### Question:
SubscribeableContentsObsSet extends AbstractSet<E> implements ObservableSet<E> { public Subscription addSubscriber(Function<? super E, Subscription> subscriber) { Objects.requireNonNull(subscriber); subscribers.add(subscriber); List<E> keys = new ArrayList<>(map.keySet()); keys.forEach(key -> { List<Subscription> otherSubs = map.get(key); Subscription sub = subscriber.apply(key); otherSubs.add(sub); map.put(key, otherSubs); }); return () -> removeSubscriber(subscriber); } SubscribeableContentsObsSet();  SubscribeableContentsObsSet(Comparator<? super E> comparator); @Override Iterator<E> iterator(); @Override int size(); @Override boolean add(E e); @SuppressWarnings("unchecked") @Override boolean remove(Object o); Subscription addSubscriber(Function<? super E, Subscription> subscriber); Subscription addChangeListener(SetChangeListener<? super E> listener); Subscription addInvalidationListener(InvalidationListener listener); @Override void addListener(SetChangeListener<? super E> listener); @Override void removeListener(SetChangeListener<? super E> listener); @Override void addListener(InvalidationListener listener); @Override void removeListener(InvalidationListener listener);  }### Answer:
@Test public void adding_subscriber_and_removing_it_will_not_throw_exception() { SubscribeableContentsObsSet<Integer> set = new SubscribeableContentsObsSet<>(); Subscription removeSubscriber = set.addSubscriber(i -> Subscription.EMPTY); removeSubscriber.unsubscribe(); }