io.netty.handler.codec.TooLongFrameException Java Examples
The following examples show how to use
io.netty.handler.codec.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: NumberParser.java From NioImapClient with Apache License 2.0 | 6 votes |
@Override public boolean process(byte value) throws Exception { char nextByte = (char) value; if (Character.isWhitespace(nextByte)) { return size == 0; } else if (!Character.isDigit(nextByte)) { return false; } else { if (size >= maxLength) { throw new TooLongFrameException( "Number is larger than " + maxLength + " bytes."); } seq.append(nextByte); size++; return true; } }
Example #2
Source File: HttpObjectAggregatorTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testOversizedResponse() { EmbeddedChannel embedder = new EmbeddedChannel(new HttpObjectAggregator(4)); HttpResponse message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); HttpContent chunk1 = new DefaultHttpContent(Unpooled.copiedBuffer("test", CharsetUtil.US_ASCII)); HttpContent chunk2 = new DefaultHttpContent(Unpooled.copiedBuffer("test2", CharsetUtil.US_ASCII)); assertFalse(embedder.writeInbound(message)); assertFalse(embedder.writeInbound(chunk1)); try { embedder.writeInbound(chunk2); fail(); } catch (TooLongFrameException expected) { // Expected } assertFalse(embedder.isOpen()); assertFalse(embedder.finish()); }
Example #3
Source File: TestDelimitedLengthFieldBasedFrameDecoder.java From datacollector with Apache License 2.0 | 6 votes |
@Test public void testMaxFrameLengthOverflow() throws Exception { Charset charset = CharsetUtil.ISO_8859_1; // maxFrameLength plus adjustment would overflow an int final long numBytes = Integer.MAX_VALUE - 1; final int lengthAdjustment = 10; EmbeddedChannel ch = getTestChannel(charset, (int) numBytes, lengthAdjustment, true); //this is a bad frame, but will still test the overflow condition String longString = String.valueOf(numBytes) + " abcd"; try { ch.writeInbound(Unpooled.copiedBuffer(longString, charset)); Assert.fail("TooLongFrameException should have been thrown"); } catch (TooLongFrameException ignored) { //ignored } Assert.assertNull(ch.readInbound()); ch.close(); }
Example #4
Source File: ExceptionHandler.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (ctx.channel().isActive()) { LOG.error("Exception occurred while processing connection pipeline", cause); if ((cause instanceof InvalidEncodingException) || (cause instanceof TooLongFrameException || (cause instanceof DecoderException))) { LOG.info("Disconnecting channel to ovsdb {}", ctx.channel()); ctx.channel().disconnect(); return; } /* In cases where a connection is quickly established and the closed Catch the IOException and close the channel. Similarly if the peer is powered off, Catch the read time out exception and close the channel */ if ((cause instanceof IOException) || (cause instanceof ReadTimeoutException)) { LOG.info("Closing channel to ovsdb {}", ctx.channel()); ctx.channel().close(); return; } LOG.error("Exception was not handled by the exception handler, re-throwing it for next handler"); ctx.fireExceptionCaught(cause); } }
Example #5
Source File: DelimiterBasedFrameDecoderTest.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
@Test public void testFailSlowTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new DelimiterBasedFrameDecoder(1, true, 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 = releaseLater((ByteBuf) ch.readInbound()); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); } }
Example #6
Source File: LengthFieldBasedFrameDecoderTest.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
@Test public void testFailFastTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4)); for (int i = 0; i < 2; i ++) { try { assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 }))); fail(DecoderException.class.getSimpleName() + " must be raised."); } catch (TooLongFrameException e) { // Expected } ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' })); ByteBuf buf = releaseLater((ByteBuf) ch.readInbound()); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); buf.release(); } }
Example #7
Source File: LengthFieldBasedFrameDecoderTest.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
@Test public void testFailSlowTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4, false)); for (int i = 0; i < 2; i ++) { assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 }))); try { assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 }))); fail(DecoderException.class.getSimpleName() + " must be raised."); } catch (TooLongFrameException e) { // Expected } ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' })); ByteBuf buf = releaseLater((ByteBuf) ch.readInbound()); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); buf.release(); } }
Example #8
Source File: DelimiterBasedFrameDecoderTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testFailSlowTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new DelimiterBasedFrameDecoder(1, true, 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(); } }
Example #9
Source File: DelimiterBasedFrameDecoderTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testFailFastTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new DelimiterBasedFrameDecoder(1, Delimiters.nulDelimiter())); for (int i = 0; i < 2; i ++) { try { assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }))); fail(DecoderException.class.getSimpleName() + " must be raised."); } catch (TooLongFrameException e) { // Expected } ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 'A', 0 })); ByteBuf buf = ch.readInbound(); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); buf.release(); } }
Example #10
Source File: LengthFieldBasedFrameDecoderTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testFailSlowTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4, false)); for (int i = 0; i < 2; i ++) { assertFalse(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 }))); try { assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0 }))); fail(DecoderException.class.getSimpleName() + " must be raised."); } catch (TooLongFrameException e) { // Expected } ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 1, 'A' })); ByteBuf buf = ch.readInbound(); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); buf.release(); } }
Example #11
Source File: LengthFieldBasedFrameDecoderTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void testFailFastTooLongFrameRecovery() throws Exception { EmbeddedChannel ch = new EmbeddedChannel( new LengthFieldBasedFrameDecoder(5, 0, 4, 0, 4)); for (int i = 0; i < 2; i ++) { try { assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 2 }))); fail(DecoderException.class.getSimpleName() + " must be raised."); } catch (TooLongFrameException e) { // Expected } ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 0, 0, 0, 0, 1, 'A' })); ByteBuf buf = ch.readInbound(); assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1)); buf.release(); } }
Example #12
Source File: HttpObjectDecoder.java From servicetalk with Apache License 2.0 | 6 votes |
private static int findCRLF(final ByteBuf buffer, int startIndex, final int maxLineSize) { final int maxToIndex = startIndex + maxLineSize; for (;;) { final int toIndex = min(buffer.writerIndex(), maxToIndex); final int lfIndex = findLF(buffer, startIndex, toIndex); if (lfIndex == -1) { if (toIndex - startIndex == maxLineSize) { throw new IllegalStateException("Could not find CRLF within " + maxLineSize + " bytes"); } return -2; } else if (lfIndex == buffer.readerIndex()) { buffer.skipBytes(1); ++startIndex; } else if (buffer.getByte(lfIndex - 1) == CR) { return lfIndex; } else if (lfIndex != maxToIndex) { throw new IllegalArgumentException("Found LF but no CR before"); } else { throw new TooLongFrameException("An HTTP line is larger than " + maxLineSize + " bytes"); } } }
Example #13
Source File: AbstractPacketDecoder.java From spring-boot-protocol with Apache License 2.0 | 6 votes |
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { if (in.isReadable(4)) { in.markReaderIndex(); int packetSize = in.readUnsignedMediumLE(); if (packetSize > maxPacketSize) { throw new TooLongFrameException("Received a packet of size " + packetSize + " but the maximum packet size is " + maxPacketSize); } int sequenceId = in.readByte(); if (!in.isReadable(packetSize)) { in.resetReaderIndex(); return; } ByteBuf packet = in.readSlice(packetSize); decodePacket(ctx, sequenceId, packet, out); } }
Example #14
Source File: NettyHttpServletHandler.java From cxf with Apache License 2.0 | 6 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { LOG.log(Level.SEVERE, "UNEXPECTED_EXCEPCTION_IN_NETTY_SERVLET_HANDLER", cause); interceptOnRequestFailed(ctx, cause); Channel ch = ctx.channel(); if (cause instanceof IllegalArgumentException) { ch.close(); } else { if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } if (ch.isActive()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } } ctx.close(); }
Example #15
Source File: WordParser.java From NioImapClient with Apache License 2.0 | 6 votes |
@Override public boolean process(byte value) throws Exception { char nextByte = (char) value; if (Character.isWhitespace(nextByte)) { return size == 0; } else { if (size >= maxWordLength) { throw new TooLongFrameException( "Word is larger than " + maxWordLength + " bytes."); } size++; seq.append(nextByte); return true; } }
Example #16
Source File: LineParser.java From NioImapClient with Apache License 2.0 | 6 votes |
@Override public boolean process(byte value) throws Exception { char nextByte = (char) value; if (nextByte == HttpConstants.CR) { return true; } else if (nextByte == HttpConstants.LF) { return false; } else { if (size >= maxLineLength) { throw new TooLongFrameException( "Line is larger than " + maxLineLength + " bytes."); } size++; seq.append(nextByte); return true; } }
Example #17
Source File: WebSocket00FrameDecoder.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private WebSocketFrame decodeBinaryFrame(ChannelHandlerContext ctx, byte type, ByteBuf buffer) { long frameSize = 0; int lengthFieldSize = 0; byte b; do { b = buffer.readByte(); frameSize <<= 7; frameSize |= b & 0x7f; if (frameSize > maxFrameSize) { throw new TooLongFrameException(); } lengthFieldSize++; if (lengthFieldSize > 8) { // Perhaps a malicious peer? throw new TooLongFrameException(); } } while ((b & 0x80) == 0x80); if (type == (byte) 0xFF && frameSize == 0) { receivedClosingHandshake = true; return new CloseWebSocketFrame(); } ByteBuf payload = readBytes(ctx.alloc(), buffer, (int) frameSize); return new BinaryWebSocketFrame(payload); }
Example #18
Source File: BackstopperRiposteFrameworkErrorHandlerListener.java From riposte with Apache License 2.0 | 6 votes |
protected @NotNull ApiError generateTooLongFrameApiError(@NotNull TooLongFrameException ex) { String exMessage = String.valueOf(ex.getMessage()); Integer tooLongFrameMaxSize = extractTooLongFrameMaxSizeFromExceptionMessage(ex); Map<String, Object> maxSizeMetadata = new HashMap<>(); if (tooLongFrameMaxSize != null) { maxSizeMetadata.put("max_length_allowed", tooLongFrameMaxSize); } // If we detect it's complaining about HTTP header size then throw the ApiError that maps to a // 431 HTTP status code. if (exMessage.startsWith("HTTP header is larger than")) { return new ApiErrorWithMetadata( TOO_LONG_FRAME_HEADER_API_ERROR_BASE, maxSizeMetadata ); } // It wasn't complaining about HTTP header size (or we didn't detect it for some reason). Return the // generic "too long line" ApiError that maps to a 400. return new ApiErrorWithMetadata( TOO_LONG_FRAME_LINE_API_ERROR_BASE, maxSizeMetadata ); }
Example #19
Source File: BackstopperRiposteFrameworkErrorHandlerListener.java From riposte with Apache License 2.0 | 6 votes |
private @Nullable Integer extractTooLongFrameMaxSizeFromExceptionMessage(@NotNull TooLongFrameException ex) { String exMessage = ex.getMessage(); if (exMessage == null || !exMessage.endsWith(" bytes.")) { return null; } try { String[] messageWords = exMessage.split(" "); String maxSizeWord = messageWords[messageWords.length - 2]; return Integer.parseInt(maxSizeWord); } catch(Throwable t) { // Couldn't parse it for some reason. logger.debug("Unable to parse max size from TooLongFrameException. ex_message={}", exMessage, t); return null; } }
Example #20
Source File: HttpPipelineHandler.java From styx with Apache License 2.0 | 6 votes |
private static HttpResponseStatus status(Throwable exception) { return EXCEPTION_STATUSES.statusFor(exception) .orElseGet(() -> { if (exception instanceof DecoderException) { Throwable cause = exception.getCause(); if (cause instanceof BadRequestException) { if (cause.getCause() instanceof TooLongFrameException) { return REQUEST_ENTITY_TOO_LARGE; } return BAD_REQUEST; } } else if (exception instanceof TransportLostException) { return BAD_GATEWAY; } return INTERNAL_SERVER_ERROR; }); }
Example #21
Source File: HttpServerOperations.java From reactor-netty with Apache License 2.0 | 6 votes |
static void sendDecodingFailures(ChannelHandlerContext ctx, Throwable t, Object msg) { Throwable cause = t.getCause() != null ? t.getCause() : t; if (log.isDebugEnabled()) { log.debug(format(ctx.channel(), "Decoding failed: " + msg + " : "), cause); } ReferenceCountUtil.release(msg); HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_0, cause instanceof TooLongFrameException ? HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE: HttpResponseStatus.BAD_REQUEST); response.headers() .setInt(HttpHeaderNames.CONTENT_LENGTH, 0) .set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE); ctx.writeAndFlush(response) .addListener(ChannelFutureListener.CLOSE); }
Example #22
Source File: WebSocket00FrameDecoder.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
private WebSocketFrame decodeBinaryFrame(ChannelHandlerContext ctx, byte type, ByteBuf buffer) { long frameSize = 0; int lengthFieldSize = 0; byte b; do { b = buffer.readByte(); frameSize <<= 7; frameSize |= b & 0x7f; if (frameSize > maxFrameSize) { throw new TooLongFrameException(); } lengthFieldSize++; if (lengthFieldSize > 8) { // Perhaps a malicious peer? throw new TooLongFrameException(); } } while ((b & 0x80) == 0x80); if (type == (byte) 0xFF && frameSize == 0) { receivedClosingHandshake = true; return new CloseWebSocketFrame(); } ByteBuf payload = ctx.alloc().buffer((int) frameSize); buffer.readBytes(payload); return new BinaryWebSocketFrame(payload); }
Example #23
Source File: FtdcDecoderTest.java From ftdc with Apache License 2.0 | 6 votes |
@Test(expected = TooLongFrameException.class) public void testTooLongFrameException() { ByteBuf buf = Unpooled.buffer(); buf.writeByte(2); buf.writeByte(3); buf.writeShort(65535); buf.writeByte(1); buf.writeByte(1); buf.writeByte(1); buf.writeZero(65535); EmbeddedChannel channel = new EmbeddedChannel(new FtdcDecoder()); channel.writeInbound(buf); assertTrue(channel.finish()); FtdcProtocol ftdcProtocol = channel.readInbound(); assertEquals(FtdType.FTDTypeCompressed, ftdcProtocol.getType()); assertEquals(22, ftdcProtocol.getBodyLength()); assertEquals(0, ftdcProtocol.getExtLength()); assertNull(channel.readInbound()); channel.finish(); }
Example #24
Source File: WebSocket00FrameDecoder.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
private WebSocketFrame decodeTextFrame(ChannelHandlerContext ctx, ByteBuf buffer) { int ridx = buffer.readerIndex(); int rbytes = actualReadableBytes(); int delimPos = buffer.indexOf(ridx, ridx + rbytes, (byte) 0xFF); if (delimPos == -1) { // Frame delimiter (0xFF) not found if (rbytes > maxFrameSize) { // Frame length exceeded the maximum throw new TooLongFrameException(); } else { // Wait until more data is received return null; } } int frameSize = delimPos - ridx; if (frameSize > maxFrameSize) { throw new TooLongFrameException(); } ByteBuf binaryData = ctx.alloc().buffer(frameSize); buffer.readBytes(binaryData); buffer.skipBytes(1); int ffDelimPos = binaryData.indexOf(binaryData.readerIndex(), binaryData.writerIndex(), (byte) 0xFF); if (ffDelimPos >= 0) { throw new IllegalArgumentException("a text frame should not contain 0xFF."); } return new TextWebSocketFrame(binaryData); }
Example #25
Source File: HttpDataServerHandler.java From tajo with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel ch = ctx.channel(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } LOG.error(cause.getMessage()); ExceptionUtil.printStackTraceIfError(LOG, cause); if (ch.isActive()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
Example #26
Source File: BackstopperRiposteFrameworkErrorHandlerListenerTest.java From riposte with Apache License 2.0 | 5 votes |
@DataProvider(value = { "true", "false" }) @Test public void shouldHandleInvalidHttpRequestExceptionWithNonNullCause(boolean useTooLongFrameExceptionAsCause) { // given Throwable cause = (useTooLongFrameExceptionAsCause) ? new TooLongFrameException("TooLongFrameException occurred") : new RuntimeException("runtime exception"); String expectedCauseMetadataMessage = (useTooLongFrameExceptionAsCause) ? listener.TOO_LONG_FRAME_LINE_METADATA_MESSAGE : "Invalid HTTP request"; String outerExceptionMessage = "message - " + UUID.randomUUID().toString(); ApiError expectedApiErrorBase = (useTooLongFrameExceptionAsCause) ? listener.TOO_LONG_FRAME_LINE_API_ERROR_BASE : testProjectApiErrors.getMalformedRequestApiError(); // when ApiExceptionHandlerListenerResult result = listener.shouldHandleException( new InvalidHttpRequestException(outerExceptionMessage, cause) ); // then assertThat(result.shouldHandleResponse).isTrue(); assertThat(result.errors).isEqualTo(singletonError( new ApiErrorWithMetadata(expectedApiErrorBase, Pair.of("cause", expectedCauseMetadataMessage)) )); assertThat(result.extraDetailsForLogging.get(0).getLeft()).isEqualTo("exception_message"); assertThat(result.extraDetailsForLogging.get(0).getRight()).isEqualTo(outerExceptionMessage); assertThat(result.extraDetailsForLogging.get(1).getLeft()).isEqualTo("exception_cause_details"); assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo(cause.toString()); }
Example #27
Source File: HttpFileServerHandler.java From tajo with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { Channel ch = ctx.channel(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } LOG.error(cause.getMessage(), cause); if (ch.isActive()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
Example #28
Source File: AbstractCommandHandler.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { io.netty.channel.Channel ch = ctx.channel(); if (cause instanceof TooLongFrameException) { LOGGER.error("Corrupted frame recieved from: " + ch.remoteAddress()); return; } if (ch.isActive()) { LOGGER.error("Internal Server Error",cause); } }
Example #29
Source File: HttpCacheClientTest.java From bazel with Apache License 2.0 | 5 votes |
@Test public void uploadResponseTooLarge() throws Exception { ServerChannel server = null; try { server = testServer.start( new SimpleChannelInboundHandler<FullHttpRequest>() { @Override protected void channelRead0( ChannelHandlerContext channelHandlerContext, FullHttpRequest request) { ByteBuf longMessage = channelHandlerContext.alloc().buffer(50000).writerIndex(50000); DefaultFullHttpResponse response = new DefaultFullHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR, longMessage); channelHandlerContext .writeAndFlush(response) .addListener(ChannelFutureListener.CLOSE); } }); Credentials credentials = newCredentials(); HttpCacheClient blobStore = createHttpBlobStore(server, /* timeoutSeconds= */ 1, credentials); ByteString data = ByteString.copyFrom("File Contents", Charsets.US_ASCII); IOException e = assertThrows( IOException.class, () -> getFromFuture( blobStore.uploadBlob(DIGEST_UTIL.compute(data.toByteArray()), data))); assertThat(e.getCause()).isInstanceOf(TooLongFrameException.class); } finally { testServer.stop(server); } }
Example #30
Source File: AtomOrStringParser.java From NioImapClient with Apache License 2.0 | 5 votes |
private void append(AppendableCharSequence seq, ByteBuf buffer, int length) { if (size + length >= maxStringLength) { throw new TooLongFrameException("String is larger than " + maxStringLength + " bytes."); } size += length; seq.append(buffer.readCharSequence(length - 1, StandardCharsets.UTF_8)); }