io.netty.util.Signal Java Examples
The following examples show how to use
io.netty.util.Signal.
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: ReplayingDecoder.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Override final void channelInputClosed(ChannelHandlerContext ctx, List<Object> out) throws Exception { try { replayable.terminate(); if (cumulation != null) { callDecode(ctx, internalBuffer(), out); decodeLast(ctx, replayable, out); } else { replayable.setCumulation(Unpooled.EMPTY_BUFFER); decodeLast(ctx, replayable, out); } } catch (Signal replay) { // Ignore replay.expect(REPLAY); } }
Example #2
Source File: ReplayingDecoderByteBufTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetUnsignedByte() { ByteBuf buf = Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1); ReplayingDecoderByteBuf buffer = new ReplayingDecoderByteBuf(buf); boolean error; int i = 0; try { for (;;) { buffer.getUnsignedByte(i); i++; } } catch (Signal e) { error = true; } assertTrue(error); assertEquals(10, i); buf.release(); }
Example #3
Source File: ReplayingDecoderByteBufTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetByte() { ByteBuf buf = Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1); ReplayingDecoderByteBuf buffer = new ReplayingDecoderByteBuf(buf); boolean error; int i = 0; try { for (;;) { buffer.getByte(i); i++; } } catch (Signal e) { error = true; } assertTrue(error); assertEquals(10, i); buf.release(); }
Example #4
Source File: ReplayingDecoderBufferTest.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
/** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetUnsignedByte() { ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(releaseLater(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1))); boolean error; int i = 0; try { for (;;) { buffer.getUnsignedByte(i); i++; } } catch (Signal e) { error = true; } assertTrue(error); assertEquals(10, i); }
Example #5
Source File: ReplayingDecoderBufferTest.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
/** * See https://github.com/netty/netty/issues/445 */ @Test public void testGetByte() { ReplayingDecoderBuffer buffer = new ReplayingDecoderBuffer(releaseLater(Unpooled.copiedBuffer("TestBuffer", CharsetUtil.ISO_8859_1))); boolean error; int i = 0; try { for (;;) { buffer.getByte(i); i++; } } catch (Signal e) { error = true; } assertTrue(error); assertEquals(10, i); }
Example #6
Source File: DefaultPromiseTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Test public void signalUncancellableCompletionValue() { final Promise<Signal> promise = new DefaultPromise<Signal>(ImmediateEventExecutor.INSTANCE); promise.setSuccess(Signal.valueOf(DefaultPromise.class, "UNCANCELLABLE")); assertTrue(promise.isDone()); assertTrue(promise.isSuccess()); }
Example #7
Source File: DefaultPromiseTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Test public void signalSuccessCompletionValue() { final Promise<Signal> promise = new DefaultPromise<Signal>(ImmediateEventExecutor.INSTANCE); promise.setSuccess(Signal.valueOf(DefaultPromise.class, "SUCCESS")); assertTrue(promise.isDone()); assertTrue(promise.isSuccess()); }
Example #8
Source File: AllBytesParser.java From NioImapClient with Apache License 2.0 | 5 votes |
@Override public String parse(ByteBuf buffer) { AppendableCharSequence sequence = sequenceReference.get(); int readerIndex = buffer.readerIndex(); try { super.parse(buffer); } catch (Signal e) { e.expect(REPLAYING_SIGNAL); buffer.readerIndex(readerIndex + size); return sequence.toString(); } return sequence.toString(); }
Example #9
Source File: BufferedBodyParser.java From NioImapClient with Apache License 2.0 | 4 votes |
@Override public Optional<byte[]> parse(ByteBuf in) { for (;;) { switch (state) { case START: char c = ((char) in.readUnsignedByte()); if (c == '{') { in.readerIndex(in.readerIndex() - 1); expectedSize = sizeParser.parse(in); state = State.SKIP_CRLF; return Optional.empty(); } else if (Character.isWhitespace(c)) { continue; } else { in.readerIndex(in.readerIndex() - 1); state = State.PARSE_STRING; continue; } case SKIP_CRLF: in.readBytes(2); state = State.PARSE_SIZE; continue; case PARSE_STRING: return Optional.of(stringParser.parse(in).getBytes(StandardCharsets.UTF_8)); case PARSE_SIZE: if (buf == null) { buf = PooledByteBufAllocator.DEFAULT.buffer(expectedSize); } pos = in.readerIndex(); try { while (size < expectedSize) { buf.writeByte((char) in.readUnsignedByte()); inc(); } } catch (Signal e) { e.expect(REPLAYING_SIGNAL); in.readerIndex(pos); return Optional.empty(); } byte[] result = new byte[buf.readableBytes()]; buf.getBytes(buf.readerIndex(), result); reset(); return Optional.of(result); } } }