@Override public void operationComplete(CloseFuture ioFuture) { if (!future.isConnected()) { future.setException(new RuntimeException("Failing connect future because accept is closed")); } } });
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { connectFuture.setException(e.getCause()); }
@Override protected void doExceptionCaught(IoSessionEx session, Throwable cause) throws Exception { if (logger.isDebugEnabled()) { String message = format("Error on HTTP connection attempt: %s", cause); if (logger.isTraceEnabled()) { // note: still debug level, but with extra detail about the exception logger.debug(message, cause); } else { logger.debug(message); } } session.close(true); ConnectFuture httpConnectFuture = HTTP_CONNECT_FUTURE_KEY.remove(session); if (httpConnectFuture != null) { httpConnectFuture.setException(cause); } }
@Override protected void doExceptionCaught(HttpSession session, Throwable cause) throws Exception { if (logger.isDebugEnabled()) { String message = format("Error on SSE connection attempt: %s", cause); if (logger.isTraceEnabled()) { // note: still debug level, but with extra detail about the exception logger.debug(message, cause); } else { logger.debug(message); } } session.close(true); ConnectFuture sseConnectFuture = SSE_CONNECT_FUTURE_KEY.remove(session); if (sseConnectFuture != null) { sseConnectFuture.setException(cause); } }
@Override protected void doExceptionCaught(IoSessionEx session, Throwable cause) throws Exception { if (logger.isDebugEnabled()) { String message = format("Error on SSL connection attempt: %s", cause); if (logger.isTraceEnabled()) { // note: still debug level, but with extra detail about the exception logger.debug(message, cause); } else { logger.debug(message); } } session.close(true); // exception may be triggered by SSL handshake ConnectFuture sslConnectFuture = SSL_CONNECT_FUTURE_KEY.remove(session); if (sslConnectFuture != null) { sslConnectFuture.setException(cause); } }
@Override protected void doExceptionCaught(HttpSession createSession, Throwable cause) throws Exception { ConnectRequest<?> connectRequest = CONNECT_REQUEST_KEY.get(createSession); ConnectFuture connectFuture = connectRequest.connectFuture; if (!connectFuture.isDone()) { connectFuture.setException(cause); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (future != null) { future.setException(e.getCause()); } else { LOGGER.error("Exception caught in IoSessionFactoryChannelHandler", e.getCause()); ctx.sendUpstream(e); } } }
@Override protected void doExceptionCaught(IoSessionEx session, Throwable cause) throws Exception { if (logger.isDebugEnabled()) { String message = format("Error on WebSocket connection: %s", cause); if (logger.isTraceEnabled()) { // note: still debug level, but with extra detail about the exception logger.debug(message, cause); } else { logger.debug(message); } } WsnSession wsnSession = SESSION_KEY.get(session); if (wsnSession != null) { wsnSession.setCloseException(cause); } session.close(true); ConnectFuture wsnConnectFuture = WSN_CONNECT_FUTURE_KEY.remove(session); if (wsnConnectFuture != null) { wsnConnectFuture.setException(cause); } }
protected <T extends ConnectFuture> void connectUsingExistingTransport(final ConnectFuture connectFuture, IoSession transportSession, HttpConnectSessionFactory httpSessionFactory) { HTTP_SESSION_FACTORY_KEY.set(transportSession, httpSessionFactory); HTTP_CONNECT_FUTURE_KEY.set(transportSession, connectFuture); try { bridgeHandler.sessionOpened(transportSession); } catch (Exception e) { connectFuture.setException(e); } }
@Override protected void doSessionClosed(HttpConnectSession httpSession) throws Exception { // if WebSocket handshake incomplete, fail the WsnSession connect future ConnectFuture wsnConnectFuture = WSN_CONNECT_FUTURE_KEY.get(httpSession); assert (wsnConnectFuture != null); if (!wsnConnectFuture.isDone() && httpSession.getParent().getReadBytes() < 10L) { wsnConnectFuture.setException(new Exception("WSN connection failed")); } }
addListener(fallbackConnectListener); } else { connectFuture.setException(new ConnectException("No fallback connector available.")); connectFuture.setException(new ConnectException("No fallback address available."));
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { connectFuture.setException(future.getCause()); } else { channelGroup.add(future.getChannel()); } } });
@Override public void operationComplete(CloseFuture future) { if (wsnConnectFuture.isDone()) { return; } HttpConnectSession httpSession = (HttpConnectSession) future.getSession(); HttpStatus httpStatus = httpSession.getStatus(); switch (httpStatus) { case INFO_SWITCHING_PROTOCOLS: doUpgrade(httpSession); break; default: Throwable exception = new ConnectException(String.format("Unexpected HTTP response %d - %s", httpStatus.code(), httpStatus.reason())).fillInStackTrace(); if (logger.isDebugEnabled()) { logger.debug("WsnConnector: failing connection with exception " + exception); } wsnConnectFuture.setException(exception); break; } }
private void callNextExceptionCaught(Entry entry, IoSession session, Throwable cause) { // Notify the related future. ConnectFuture future = (ConnectFuture) session .removeAttribute(SESSION_CREATED_FUTURE); if (future == null) { try { IoFilter filter = entry.getFilter(); NextFilter nextFilter = entry.getNextFilter(); filter.exceptionCaught(nextFilter, session, cause); } catch (Throwable e) { LOGGER .warn( "Unexpected exception from exceptionCaught handler.", e); } } else { // Please note that this place is not the only place that // calls ConnectFuture.setException(). session.close(true); future.setException(cause); } }
private void callNextExceptionCaught(Entry entry, IoSession session, Throwable cause) { // Notify the related future. ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE); if (future == null) { try { IoFilter filter = entry.getFilter(); NextFilter nextFilter = entry.getNextFilter(); filter.exceptionCaught(nextFilter, session, cause); } catch (Throwable e) { LOGGER.warn("Unexpected exception from exceptionCaught handler.", e); } } else { // Please note that this place is not the only place that // calls ConnectFuture.setException(). if (!session.isClosing()) { // Call the closeNow method only if needed session.closeNow(); } future.setException(cause); } }
private void callNextExceptionCaught(Entry entry, IoSession session, Throwable cause) { // Notify the related future. ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE); if (future == null) { try { IoFilter filter = entry.getFilter(); NextFilter nextFilter = entry.getNextFilter(); filter.exceptionCaught(nextFilter, session, cause); } catch (Throwable e) { LOGGER.warn("Unexpected exception from exceptionCaught handler.", e); } } else { // Please note that this place is not the only place that // calls ConnectFuture.setException(). if (!session.isClosing()) { // Call the closeNow method only if needed session.closeNow(); } future.setException(cause); } }
protected void callNextExceptionCaught(Entry entry, IoSession session, Throwable cause) { // Notify the related future. ConnectFuture future = (ConnectFuture) session .removeAttribute(SESSION_CREATED_FUTURE); if (future == null) { try { IoFilter filter = entry.getFilter(); NextFilter nextFilter = entry.getNextFilter(); filter.exceptionCaught(nextFilter, session, cause); } catch (Throwable e) { LOGGER .warn( "Unexpected exception from exceptionCaught handler.", e); } } else { // Please note that this place is not the only place that // calls ConnectFuture.setException(). session.close(true); future.setException(cause); } }
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { // needed by HTTPS upgrade to websocket if (!session.isClosing()) { IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); } SslSession sslSession = SSL_SESSION_KEY.get(session); if (sslSession != null) { if (!sslSession.isClosing()) { // behave similarly to connection reset by peer at NIO layer sslSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); } } else { // SSL handshake incomplete, fail the SslSession connect future ConnectFuture sslConnectFuture = SSL_CONNECT_FUTURE_KEY.remove(session); if (sslConnectFuture != null) { sslConnectFuture.setException(new Exception("SSL connection failed")); } } }
private <T extends ConnectFuture> void connectUsingNewTransport(final ConnectFuture connectFuture, ResourceAddress address, HttpConnectSessionFactory httpSessionFactory) { // propagate connection failure, if necessary IoFutureListener<ConnectFuture> parentConnectListener = future -> { // fail bridge connect future if parent connect fails if (!future.isConnected()) { connectFuture.setException(future.getException()); } }; ResourceAddress transportAddress = address.getTransport(); BridgeConnector connector = bridgeServiceFactory.newBridgeConnector(transportAddress); IoSessionInitializer<ConnectFuture> parentInitializer = createParentInitializer(address, connectFuture, httpSessionFactory); connector.connect(transportAddress, bridgeHandler, parentInitializer).addListener(parentConnectListener); }
ConnectRequest<?> connectRequest = CONNECT_REQUEST_KEY.get(createSession); ConnectFuture connectFuture = connectRequest.connectFuture; connectFuture.setException(new IllegalStateException( "Create handshake failed: invalid response").fillInStackTrace()); return;