static ConnectionObserver compositeConnectionObserver(ConnectionObserver observer, ConnectionObserver other) { if (observer == ConnectionObserver.emptyListener()) { return other; if (other == ConnectionObserver.emptyListener()) { return observer;
@Override public Context currentContext() { return listener.currentContext(); }
@Override public void onStateChange(Connection connection, State newState) { for (ConnectionObserver observer : observers) { observer.onStateChange(connection, newState); } } }
@Override public Bootstrap apply(Bootstrap b) { ConnectionObserver observer = BootstrapHandlers.connectionObserver(b); BootstrapHandlers.connectionObserver(b, observer.then(this.observer)); return b; } }
@Override public void onUncaughtException(Connection connection, Throwable error) { for (ConnectionObserver observer : observers) { observer.onUncaughtException(connection, error); } }
owner().onStateChange(connection, State.DISCONNECTING); return; owner().onStateChange(connection, State.DISCONNECTING); .getAndSet(ConnectionObserver.emptyListener()); obs.onStateChange(connection, State.RELEASED); }); return; owner().onStateChange(connection, newState);
@Override protected void onInboundClose() { if (isInboundCancelled() || isInboundDisposed()) { return; } listener().onStateChange(this, HttpClientState.RESPONSE_INCOMPLETE); if (responseState == null) { if (markSentBody()) { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE_SENDING_REQUEST); } else { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE); } return; } super.onInboundError(PrematureCloseException.DURING_RESPONSE); }
@Override public Bootstrap apply(Bootstrap bootstrap) { ConnectionObserver observer = BootstrapHandlers.connectionObserver(bootstrap); BootstrapHandlers.connectionObserver(bootstrap, observer.then(this)); return bootstrap; }
@Override public void onUncaughtException(Connection connection, Throwable error) { for (ConnectionObserver observer : observers) { observer.onUncaughtException(connection, error); } }
owner().onStateChange(connection, State.DISCONNECTING); return; owner().onStateChange(connection, State.DISCONNECTING); .getAndSet(ConnectionObserver.emptyListener()); obs.onStateChange(connection, State.RELEASED); }); return; owner().onStateChange(connection, newState);
@Override protected void onInboundClose() { if (isInboundCancelled() || isInboundDisposed()) { return; } listener().onStateChange(this, HttpClientState.RESPONSE_INCOMPLETE); if (responseState == null) { if (markSentBody()) { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE_SENDING_REQUEST); } else { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE); } return; } super.onInboundError(PrematureCloseException.DURING_RESPONSE); }
@Override public void onStateChange(Connection connection, State newState) { for (ConnectionObserver observer : observers) { observer.onStateChange(connection, newState); } } }
@Override public ServerBootstrap apply(ServerBootstrap b) { ConnectionObserver observer = BootstrapHandlers.childConnectionObserver(b); BootstrapHandlers.childConnectionObserver(b, observer.then(this.observer)); return b; } }
static ConnectionObserver compositeConnectionObserver(ConnectionObserver observer, ConnectionObserver other) { if (observer == ConnectionObserver.emptyListener()) { return other; if (other == ConnectionObserver.emptyListener()) { return observer;
@Override public void onUncaughtException(Connection connection, Throwable error) { sink.error(error); obs.onUncaughtException(connection, error); }
@Override public Context currentContext() { return observers[observers.length - 1].currentContext(); }
/** * React on connection fatal error, will request a disconnecting state * change by default. It should only catch exceptions that can't be consumed by a * {@link NettyInbound#receive} subscriber. * * @param connection the remote connection * @param error the failing cause */ default void onUncaughtException(Connection connection, Throwable error) { onStateChange(connection, State.DISCONNECTING); }
@Override public ServerBootstrap apply(ServerBootstrap b) { ConnectionObserver observer = BootstrapHandlers.childConnectionObserver(b); BootstrapHandlers.childConnectionObserver(b, observer.then(this)); return b; } }
/** * Obtain and remove the current childHandler {@link ConnectionObserver} from the * bootstrap. * * @param b the bootstrap to scan * * @return current {@link ConnectionObserver} or null * */ @SuppressWarnings("unchecked") public static ConnectionObserver childConnectionObserver(ServerBootstrap b) { Objects.requireNonNull(b, "bootstrap"); ConnectionObserver obs = (ConnectionObserver) b.config() .childOptions() .get(OBSERVER_OPTION); b.childOption(OBSERVER_OPTION, null); if (obs == null) { return ConnectionObserver.emptyListener(); //will not be triggered in } return obs; }
@Override public void onUncaughtException(Connection c, Throwable error) { sink.error(error); obs.onUncaughtException(c, error); } }