@Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   e.getCause().printStackTrace();
   Channel channel = e.getChannel();
   channel.close();
   System.out.println("exceptionCaught...");
 }
예제 #2
0
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {

    Throwable cause = e.getCause();
    if (cause instanceof IOException) {
      if (cause instanceof ClosedChannelException) {
        synchronized (ignoreClosedChannelExceptionLock) {
          if (ignoreClosedChannelException > 0) {
            ignoreClosedChannelException--;
            logger.debug("Swallowing an exception raised while " + "writing non-app data", cause);
            return;
          }
        }
      } else if (engine.isOutboundDone()) {
        String message = String.valueOf(cause.getMessage()).toLowerCase();
        if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
          // It is safe to ignore the 'connection reset by peer' or
          // 'broken pipe' error after sending closure_notify.
          logger.debug(
              "Swallowing a 'connection reset by peer / "
                  + "broken pipe' error occurred while writing "
                  + "'closure_notify'",
              cause);

          // Close the connection explicitly just in case the transport
          // did not close the connection automatically.
          Channels.close(ctx, succeededFuture(e.getChannel()));
          return;
        }
      }
    }

    ctx.sendUpstream(e);
  }
예제 #3
0
  @Override
  public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent event) {
    final Throwable e = event.getCause();
    final Channel c = event.getChannel();

    if (e instanceof RejectedExecutionException) {
      LOG.warn(
          getPeerUuidLoggingString()
              + "RPC rejected by the executor,"
              + " ignore this if we're shutting down",
          e);
    } else if (e instanceof ReadTimeoutException) {
      LOG.debug(getPeerUuidLoggingString() + "Encountered a read timeout");
      // Doing the cleanup here since we want to invalidate all the RPCs right _now_, and not let
      // the ReplayingDecoder continue decoding through Channels.close() below.
      cleanup(c);
    } else {
      LOG.error(getPeerUuidLoggingString() + "Unexpected exception from downstream on " + c, e);
      // For any other exception, likely a connection error, we clear the leader state
      // for those tablets that this TS is the cached leader of.
      kuduClient.demoteAsLeaderForAllTablets(this);
    }
    if (c.isOpen()) {
      Channels.close(c); // Will trigger channelClosed(), which will cleanup()
    } else { // else: presumably a connection timeout.
      cleanup(c); // => need to cleanup() from here directly.
    }
  }
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent exceptionEvent)
      throws Exception {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Exception caught at Channel: " + ctx.getChannel(), exceptionEvent.getCause());
    }

    if (exceptionHandled) {
      // ignore subsequent exceptions being thrown
      return;
    }

    exceptionHandled = true;
    Throwable cause = exceptionEvent.getCause();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Closing channel as an exception was thrown from Netty", cause);
    }

    Exchange exchange = getExchange(ctx);
    AsyncCallback callback = getAsyncCallback(ctx);

    // the state may not be set
    if (exchange != null && callback != null) {
      // set the cause on the exchange
      exchange.setException(cause);

      // close channel in case an exception was thrown
      NettyHelper.close(exceptionEvent.getChannel());

      // signal callback
      callback.done(false);
    }
  }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   Channel ch = e.getChannel();
   Throwable cause = e.getCause();
   if (cause instanceof TooLongFrameException) {
     sendError(ctx, HttpResponseStatus.BAD_REQUEST);
     return;
   }
   if (cause != null) {
     if (cause.getClass().equals(IOException.class)) {
       LOGGER.debug("Connection error: " + cause);
       StartStopListenerDelegate startStopListenerDelegate =
           (StartStopListenerDelegate) ctx.getAttachment();
       if (startStopListenerDelegate != null) {
         LOGGER.debug("Premature end, stopping...");
         startStopListenerDelegate.stop();
       }
     } else if (!cause.getClass().equals(ClosedChannelException.class)) {
       LOGGER.debug("Caught exception: " + cause);
     }
   }
   if (ch.isConnected()) {
     sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR);
   }
   e.getChannel().close();
 }
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    getLogger(ctx.getChannel()).debug("Error while processing imap request", e.getCause());

    if (e.getCause() instanceof TooLongFrameException) {

      // Max line length exceeded
      // See RFC 2683 section 3.2.1
      //
      // "For its part, a server should allow for a command line of at
      // least
      // 8000 octets. This provides plenty of leeway for accepting
      // reasonable
      // length commands from clients. The server should send a BAD
      // response
      // to a command that does not end within the server's maximum
      // accepted
      // command length."
      //
      // See also JAMES-1190
      ImapResponseComposer composer = (ImapResponseComposer) ctx.getAttachment();
      composer.untaggedResponse(
          ImapConstants.BAD + " failed. Maximum command line length exceeded");
    } else {
      // logout on error not sure if that is the best way to handle it
      final ImapSession imapSession = (ImapSession) attributes.get(ctx.getChannel());
      if (imapSession != null) imapSession.logout();

      // Make sure we close the channel after all the buffers were flushed out
      Channel channel = ctx.getChannel();
      if (channel.isConnected()) {
        channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
      }
    }
  }
 protected void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   if (e.getCause() instanceof ReadTimeoutException) {
     if (logger.isTraceEnabled()) {
       logger.trace("Connection timeout [{}]", ctx.getChannel().getRemoteAddress());
     }
     ctx.getChannel().close();
   } else {
     if (!lifecycle.started()) {
       // ignore
       return;
     }
     if (!NetworkExceptionHelper.isCloseConnectionException(e.getCause())) {
       logger.warn(
           "Caught exception while handling client http traffic, closing connection {}",
           e.getCause(),
           ctx.getChannel());
       ctx.getChannel().close();
     } else {
       logger.debug(
           "Caught exception while handling client http traffic, closing connection {}",
           e.getCause(),
           ctx.getChannel());
       ctx.getChannel().close();
     }
   }
 }
예제 #8
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   Channel channel = e.getChannel();
   Throwable t = e.getCause();
   logger.debug("exception at :{}", channel);
   streamClientListener.onException(channel, t);
   // super.exceptionCaught(ctx, e);
 }
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
      logger.warn(
          "Unexpected exception from the " + (server ? "server" : "client") + " side",
          e.getCause());

      exception.compareAndSet(null, e.getCause());
      e.getChannel().close();
    }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
   if (e.getCause() instanceof IOException) {
     LOG.warn("IOException from downstream.", e.getCause());
   } else {
     LOG.warn("Unexpected exception from downstream.", e.getCause());
   }
   // Offer default object
   answer.offer(false);
   Channels.close(e.getChannel());
 }
예제 #11
0
  /**
   * @see
   *     org.jboss.netty.channel.SimpleChannelUpstreamHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext,
   *     org.jboss.netty.channel.ExceptionEvent)
   */
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
    Throwable cause = event.getCause();
    if (being_closed.get() == false) {
      if (!(cause instanceof ConnectException)) {
        LOG.info("Connection failed:" + client.getRemoteAddr(), cause);
      }

      client.exceptionChannel(event.getChannel());
      client.reconnect();
    }
  }
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Channel ch = e.getChannel();
    Throwable cause = e.getCause();
    if (cause instanceof TooLongFrameException) {
      sendError(ctx, BAD_REQUEST);
      return;
    }

    cause.printStackTrace();
    if (ch.isConnected()) {
      sendError(ctx, INTERNAL_SERVER_ERROR);
    }
  }
예제 #13
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   if (e.getCause() instanceof JsonParseException) {
     BaseTransport.respond(
         e.getChannel(), HttpResponseStatus.INTERNAL_SERVER_ERROR, "Broken JSON encoding.");
   } else if (e.getCause() instanceof SessionHandler.NotFoundException) {
     BaseTransport.respond(
         e.getChannel(),
         HttpResponseStatus.NOT_FOUND,
         "Session not found. Cannot send data to non-existing session.");
   } else {
     super.exceptionCaught(ctx, e);
   }
 }
예제 #14
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
   Throwable cause = event.getCause();
   if (!(cause instanceof ConnectException)) {
     LOG.info("Connection failed " + client.dstAddressPrefixedName, cause);
   }
 }
예제 #15
0
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Channel ch = e.getChannel();
    Throwable cause = e.getCause();
    if (cause instanceof TooLongFrameException) {
      sendError(ctx, BAD_REQUEST);
      return;
    }

    LOG.error("Shuffle error: ", cause);
    shuffleMetrics.failedOutput();
    if (ch.isConnected()) {
      LOG.error("Shuffle error " + e);
      sendError(ctx, INTERNAL_SERVER_ERROR);
    }
  }
예제 #16
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
   // На канале произошло исключение. Выводим ошибку, закрываем канал.
   // Server.logger.log(Level.WARNING, "Exception from downstream", e.getCause());
   ctx.getChannel().close();
   log.info("exceptionCaught", e.getCause());
 }
예제 #17
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   try {
     e.getChannel().close();
   } catch (Exception ex) {
   }
 }
예제 #18
0
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    logger.error(
        "something goes wrong with channel:{}, exception={}",
        ctx.getChannel(),
        ExceptionUtils.getStackTrace(e.getCause()));

    ctx.getChannel().close();
  }
예제 #19
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
   final NioSocketChannel ch = (NioSocketChannel) e.getChannel();
   final ClientConnection conn = connectionMap.get(ch);
   final Throwable t = e.getCause();
   if (conn != null && t instanceof Exception) {
     runOnCorrectThread(
         ch,
         new Runnable() {
           public void run() {
             conn.handleException((Exception) t);
           }
         });
   } else {
     log.error("Unhandled exception", t);
   }
 }
예제 #20
0
파일: NetServer.java 프로젝트: hansd/vert.x
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
   final NioSocketChannel ch = (NioSocketChannel) e.getChannel();
   final NetSocket sock = socketMap.get(ch);
   ch.close();
   final Throwable t = e.getCause();
   if (sock != null && t instanceof Exception) {
     VertxInternal.instance.executeOnContext(
         sock.getContextID(),
         new Runnable() {
           public void run() {
             sock.handleException((Exception) t);
           }
         });
   } else {
     t.printStackTrace();
   }
 }
예제 #21
0
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Throwable cause = e.getCause();

    if (!(cause instanceof ConnectException)) {
      stats.accumulateOutcomeWithDelta(Outcome.UNHANDLED_FAILURE, 0);
    }
    scheduleReconnect();
  }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   Channel ch = e.getChannel();
   Throwable cause = e.getCause();
   if (cause instanceof TooLongFrameException) {
     sendError(ctx, HttpResponseStatus.BAD_REQUEST);
     return;
   }
   if (cause != null
       && !cause.getClass().equals(ClosedChannelException.class)
       && !cause.getClass().equals(IOException.class)) {
     LOGGER.debug("Caught exception", cause);
   }
   if (ch.isConnected()) {
     sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR);
   }
   e.getChannel().close();
 }
예제 #23
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   if (e.getCause() instanceof ClosedChannelException) {
     // these are part of life
     // XXX Debug logging might be good
     return;
   }
   super.exceptionCaught(ctx, e);
 }
예제 #24
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
   Throwable t = event.getCause();
   if (t instanceof ConnectException) {
     LOG.warn("Connection to pacemaker failed. Trying to reconnect {}", t.getMessage());
   } else {
     LOG.error("Exception occurred in Pacemaker.", t);
   }
   client.reconnect();
 }
 public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent exceptionEvent)
     throws Exception {
   Throwable t = exceptionEvent.getCause();
   if (t != null && IOException.class.isAssignableFrom(t.getClass())) {
     LOG.debug(t, t);
   } else {
     LOG.debug(t, t);
   }
   ctx.sendUpstream(exceptionEvent);
 }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   HttpServerChannelHandler handler = (HttpServerChannelHandler) ctx.getAttachment();
   if (handler != null) {
     handler.exceptionCaught(ctx, e);
   } else {
     throw new IllegalStateException(
         "HttpServerChannelHandler not found as attachment. Cannot handle caught exception.",
         e.getCause());
   }
 }
예제 #27
0
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
      final NioSocketChannel ch = (NioSocketChannel) e.getChannel();
      final NetSocket sock = socketMap.remove(ch);
      ch.close();
      final Throwable t = e.getCause();

      log.error("Exception on netserver", t);

      if (sock != null && t instanceof Exception) {
        sock.getContext()
            .execute(
                new Runnable() {
                  public void run() {
                    sock.handleException((Exception) t);
                  }
                });
      } else {
        // Ignore - any exceptions not associated with any sock (e.g. failure in ssl handshake) will
        // be communicated explicitly
      }
    }
예제 #28
0
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    if (httpChildChannel != null) {
      HttpChildChannel httpChildChannel = this.httpChildChannel;
      this.httpChildChannel = null;

      if (httpChildChannel.setReadClosed() || httpChildChannel.setWriteClosed()) {
        fireExceptionCaught(httpChildChannel, e.getCause());
        fireChannelClosed(httpChildChannel);
      }
    }

    Channel channel = ctx.getChannel();
    channel.close();
  }
예제 #29
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   e.getCause().printStackTrace(System.err);
   RedisConnection conn = (RedisConnection) ctx.getChannel().getAttachment();
   conn.releaseBroken();
   /*
    * ChannelFuture future = ctx.getChannel().disconnect();
    * future.addListener(new ChannelFutureListener() {
    *
    * @Override public void operationComplete(ChannelFuture cf) throws
    * Exception { RedisConnection conn =
    * (RedisConnection)cf.getChannel().getAttachment();
    * conn.releaseBroken(); } });
    */
 }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   if (e.getCause() instanceof ClosedChannelException) {
     // do nothing
   } else if (e.getCause() instanceof UnresolvedAddressException) {
     logger.error(
         "Unable to resolve one of the server addresses: [{}]", e.getCause().getMessage());
   } else if (e.getCause() instanceof ConnectException) {
     logger.error("Unable to connect: [{}]", e.getCause().getMessage());
   } else if (e.getCause().getMessage() != null
       && e.getCause().getMessage().contains("Connection reset by peer")) {
     // still do nothing
   } else {
     super.exceptionCaught(ctx, e);
   }
 }