org.jboss.netty.handler.codec.frame.TooLongFrameException Java Examples
The following examples show how to use
org.jboss.netty.handler.codec.frame.TooLongFrameException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShuffleHandler.java From hadoop with Apache License 2.0 | 6 votes |
@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; } else if (cause instanceof IOException) { if (cause instanceof ClosedChannelException) { LOG.debug("Ignoring closed channel error", cause); return; } String message = String.valueOf(cause.getMessage()); if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) { LOG.debug("Ignoring client socket close", cause); return; } } LOG.error("Shuffle error: ", cause); if (ch.isConnected()) { LOG.error("Shuffle error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #2
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 6 votes |
@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; } else if (cause instanceof IOException) { if (cause instanceof ClosedChannelException) { LOG.debug("Ignoring closed channel error", cause); return; } String message = String.valueOf(cause.getMessage()); if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) { LOG.debug("Ignoring client socket close", cause); return; } } LOG.error("Shuffle error: ", cause); if (ch.isConnected()) { LOG.error("Shuffle error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #3
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 6 votes |
@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; } else if (cause instanceof IOException) { if (cause instanceof ClosedChannelException) { LOG.debug("Ignoring closed channel error", cause); return; } String message = String.valueOf(cause.getMessage()); if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) { LOG.debug("Ignoring client socket close", cause); return; } } LOG.error("Shuffle error: ", cause); if (ch.isConnected()) { LOG.error("Shuffle error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #4
Source File: ShuffleHandler.java From RDFS with Apache License 2.0 | 6 votes |
@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); } }
Example #5
Source File: PullServerAuxService.java From incubator-tajo with Apache License 2.0 | 6 votes |
@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("PullServer error: ", cause); if (ch.isConnected()) { LOG.error("PullServer error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #6
Source File: TajoPullServerService.java From incubator-tajo with Apache License 2.0 | 6 votes |
@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("PullServer error: ", cause); if (ch.isConnected()) { LOG.error("PullServer error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #7
Source File: ThriftFrameDecoder.java From ikasoa with MIT License | 6 votes |
protected ChannelBuffer tryDecodeFramedMessage(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, boolean stripFraming) { int messageStartReaderIndex = buffer.readerIndex(); int messageContentsOffset = stripFraming ? messageStartReaderIndex + MESSAGE_FRAME_SIZE : messageStartReaderIndex; int messageLength = buffer.getInt(messageStartReaderIndex) + MESSAGE_FRAME_SIZE; int messageContentsLength = messageStartReaderIndex + messageLength - messageContentsOffset; if (messageContentsLength > maxFrameSize) Channels.fireExceptionCaught(ctx, new TooLongFrameException(String.format("Maximum frame size of %d exceeded .", maxFrameSize))); if (messageLength == 0) { buffer.readerIndex(messageContentsOffset); return null; } else if (buffer.readableBytes() < messageLength) return null; else { ChannelBuffer messageBuffer = extractFrame(buffer, messageContentsOffset, messageContentsLength); buffer.readerIndex(messageStartReaderIndex + messageLength); return messageBuffer; } }
Example #8
Source File: ShuffleHandler.java From big-c with Apache License 2.0 | 6 votes |
@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; } else if (cause instanceof IOException) { if (cause instanceof ClosedChannelException) { LOG.debug("Ignoring closed channel error", cause); return; } String message = String.valueOf(cause.getMessage()); if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) { LOG.debug("Ignoring client socket close", cause); return; } } LOG.error("Shuffle error: ", cause); if (ch.isConnected()) { LOG.error("Shuffle error " + e); sendError(ctx, INTERNAL_SERVER_ERROR); } }
Example #9
Source File: ManageSieveChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { try (Closeable closeable = ManageSieveMDCContext.from(ctx, attributes)) { logger.warn("Error while processing ManageSieve request", e.getCause()); if (e.getCause() instanceof TooLongFrameException) { // Max line length exceeded // See also JAMES-1190 ((ChannelManageSieveResponseWriter) ctx.getAttachment()).write("NO Maximum command line length exceeded"); } else if (e.getCause() instanceof SessionTerminatedException) { ((ChannelManageSieveResponseWriter) ctx.getAttachment()).write("OK channel is closing"); logout(ctx); } } }
Example #10
Source File: HttpDataServerHandler.java From incubator-tajo with Apache License 2.0 | 5 votes |
@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); } }
Example #11
Source File: HttpDataServerHandler.java From incubator-tajo with Apache License 2.0 | 5 votes |
@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); } }
Example #12
Source File: ThriftFrameEncoder.java From ikasoa with MIT License | 5 votes |
@Override protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if (!(msg instanceof TNettyMessage)) return msg; TNettyMessage message = (TNettyMessage) msg; int frameSize = message.getBuffer().readableBytes(); if (message.getBuffer().readableBytes() > maxFrameSize) { Channels.fireExceptionCaught(ctx, new TooLongFrameException(String.format( "Frame size exceeded on encode: frame was %d bytes, maximum allowed is %d bytes .", frameSize, maxFrameSize))); return null; } switch (message.getTransportType()) { case UNFRAMED: return message.getBuffer(); case FRAMED: ChannelBuffer frameSizeBuffer = ChannelBuffers.buffer(4); frameSizeBuffer.writeInt(message.getBuffer().readableBytes()); return ChannelBuffers.wrappedBuffer(frameSizeBuffer, message.getBuffer()); case HEADER: throw new UnsupportedOperationException("Header transport is not supported ."); case HTTP: throw new UnsupportedOperationException("HTTP transport is not supported ."); default: throw new UnsupportedOperationException("Unrecognized transport type ."); } }
Example #13
Source File: ThriftFrameDecoder.java From ikasoa with MIT License | 5 votes |
protected ChannelBuffer tryDecodeUnframedMessage(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, TProtocolFactory inputProtocolFactory) throws TException { int messageLength = 0; int messageStartReaderIndex = buffer.readerIndex(); try { TNettyTransport decodeAttemptTransport = new TNettyTransport(channel, buffer, TNettyTransportType.UNFRAMED); int initialReadBytes = decodeAttemptTransport.getReadByteCount(); TProtocol inputProtocol = inputProtocolFactory.getProtocol(decodeAttemptTransport); inputProtocol.readMessageBegin(); TProtocolUtil.skip(inputProtocol, TType.STRUCT); inputProtocol.readMessageEnd(); messageLength = decodeAttemptTransport.getReadByteCount() - initialReadBytes; } catch (TTransportException | IndexOutOfBoundsException e) { return null; } finally { if (buffer.readerIndex() - messageStartReaderIndex > maxFrameSize) Channels.fireExceptionCaught(ctx, new TooLongFrameException(String.format("Maximum frame size of %d exceeded .", maxFrameSize))); buffer.readerIndex(messageStartReaderIndex); } if (messageLength <= 0) return null; ChannelBuffer messageBuffer = extractFrame(buffer, messageStartReaderIndex, messageLength); buffer.readerIndex(messageStartReaderIndex + messageLength); return messageBuffer; }
Example #14
Source File: MemcachedFrameDecoder.java From fqueue with Apache License 2.0 | 4 votes |
private void fail(long frameLength) throws TooLongFrameException { throw new TooLongFrameException("The frame length exceeds " + maxFrameLength + ": " + frameLength); }
Example #15
Source File: MemcachedFrameDecoder.java From fqueue with Apache License 2.0 | 4 votes |
private void fail(long frameLength) throws TooLongFrameException { throw new TooLongFrameException("The frame length exceeds " + maxFrameLength + ": " + frameLength); }
Example #16
Source File: ImapChannelUpstreamHandler.java From james-project with Apache License 2.0 | 4 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) { LOGGER.warn("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); } } } }
Example #17
Source File: SizeHeaderFrameDecoder.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < 6) { return null; } int readerIndex = buffer.readerIndex(); if (buffer.getByte(readerIndex) != 'E' || buffer.getByte(readerIndex + 1) != 'S') { // special handling for what is probably HTTP if (bufferStartsWith(buffer, readerIndex, "GET ") || bufferStartsWith(buffer, readerIndex, "POST ") || bufferStartsWith(buffer, readerIndex, "PUT ") || bufferStartsWith(buffer, readerIndex, "HEAD ") || bufferStartsWith(buffer, readerIndex, "DELETE ") || bufferStartsWith(buffer, readerIndex, "OPTIONS ") || bufferStartsWith(buffer, readerIndex, "PATCH ") || bufferStartsWith(buffer, readerIndex, "TRACE ")) { throw new HttpOnTransportException("This is not a HTTP port"); } // we have 6 readable bytes, show 4 (should be enough) throw new StreamCorruptedException("invalid internal transport message format, got (" + Integer.toHexString(buffer.getByte(readerIndex) & 0xFF) + "," + Integer.toHexString(buffer.getByte(readerIndex + 1) & 0xFF) + "," + Integer.toHexString(buffer.getByte(readerIndex + 2) & 0xFF) + "," + Integer.toHexString(buffer.getByte(readerIndex + 3) & 0xFF) + ")"); } int dataLen = buffer.getInt(buffer.readerIndex() + 2); if (dataLen == NettyHeader.PING_DATA_SIZE) { // discard the messages we read and continue, this is achieved by skipping the bytes // and returning null buffer.skipBytes(6); return null; } if (dataLen <= 0) { throw new StreamCorruptedException("invalid data length: " + dataLen); } // safety against too large frames being sent if (dataLen > NINETY_PER_HEAP_SIZE) { throw new TooLongFrameException( "transport content length received [" + new ByteSizeValue(dataLen) + "] exceeded [" + new ByteSizeValue(NINETY_PER_HEAP_SIZE) + "]"); } if (buffer.readableBytes() < dataLen + 6) { return null; } buffer.skipBytes(6); return buffer; }