/** * {@inheritDoc} */ public Key addCloseHandler(final CloseHandler<? super T> handler) { Assert.checkNotNullParam("handler", handler); synchronized (closeLock) { if (state == State.OPEN || state == State.CLOSING) { final Key key = new KeyImpl<T>(this); final Map<Key, CloseHandler<? super T>> closeHandlers = this.closeHandlers; if (closeHandlers == null) { final IdentityHashMap<Key, CloseHandler<? super T>> newMap = new IdentityHashMap<Key, CloseHandler<? super T>>(); this.closeHandlers = newMap; newMap.put(key, handler); } else { closeHandlers.put(key, handler); } return key; } } runCloseTask(new CloseHandlerTask(handler, null)); return new NullKey(); }
/** * {@inheritDoc} */ public Key addCloseHandler(final CloseHandler<? super T> handler) { if (handler == null) { throw new NullPointerException("handler is null"); } synchronized (closeLock) { if (state == State.OPEN || state == State.CLOSING) { final Key key = new KeyImpl<T>(this); final Map<Key, CloseHandler<? super T>> closeHandlers = this.closeHandlers; if (closeHandlers == null) { final IdentityHashMap<Key, CloseHandler<? super T>> newMap = new IdentityHashMap<Key, CloseHandler<? super T>>(); this.closeHandlers = newMap; newMap.put(key, handler); } else { closeHandlers.put(key, handler); } return key; } } runCloseTask(new CloseHandlerTask(handler, null)); return new NullKey(); }
/** * {@inheritDoc} */ public Key addCloseHandler(final CloseHandler<? super T> handler) { Assert.checkNotNullParam("handler", handler); synchronized (closeLock) { if (state == State.OPEN || state == State.CLOSING) { final Key key = new KeyImpl<T>(this); final Map<Key, CloseHandler<? super T>> closeHandlers = this.closeHandlers; if (closeHandlers == null) { final IdentityHashMap<Key, CloseHandler<? super T>> newMap = new IdentityHashMap<Key, CloseHandler<? super T>>(); this.closeHandlers = newMap; newMap.put(key, handler); } else { closeHandlers.put(key, handler); } return key; } } runCloseTask(new CloseHandlerTask(handler, null)); return new NullKey(); }