@Override protected void finalize() throws Throwable { IoUtils.safeClose(selector); } }
@Override public void run() { IoUtils.safeClose(i); } });
@Override public void run() { IoUtils.safeClose(channel); } });
@Override public void handleEvent(StreamConnection channel) { IoUtils.safeClose(channel); // Close the channel right away } }, options);
public void onSuccess() { if (this.outputStream.size() > 0) { handleFrame(); } if (logger.isTraceEnabled()) { logger.trace("XHR receive request completed."); } IoUtils.safeClose(this.connection); executeReceiveRequest(this.request, this.url, this.headers, this.session, this.connectFuture); }
@Override public void close() throws IOException { this.stopped = true; watchThread.interrupt(); IoUtils.safeClose(watchService); }
@Override public void handleException(final StreamSourceChannel channel, final IOException e) { //make sure the listeners have been invoked //unless the connection has been killed this is a no-op invokeExchangeCompleteListeners(); UndertowLogger.REQUEST_LOGGER.debug("Exception draining request stream", e); IoUtils.safeClose(connection); } }
@Override public void run() { try { mh.handle(dis, correlationId); } catch (IOException e) { log.error(e); } finally { IoUtils.safeClose(dis); } }
@Override public void handleException(StreamSinkChannel channel, IOException exception) { IoUtils.safeClose(exchange.getConnection()); } }));
private void handleError(IOException exception) { UndertowLogger.REQUEST_IO_LOGGER.ioException(exception); currentRequest.setFailed(exception); currentRequest = null; pendingResponse = null; safeClose(connection); }
@Override public void handleEvent(StreamSinkChannel channel) { if(timerKey != null) { timerKey.remove(); } for (ChannelListener<ServerSentEventConnection> listener : closeTasks) { ChannelListeners.invokeChannelListener(ServerSentEventConnection.this, listener); } IoUtils.safeClose(ServerSentEventConnection.this); } });
private void handleFailedRead(ConduitStreamSourceChannel channel, int res) { if (res == 0) { channel.setReadListener(this); channel.resumeReads(); } else if (res == -1) { IoUtils.safeClose(connection); } }
public void onFailure(Throwable failure) { IoUtils.safeClose(this.connection); if (this.connectFuture.setException(failure)) { return; } if (this.session.isDisconnected()) { this.session.afterTransportClosed(null); } else { this.session.handleTransportError(failure); this.session.afterTransportClosed(new CloseStatus(1006, failure.getMessage())); } } }
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { try { if (state != 0) { return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); } else { return next.transferFrom(source, count, throughBuffer); } } catch (IOException| RuntimeException | Error e) { IoUtils.safeClose(connection); throw e; } }
IoUtils.safeClose(connection);
protected void write(MessageWriter writer) throws IOException { CancellableDataOutputStream output = new CancellableDataOutputStream(channel.writeMessage()); try { writer.write(output); } catch (IOException e) { output.cancel(); throw e; } finally { IoUtils.safeClose(output); } }
static void handleFailure(HttpServerExchange exchange, ProxyClientHandler proxyClientHandler, Predicate idempotentRequestPredicate, IOException e) { UndertowLogger.PROXY_REQUEST_LOGGER.proxyRequestFailed(exchange.getRequestURI(), e); if(exchange.isResponseStarted()) { IoUtils.safeClose(exchange.getConnection()); } else if(idempotentRequestPredicate.resolve(exchange) && proxyClientHandler != null) { proxyClientHandler.failed(exchange); //this will attempt a retry if configured to do so } else { exchange.setStatusCode(StatusCodes.SERVICE_UNAVAILABLE); exchange.endExchange(); } }
public void exchangeComplete(final HttpServerExchange exchange) { if (!exchange.isUpgrade() && exchange.isPersistent()) { startRequest(); ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel(); channel.getReadSetter().set(this); channel.wakeupReads(); } else if(!exchange.isPersistent()) { safeClose(exchange.getConnection()); } }