use of io.netty.handler.codec.TooLongFrameException in project vert.x by eclipse.
the class Http1xTest method testServerConnectionExceptionHandler.
@Test
public void testServerConnectionExceptionHandler() throws Exception {
server.connectionHandler(conn -> {
conn.exceptionHandler(err -> {
assertTrue(err instanceof TooLongFrameException);
testComplete();
});
});
server.requestHandler(req -> {
fail();
});
CountDownLatch listenLatch = new CountDownLatch(1);
server.listen(onSuccess(s -> listenLatch.countDown()));
awaitLatch(listenLatch);
HttpClientRequest req = client.post(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp -> {
});
req.putHeader("the_header", TestUtils.randomAlphaString(10000));
req.sendHead();
await();
}
use of io.netty.handler.codec.TooLongFrameException in project netty by netty.
the class StompSubframeDecoder method readLine.
private static String readLine(ByteBuf buffer, int maxLineLength) {
AppendableCharSequence buf = new AppendableCharSequence(128);
int lineLength = 0;
for (; ; ) {
byte nextByte = buffer.readByte();
if (nextByte == StompConstants.CR) {
nextByte = buffer.readByte();
if (nextByte == StompConstants.LF) {
return buf.toString();
}
} else if (nextByte == StompConstants.LF) {
return buf.toString();
} else {
if (lineLength >= maxLineLength) {
throw new TooLongFrameException("An STOMP line is larger than " + maxLineLength + " bytes.");
}
lineLength++;
buf.append((char) nextByte);
}
}
}
use of io.netty.handler.codec.TooLongFrameException in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleTooLongFrameExceptionAndAddCauseMetadata.
@Test
public void shouldHandleTooLongFrameExceptionAndAddCauseMetadata() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new TooLongFrameException());
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("The request exceeded the maximum payload size allowed");
}
use of io.netty.handler.codec.TooLongFrameException in project bookkeeper by apache.
the class PerChannelBookieClient method exceptionCaught.
/**
* Called by netty when an exception happens in one of the netty threads
* (mostly due to what we do in the netty threads).
*/
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
exceptionCounter.inc();
if (cause instanceof CorruptedFrameException || cause instanceof TooLongFrameException) {
LOG.error("Corrupted frame received from bookie: {}", ctx.channel().remoteAddress());
ctx.close();
return;
}
if (cause instanceof AuthHandler.AuthenticationException) {
LOG.error("Error authenticating connection", cause);
errorOutOutstandingEntries(BKException.Code.UnauthorizedAccessException);
Channel c = ctx.channel();
if (c != null) {
closeChannel(c);
}
return;
}
if (cause instanceof DecoderException && cause.getCause() instanceof SSLHandshakeException) {
LOG.error("TLS handshake failed", cause);
errorOutPendingOps(BKException.Code.SecurityException);
Channel c = ctx.channel();
if (c != null) {
closeChannel(c);
}
}
if (cause instanceof IOException) {
LOG.warn("Exception caught on:{} cause:", ctx.channel(), cause);
ctx.close();
return;
}
synchronized (this) {
if (state == ConnectionState.CLOSED) {
if (LOG.isDebugEnabled()) {
LOG.debug("Unexpected exception caught by bookie client channel handler, " + "but the client is closed, so it isn't important", cause);
}
} else {
LOG.error("Unexpected exception caught by bookie client channel handler", cause);
}
}
// Since we are a library, cant terminate App here, can we?
ctx.close();
}
use of io.netty.handler.codec.TooLongFrameException in project graylog2-server by Graylog2.
the class LenientDelimiterBasedFrameDecoderTest method testFailSlowTooLongFrameRecovery.
@Test
public void testFailSlowTooLongFrameRecovery() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new LenientDelimiterBasedFrameDecoder(1, true, false, false, Delimiters.nulDelimiter()));
for (int i = 0; i < 2; i++) {
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }));
try {
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0 })));
fail(DecoderException.class.getSimpleName() + " must be raised.");
} catch (TooLongFrameException e) {
// Expected
}
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A', 0 }));
ByteBuf buf = ch.readInbound();
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
buf.release();
}
}
Aggregations