| | |
| | | |
| | | @Override |
| | | public NextAction handleRead(final FilterChainContext ctx) { |
| | | final GrizzlyBackpressureSubscription immutableRef = downstream; |
| | | if (immutableRef != null) { |
| | | return immutableRef.handleRead(ctx); |
| | | } |
| | | ctx.suspend(); |
| | | return ctx.getSuspendAction(); |
| | | // handleRead() is invoked only after handleAccept() completion, downstream cannot be null. |
| | | return downstream.handleRead(ctx); |
| | | } |
| | | |
| | | @Override |
| | | public void exceptionOccurred(final FilterChainContext ctx, final Throwable error) { |
| | | // downstream can be null if an error happen before handleAccept() completion. |
| | | final GrizzlyBackpressureSubscription immutableRef = downstream; |
| | | if (immutableRef != null) { |
| | | immutableRef.onError(error); |
| | |
| | | @Override |
| | | public NextAction handleClose(final FilterChainContext ctx) { |
| | | isClosed = true; |
| | | // downstream can be null if the connection is closed before handleAccept() completion. |
| | | final GrizzlyBackpressureSubscription immutableRef = downstream; |
| | | if (immutableRef != null) { |
| | | immutableRef.onComplete(); |
| | |
| | | connection.closeSilently(); |
| | | } |
| | | |
| | | private void closeConnection() { |
| | | downstream.cancel(); |
| | | connection.closeSilently(); |
| | | } |
| | | |
| | | @Override |
| | | public void disconnect(final ResultCode resultCode, final String diagnosticMessage) { |
| | | notifyConnectionDisconnected(resultCode, diagnosticMessage); |
| | |
| | | ).doAfterTerminate(new Action() { |
| | | @Override |
| | | public void run() throws Exception { |
| | | closeConnection(); |
| | | // handleClose() will be invoked once this connection has been closed. |
| | | connection.closeSilently(); |
| | | } |
| | | }).subscribe(); |
| | | } |