Change the return type of EmbeddedChannel.read*() from Object to an ad-hoc type parameter

.. so that there's no need to explicitly down-cast.

Fixes #2067
This commit is contained in:
Trustin Lee 2013-12-16 22:22:47 +09:00
parent 61ed9476ae
commit 94d6e44bba
34 changed files with 132 additions and 134 deletions

View File

@ -206,7 +206,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
// Clean-up the previous encoder if not cleaned up correctly.
if (decoder.finish()) {
for (;;) {
ByteBuf buf = (ByteBuf) decoder.readOutbound();
ByteBuf buf = decoder.readOutbound();
if (buf == null) {
break;
}
@ -234,7 +234,7 @@ public abstract class HttpContentDecoder extends MessageToMessageDecoder<HttpObj
private void fetchDecoderOutput(List<Object> out) {
for (;;) {
ByteBuf buf = (ByteBuf) decoder.readInbound();
ByteBuf buf = decoder.readInbound();
if (buf == null) {
break;
}

View File

@ -247,7 +247,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
// Clean-up the previous encoder if not cleaned up correctly.
if (encoder.finish()) {
for (;;) {
ByteBuf buf = (ByteBuf) encoder.readOutbound();
ByteBuf buf = encoder.readOutbound();
if (buf == null) {
break;
}
@ -275,7 +275,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
private void fetchEncoderOutput(List<Object> out) {
for (;;) {
ByteBuf buf = (ByteBuf) encoder.readOutbound();
ByteBuf buf = encoder.readOutbound();
if (buf == null) {
break;
}

View File

@ -70,7 +70,7 @@ public class HttpContentCompressorTest {
ch.writeOutbound(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK));
HttpResponse res = (HttpResponse) ch.readOutbound();
HttpResponse res = ch.readOutbound();
assertThat(res, is(not(instanceOf(FullHttpResponse.class))));
assertThat(res.headers().get(Names.TRANSFER_ENCODING), is("chunked"));
assertThat(res.headers().get(Names.CONTENT_LENGTH), is(nullValue()));
@ -79,12 +79,12 @@ public class HttpContentCompressorTest {
ch.writeOutbound(LastHttpContent.EMPTY_LAST_CONTENT);
HttpContent chunk;
chunk = (HttpContent) ch.readOutbound();
chunk = ch.readOutbound();
assertThat(chunk, is(instanceOf(HttpContent.class)));
assertThat(chunk.content().isReadable(), is(true));
chunk.release();
chunk = (HttpContent) ch.readOutbound();
chunk = ch.readOutbound();
assertThat(chunk, is(instanceOf(LastHttpContent.class)));
assertThat(chunk.content().isReadable(), is(false));
chunk.release();

View File

@ -35,7 +35,7 @@ public class HttpInvalidMessageTest {
public void testRequestWithBadInitialLine() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder());
ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8));
HttpRequest req = (HttpRequest) ch.readInbound();
HttpRequest req = ch.readInbound();
DecoderResult dr = req.getDecoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
@ -50,7 +50,7 @@ public class HttpInvalidMessageTest {
ch.writeInbound(Unpooled.copiedBuffer("Good_Name: Good Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8));
HttpRequest req = (HttpRequest) ch.readInbound();
HttpRequest req = ch.readInbound();
DecoderResult dr = req.getDecoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
@ -63,7 +63,7 @@ public class HttpInvalidMessageTest {
public void testResponseWithBadInitialLine() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
DecoderResult dr = res.getDecoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
@ -78,7 +78,7 @@ public class HttpInvalidMessageTest {
ch.writeInbound(Unpooled.copiedBuffer("Good_Name: Good Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
DecoderResult dr = res.getDecoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
@ -94,10 +94,10 @@ public class HttpInvalidMessageTest {
ch.writeInbound(Unpooled.copiedBuffer("Transfer-Encoding: chunked\r\n\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("BAD_LENGTH\r\n", CharsetUtil.UTF_8));
HttpRequest req = (HttpRequest) ch.readInbound();
HttpRequest req = ch.readInbound();
assertTrue(req.getDecoderResult().isSuccess());
HttpContent chunk = (HttpContent) ch.readInbound();
HttpContent chunk = ch.readInbound();
DecoderResult dr = chunk.getDecoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());

View File

@ -27,7 +27,7 @@ import org.junit.Test;
import java.util.List;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static io.netty.util.ReferenceCountUtil.*;
import static org.junit.Assert.*;
public class HttpObjectAggregatorTest {
@ -50,7 +50,7 @@ public class HttpObjectAggregatorTest {
// this should trigger a channelRead event so return true
assertTrue(embedder.writeInbound(chunk3));
assertTrue(embedder.finish());
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
FullHttpRequest aggratedMessage = embedder.readInbound();
assertNotNull(aggratedMessage);
assertEquals(chunk1.content().readableBytes() + chunk2.content().readableBytes(),
@ -92,7 +92,7 @@ public class HttpObjectAggregatorTest {
// this should trigger a channelRead event so return true
assertTrue(embedder.writeInbound(trailer));
assertTrue(embedder.finish());
DefaultFullHttpRequest aggratedMessage = (DefaultFullHttpRequest) embedder.readInbound();
FullHttpRequest aggratedMessage = embedder.readInbound();
assertNotNull(aggratedMessage);
assertEquals(chunk1.content().readableBytes() + chunk2.content().readableBytes(),
@ -177,7 +177,7 @@ public class HttpObjectAggregatorTest {
// this should trigger a channelRead event so return true
assertTrue(embedder.writeInbound(chunk3));
assertTrue(embedder.finish());
FullHttpRequest aggratedMessage = (FullHttpRequest) embedder.readInbound();
FullHttpRequest aggratedMessage = embedder.readInbound();
assertNotNull(aggratedMessage);
assertEquals(chunk1.content().readableBytes() + chunk2.content().readableBytes(),

View File

@ -19,7 +19,6 @@ package io.netty.handler.codec.http;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Test;
@ -70,10 +69,10 @@ public class HttpRequestDecoderTest {
private static void testDecodeWholeRequestAtOnce(byte[] content) {
EmbeddedChannel channel = new EmbeddedChannel(new HttpRequestDecoder());
Assert.assertTrue(channel.writeInbound(Unpooled.wrappedBuffer(content)));
HttpRequest req = (HttpRequest) channel.readInbound();
HttpRequest req = channel.readInbound();
Assert.assertNotNull(req);
checkHeaders(req.headers());
LastHttpContent c = (LastHttpContent) channel.readInbound();
LastHttpContent c = channel.readInbound();
Assert.assertEquals(8, c.content().readableBytes());
Assert.assertEquals(Unpooled.wrappedBuffer(content, content.length - 8, 8), c.content().readBytes(8));
c.release();
@ -142,11 +141,11 @@ public class HttpRequestDecoderTest {
channel.writeInbound(Unpooled.wrappedBuffer(content, content.length - i, 1));
}
HttpRequest req = (HttpRequest) channel.readInbound();
HttpRequest req = channel.readInbound();
Assert.assertNotNull(req);
checkHeaders(req.headers());
LastHttpContent c = (LastHttpContent) channel.readInbound();
LastHttpContent c = channel.readInbound();
Assert.assertEquals(8, c.content().readableBytes());
for (int i = 8; i > 1; i--) {
Assert.assertEquals(content[content.length - i], c.content().readByte());
@ -165,7 +164,7 @@ public class HttpRequestDecoderTest {
"Host: localhost" + crlf +
"EmptyHeader:" + crlf + crlf;
channel.writeInbound(Unpooled.wrappedBuffer(request.getBytes(CharsetUtil.US_ASCII)));
HttpRequest req = (HttpRequest) channel.readInbound();
HttpRequest req = channel.readInbound();
Assert.assertEquals("", req.headers().get("EmptyHeader"));
}
}

View File

@ -24,7 +24,6 @@ import java.util.List;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
public class HttpResponseDecoderTest {
@ -117,14 +116,14 @@ public class HttpResponseDecoderTest {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n\r\n", CharsetUtil.US_ASCII));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
assertThat(ch.readInbound(), is(nullValue()));
assertThat(ch.finish(), is(true));
LastHttpContent content = (LastHttpContent) ch.readInbound();
LastHttpContent content = ch.readInbound();
assertThat(content.content().isReadable(), is(false));
content.release();
@ -136,19 +135,19 @@ public class HttpResponseDecoderTest {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n\r\n", CharsetUtil.US_ASCII));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
assertThat(ch.readInbound(), is(nullValue()));
ch.writeInbound(Unpooled.wrappedBuffer(new byte[1024]));
HttpContent content = (HttpContent) ch.readInbound();
HttpContent content = ch.readInbound();
assertThat(content.content().readableBytes(), is(1024));
content.release();
assertThat(ch.finish(), is(true));
LastHttpContent lastContent = (LastHttpContent) ch.readInbound();
LastHttpContent lastContent = ch.readInbound();
assertThat(lastContent.content().isReadable(), is(false));
lastContent.release();
@ -162,20 +161,20 @@ public class HttpResponseDecoderTest {
"HTTP/1.1 200 OK\r\nX-Header: h2=h2v2; Expires=Wed, 09-Jun-2021 10:18:14 GMT \r\n\r\n",
CharsetUtil.US_ASCII));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
assertThat(res.headers().get("X-Header"), is("h2=h2v2; Expires=Wed, 09-Jun-2021 10:18:14 GMT"));
assertThat(ch.readInbound(), is(nullValue()));
ch.writeInbound(Unpooled.wrappedBuffer(new byte[1024]));
HttpContent content = (HttpContent) ch.readInbound();
HttpContent content = ch.readInbound();
assertThat(content.content().readableBytes(), is(1024));
content.release();
assertThat(ch.finish(), is(true));
LastHttpContent lastContent = (LastHttpContent) ch.readInbound();
LastHttpContent lastContent = ch.readInbound();
assertThat(lastContent.content().isReadable(), is(false));
lastContent.release();
@ -195,11 +194,11 @@ public class HttpResponseDecoderTest {
"\r\n",
CharsetUtil.US_ASCII));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
LastHttpContent lastContent = (LastHttpContent) ch.readInbound();
LastHttpContent lastContent = ch.readInbound();
assertThat(lastContent.content().isReadable(), is(false));
HttpHeaders headers = lastContent.trailingHeaders();
assertEquals(1, headers.names().size());
@ -245,11 +244,11 @@ public class HttpResponseDecoderTest {
}
ch.writeInbound(Unpooled.wrappedBuffer(content, headerLength, content.length - headerLength));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
LastHttpContent lastContent = (LastHttpContent) ch.readInbound();
LastHttpContent lastContent = ch.readInbound();
assertThat(lastContent.content().isReadable(), is(false));
HttpHeaders headers = lastContent.trailingHeaders();
assertEquals(1, headers.names().size());
@ -278,11 +277,11 @@ public class HttpResponseDecoderTest {
ch.writeInbound(Unpooled.wrappedBuffer(data, 0, data.length / 2));
ch.writeInbound(Unpooled.wrappedBuffer(data, 5, data.length / 2));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
LastHttpContent content = (LastHttpContent) ch.readInbound();
LastHttpContent content = ch.readInbound();
assertEquals(10, content.content().readableBytes());
assertEquals(Unpooled.wrappedBuffer(data), content.content());
content.release();
@ -321,11 +320,11 @@ public class HttpResponseDecoderTest {
ch.writeInbound(Unpooled.wrappedBuffer(data, 0, data.length / 2));
ch.writeInbound(Unpooled.wrappedBuffer(data, 5, data.length / 2));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.OK));
LastHttpContent lastContent = (LastHttpContent) ch.readInbound();
LastHttpContent lastContent = ch.readInbound();
assertEquals(10, lastContent.content().readableBytes());
assertEquals(Unpooled.wrappedBuffer(data), lastContent.content());
lastContent.release();
@ -346,10 +345,10 @@ public class HttpResponseDecoderTest {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.wrappedBuffer(data));
HttpResponse res = (HttpResponse) ch.readInbound();
HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
HttpContent content = (HttpContent) ch.readInbound();
HttpContent content = ch.readInbound();
assertThat(content.content().readableBytes(), is(16));
content.release();

View File

@ -47,13 +47,13 @@ public class HttpServerCodecTest {
decoderEmbedder.writeInbound(prepareDataChunk(offeredContentLength));
decoderEmbedder.finish();
HttpMessage httpMessage = (HttpMessage) decoderEmbedder.readInbound();
HttpMessage httpMessage = decoderEmbedder.readInbound();
assertNotNull(httpMessage);
boolean empty = true;
int totalBytesPolled = 0;
for (;;) {
HttpContent httpChunk = (HttpContent) decoderEmbedder.readInbound();
HttpContent httpChunk = decoderEmbedder.readInbound();
if (httpChunk == null) {
break;
}
@ -80,7 +80,7 @@ public class HttpServerCodecTest {
assertThat(ch.readInbound(), is(nullValue()));
// Ensure the aggregator writes a 100 Continue response.
ByteBuf continueResponse = (ByteBuf) ch.readOutbound();
ByteBuf continueResponse = ch.readOutbound();
assertThat(continueResponse.toString(CharsetUtil.UTF_8), is("HTTP/1.1 100 Continue\r\n\r\n"));
continueResponse.release();
@ -91,7 +91,7 @@ public class HttpServerCodecTest {
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 42 }));
// Ensure the aggregator generates a full request.
FullHttpRequest req = (FullHttpRequest) ch.readInbound();
FullHttpRequest req = ch.readInbound();
assertThat(req.headers().get(CONTENT_LENGTH), is("1"));
assertThat(req.content().readableBytes(), is(1));
assertThat(req.content().readByte(), is((byte) 42));
@ -107,7 +107,7 @@ public class HttpServerCodecTest {
ch.writeOutbound(res);
// Ensure the encoder handles the response after handling 100 Continue.
ByteBuf encodedRes = (ByteBuf) ch.readOutbound();
ByteBuf encodedRes = ch.readOutbound();
assertThat(encodedRes.toString(CharsetUtil.UTF_8), is("HTTP/1.1 201 Created\r\nContent-Length: 2\r\n\r\nOK"));
encodedRes.release();

View File

@ -47,25 +47,25 @@ public class WebSocketFrameAggregatorTest {
Assert.assertTrue(channel.finish());
BinaryWebSocketFrame frame = (BinaryWebSocketFrame) channel.readInbound();
BinaryWebSocketFrame frame = channel.readInbound();
Assert.assertTrue(frame.isFinalFragment());
Assert.assertEquals(1, frame.rsv());
Assert.assertEquals(content1, frame.content());
frame.release();
PingWebSocketFrame frame2 = (PingWebSocketFrame) channel.readInbound();
PingWebSocketFrame frame2 = channel.readInbound();
Assert.assertTrue(frame2.isFinalFragment());
Assert.assertEquals(0, frame2.rsv());
Assert.assertEquals(content1, frame2.content());
frame2.release();
PongWebSocketFrame frame3 = (PongWebSocketFrame) channel.readInbound();
PongWebSocketFrame frame3 = channel.readInbound();
Assert.assertTrue(frame3.isFinalFragment());
Assert.assertEquals(0, frame3.rsv());
Assert.assertEquals(content1, frame3.content());
frame3.release();
BinaryWebSocketFrame frame4 = (BinaryWebSocketFrame) channel.readInbound();
BinaryWebSocketFrame frame4 = channel.readInbound();
Assert.assertTrue(frame4.isFinalFragment());
Assert.assertEquals(0, frame4.rsv());
Assert.assertEquals(aggregatedContent, frame4.content());
@ -86,25 +86,25 @@ public class WebSocketFrameAggregatorTest {
Assert.assertTrue(channel.finish());
TextWebSocketFrame frame = (TextWebSocketFrame) channel.readInbound();
TextWebSocketFrame frame = channel.readInbound();
Assert.assertTrue(frame.isFinalFragment());
Assert.assertEquals(1, frame.rsv());
Assert.assertEquals(content1, frame.content());
frame.release();
PingWebSocketFrame frame2 = (PingWebSocketFrame) channel.readInbound();
PingWebSocketFrame frame2 = channel.readInbound();
Assert.assertTrue(frame2.isFinalFragment());
Assert.assertEquals(0, frame2.rsv());
Assert.assertEquals(content1, frame2.content());
frame2.release();
PongWebSocketFrame frame3 = (PongWebSocketFrame) channel.readInbound();
PongWebSocketFrame frame3 = channel.readInbound();
Assert.assertTrue(frame3.isFinalFragment());
Assert.assertEquals(0, frame3.rsv());
Assert.assertEquals(content1, frame3.content());
frame3.release();
TextWebSocketFrame frame4 = (TextWebSocketFrame) channel.readInbound();
TextWebSocketFrame frame4 = channel.readInbound();
Assert.assertTrue(frame4.isFinalFragment());
Assert.assertEquals(0, frame4.rsv());
Assert.assertEquals(aggregatedContent, frame4.content());

View File

@ -58,11 +58,11 @@ public class WebSocketServerHandshaker00Test {
EmbeddedChannel ch2 = new EmbeddedChannel(new HttpResponseDecoder());
ch2.writeInbound(ch.readOutbound());
HttpResponse res = (HttpResponse) ch2.readInbound();
HttpResponse res = ch2.readInbound();
Assert.assertEquals("ws://example.com/chat", res.headers().get(Names.SEC_WEBSOCKET_LOCATION));
Assert.assertEquals("chat", res.headers().get(Names.SEC_WEBSOCKET_PROTOCOL));
LastHttpContent content = (LastHttpContent) ch2.readInbound();
LastHttpContent content = ch2.readInbound();
Assert.assertEquals("8jKS'y:G*Co,Wxa-", content.content().toString(CharsetUtil.US_ASCII));
content.release();

View File

@ -53,11 +53,11 @@ public class WebSocketServerHandshaker08Test {
new WebSocketServerHandshaker08(
"ws://example.com/chat", "chat", false, Integer.MAX_VALUE).handshake(ch, req);
ByteBuf resBuf = (ByteBuf) ch.readOutbound();
ByteBuf resBuf = ch.readOutbound();
EmbeddedChannel ch2 = new EmbeddedChannel(new HttpResponseDecoder());
ch2.writeInbound(resBuf);
HttpResponse res = (HttpResponse) ch2.readInbound();
HttpResponse res = ch2.readInbound();
Assert.assertEquals(
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.headers().get(Names.SEC_WEBSOCKET_ACCEPT));

View File

@ -53,11 +53,11 @@ public class WebSocketServerHandshaker13Test {
new WebSocketServerHandshaker13(
"ws://example.com/chat", "chat", false, Integer.MAX_VALUE).handshake(ch, req);
ByteBuf resBuf = (ByteBuf) ch.readOutbound();
ByteBuf resBuf = ch.readOutbound();
EmbeddedChannel ch2 = new EmbeddedChannel(new HttpResponseDecoder());
ch2.writeInbound(resBuf);
HttpResponse res = (HttpResponse) ch2.readInbound();
HttpResponse res = ch2.readInbound();
Assert.assertEquals(
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.headers().get(Names.SEC_WEBSOCKET_ACCEPT));

View File

@ -87,7 +87,7 @@ public class BinaryMemcacheDecoderTest {
incoming.writeBytes(GET_REQUEST);
channel.writeInbound(incoming);
BinaryMemcacheRequest request = (BinaryMemcacheRequest) channel.readInbound();
BinaryMemcacheRequest request = channel.readInbound();
assertThat(request, notNullValue());
assertThat(request.getHeader(), notNullValue());
@ -115,7 +115,7 @@ public class BinaryMemcacheDecoderTest {
incoming.writeBytes(SET_REQUEST_WITH_CONTENT);
channel.writeInbound(incoming);
BinaryMemcacheRequest request = (BinaryMemcacheRequest) channel.readInbound();
BinaryMemcacheRequest request = channel.readInbound();
assertThat(request, notNullValue());
assertThat(request.getHeader(), notNullValue());
@ -131,7 +131,7 @@ public class BinaryMemcacheDecoderTest {
int expectedContentChunks = 4;
for (int i = 1; i <= expectedContentChunks; i++) {
MemcacheContent content = (MemcacheContent) channel.readInbound();
MemcacheContent content = channel.readInbound();
if (i < expectedContentChunks) {
assertThat(content, instanceOf(MemcacheContent.class));
} else {
@ -154,7 +154,7 @@ public class BinaryMemcacheDecoderTest {
channel.writeInbound(incoming.readBytes(5));
}
BinaryMemcacheRequest request = (BinaryMemcacheRequest) channel.readInbound();
BinaryMemcacheRequest request = channel.readInbound();
assertThat(request, notNullValue());
assertThat(request.getHeader(), notNullValue());
@ -163,8 +163,8 @@ public class BinaryMemcacheDecoderTest {
request.release();
MemcacheContent content1 = (MemcacheContent) channel.readInbound();
MemcacheContent content2 = (MemcacheContent) channel.readInbound();
MemcacheContent content1 = channel.readInbound();
MemcacheContent content2 = channel.readInbound();
assertThat(content1, instanceOf(MemcacheContent.class));
assertThat(content2, instanceOf(LastMemcacheContent.class));
@ -184,7 +184,7 @@ public class BinaryMemcacheDecoderTest {
public void shouldHandleTwoMessagesInOneBatch() {
channel.writeInbound(Unpooled.buffer().writeBytes(GET_REQUEST).writeBytes(GET_REQUEST));
BinaryMemcacheRequest request = (BinaryMemcacheRequest) channel.readInbound();
BinaryMemcacheRequest request = channel.readInbound();
assertThat(request, instanceOf(BinaryMemcacheRequest.class));
assertThat(request, notNullValue());
request.release();
@ -193,7 +193,7 @@ public class BinaryMemcacheDecoderTest {
assertThat(lastContent, instanceOf(LastMemcacheContent.class));
((ReferenceCounted) lastContent).release();
request = (BinaryMemcacheRequest) channel.readInbound();
request = channel.readInbound();
assertThat(request, instanceOf(BinaryMemcacheRequest.class));
assertThat(request, notNullValue());
request.release();
@ -212,43 +212,43 @@ public class BinaryMemcacheDecoderTest {
channel.writeInbound(Unpooled.buffer().writeBytes(GET_RESPONSE_CHUNK_2));
// First message
BinaryMemcacheResponse response = (BinaryMemcacheResponse) channel.readInbound();
BinaryMemcacheResponse response = channel.readInbound();
assertThat(response.getHeader().getStatus(), is(BinaryMemcacheResponseStatus.KEY_ENOENT));
assertThat(response.getHeader().getTotalBodyLength(), is(msgBody.length()));
response.release();
// First message first content chunk
MemcacheContent content = (MemcacheContent) channel.readInbound();
MemcacheContent content = channel.readInbound();
assertThat(content, instanceOf(LastMemcacheContent.class));
assertThat(content.content().toString(CharsetUtil.UTF_8), is(msgBody));
content.release();
// Second message
response = (BinaryMemcacheResponse) channel.readInbound();
response = channel.readInbound();
assertThat(response.getHeader().getStatus(), is(BinaryMemcacheResponseStatus.KEY_ENOENT));
assertThat(response.getHeader().getTotalBodyLength(), is(msgBody.length()));
response.release();
// Second message first content chunk
content = (MemcacheContent) channel.readInbound();
content = channel.readInbound();
assertThat(content, instanceOf(MemcacheContent.class));
assertThat(content.content().toString(CharsetUtil.UTF_8), is(msgBody.substring(0, 7)));
content.release();
// Second message second content chunk
content = (MemcacheContent) channel.readInbound();
content = channel.readInbound();
assertThat(content, instanceOf(LastMemcacheContent.class));
assertThat(content.content().toString(CharsetUtil.UTF_8), is(msgBody.substring(7, 9)));
content.release();
// Third message
response = (BinaryMemcacheResponse) channel.readInbound();
response = channel.readInbound();
assertThat(response.getHeader().getStatus(), is(BinaryMemcacheResponseStatus.KEY_ENOENT));
assertThat(response.getHeader().getTotalBodyLength(), is(msgBody.length()));
response.release();
// Third message first content chunk
content = (MemcacheContent) channel.readInbound();
content = channel.readInbound();
assertThat(content, instanceOf(LastMemcacheContent.class));
assertThat(content.content().toString(CharsetUtil.UTF_8), is(msgBody));
content.release();

View File

@ -57,7 +57,7 @@ public class BinaryMemcacheEncoderTest {
boolean result = channel.writeOutbound(request);
assertThat(result, is(true));
ByteBuf written = (ByteBuf) channel.readOutbound();
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
assertThat(written.readByte(), is((byte) 0x80));
assertThat(written.readByte(), is((byte) 0x00));
@ -74,7 +74,7 @@ public class BinaryMemcacheEncoderTest {
boolean result = channel.writeOutbound(request);
assertThat(result, is(true));
ByteBuf written = (ByteBuf) channel.readOutbound();
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
assertThat(written.readByte(), is((byte) 0xAA));
assertThat(written.readByte(), is(BinaryMemcacheOpcodes.GET));
@ -93,7 +93,7 @@ public class BinaryMemcacheEncoderTest {
boolean result = channel.writeOutbound(request);
assertThat(result, is(true));
ByteBuf written = (ByteBuf) channel.readOutbound();
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE + extrasLength));
written.readBytes(DEFAULT_HEADER_SIZE);
assertThat(written.readBytes(extrasLength).toString(CharsetUtil.UTF_8), equalTo(extrasContent));
@ -111,7 +111,7 @@ public class BinaryMemcacheEncoderTest {
boolean result = channel.writeOutbound(request);
assertThat(result, is(true));
ByteBuf written = (ByteBuf) channel.readOutbound();
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE + keyLength));
written.readBytes(DEFAULT_HEADER_SIZE);
assertThat(written.readBytes(keyLength).toString(CharsetUtil.UTF_8), equalTo(key));
@ -137,9 +137,9 @@ public class BinaryMemcacheEncoderTest {
result = channel.writeOutbound(content2);
assertThat(result, is(true));
ByteBuf written = (ByteBuf) channel.readOutbound();
ByteBuf written = channel.readOutbound();
assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
written = (ByteBuf) channel.readOutbound();
written = channel.readOutbound();
assertThat(written.readableBytes(), is(content1.content().readableBytes()));
assertThat(
written.readBytes(content1.content().readableBytes()).toString(CharsetUtil.UTF_8),
@ -147,7 +147,7 @@ public class BinaryMemcacheEncoderTest {
);
written.release();
written = (ByteBuf) channel.readOutbound();
written = channel.readOutbound();
assertThat(written.readableBytes(), is(content2.content().readableBytes()));
assertThat(
written.readBytes(content2.content().readableBytes()).toString(CharsetUtil.UTF_8),

View File

@ -57,7 +57,7 @@ public class BinaryMemcacheObjectAggregatorTest {
incoming.writeBytes(SET_REQUEST_WITH_CONTENT);
channel.writeInbound(incoming);
FullBinaryMemcacheRequest request = (FullBinaryMemcacheRequest) channel.readInbound();
FullBinaryMemcacheRequest request = channel.readInbound();
assertThat(request, instanceOf(FullBinaryMemcacheRequest.class));
assertThat(request, notNullValue());

View File

@ -30,7 +30,7 @@ public class SocksAuthRequestDecoderTest {
SocksAuthRequestDecoder decoder = new SocksAuthRequestDecoder();
EmbeddedChannel embedder = new EmbeddedChannel(decoder);
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
msg = (SocksAuthRequest) embedder.readInbound();
msg = embedder.readInbound();
assertEquals(msg.username(), username);
assertEquals(msg.username(), password);
assertNull(embedder.readInbound());

View File

@ -31,7 +31,7 @@ public class SocksAuthResponseDecoderTest {
SocksAuthResponseDecoder decoder = new SocksAuthResponseDecoder();
EmbeddedChannel embedder = new EmbeddedChannel(decoder);
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
msg = (SocksAuthResponse) embedder.readInbound();
msg = embedder.readInbound();
assertSame(msg.authStatus(), authStatus);
assertNull(embedder.readInbound());
}

View File

@ -39,7 +39,7 @@ public class SocksCmdRequestDecoderTest {
if (msg.addressType() == SocksAddressType.UNKNOWN) {
assertTrue(embedder.readInbound() instanceof UnknownSocksRequest);
} else {
msg = (SocksCmdRequest) embedder.readInbound();
msg = embedder.readInbound();
assertSame(msg.cmdType(), cmdType);
assertSame(msg.addressType(), addressType);
assertEquals(msg.host(), host);

View File

@ -35,7 +35,7 @@ public class SocksCmdResponseDecoderTest {
if (addressType == SocksAddressType.UNKNOWN) {
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
} else {
msg = (SocksResponse) embedder.readInbound();
msg = embedder.readInbound();
assertEquals(((SocksCmdResponse) msg).cmdStatus(), cmdStatus);
}
assertNull(embedder.readInbound());

View File

@ -42,7 +42,7 @@ public class ByteToMessageDecoderTest {
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] {'a', 'b', 'c'});
channel.writeInbound(buf.copy());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
Assert.assertEquals(b, buf.skipBytes(1));
b.release();
buf.release();
@ -67,7 +67,7 @@ public class ByteToMessageDecoderTest {
});
channel.writeInbound(buf.copy());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
Assert.assertEquals(b, Unpooled.wrappedBuffer(new byte[] { 'b', 'c'}));
buf.release();
b.release();

View File

@ -21,7 +21,7 @@ import io.netty.channel.embedded.EmbeddedChannel;
import org.junit.Assert;
import org.junit.Test;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static io.netty.util.ReferenceCountUtil.*;
public class LengthFieldBasedFrameDecoderTest {
@ -43,7 +43,7 @@ public class LengthFieldBasedFrameDecoderTest {
}
Assert.assertTrue(channel.finish());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
Assert.assertEquals(5, b.readableBytes());
Assert.assertEquals(1, b.readInt());
Assert.assertEquals('a', b.readByte());
@ -73,7 +73,7 @@ public class LengthFieldBasedFrameDecoderTest {
Assert.assertTrue(channel.finish());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
Assert.assertEquals(5, b.readableBytes());
Assert.assertEquals(1, b.readInt());
Assert.assertEquals('a', b.readByte());

View File

@ -24,7 +24,7 @@ import org.junit.Test;
import java.util.List;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static io.netty.util.ReferenceCountUtil.*;
import static org.junit.Assert.*;
public class ReplayingDecoderTest {
@ -122,7 +122,7 @@ public class ReplayingDecoderTest {
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] {'a', 'b', 'c'});
channel.writeInbound(buf.copy());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
assertEquals(b, buf.skipBytes(1));
b.release();
buf.release();
@ -146,7 +146,7 @@ public class ReplayingDecoderTest {
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] {'a', 'b', 'c'});
channel.writeInbound(buf.copy());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
assertEquals("Expect to have still all bytes in the buffer", b, buf);
b.release();
@ -172,7 +172,7 @@ public class ReplayingDecoderTest {
});
channel.writeInbound(buf.copy());
ByteBuf b = (ByteBuf) channel.readInbound();
ByteBuf b = channel.readInbound();
assertEquals(b, Unpooled.wrappedBuffer(new byte[] { 'b', 'c'}));
b.release();
buf.release();

View File

@ -16,7 +16,6 @@
package io.netty.handler.codec.bytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.internal.EmptyArrays;
import org.junit.Before;
@ -49,7 +48,7 @@ public class ByteArrayEncoderTest {
@Test
public void testEncodeEmpty() {
ch.writeOutbound(EmptyArrays.EMPTY_BYTES);
assertThat((ByteBuf) ch.readOutbound(), is(Unpooled.EMPTY_BUFFER));
assertThat((ByteBuf) ch.readOutbound(), is(EMPTY_BUFFER));
}
@Test

View File

@ -22,7 +22,7 @@ import io.netty.channel.embedded.EmbeddedChannel;
import org.junit.Before;
import org.junit.Test;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static io.netty.util.ReferenceCountUtil.*;
import static org.junit.Assert.*;
public class SnappyFramedEncoderTest {
@ -90,7 +90,7 @@ public class SnappyFramedEncoderTest {
CompositeByteBuf actual = Unpooled.compositeBuffer();
for (;;) {
ByteBuf m = (ByteBuf) channel.readOutbound();
ByteBuf m = channel.readOutbound();
if (m == null) {
break;
}
@ -145,7 +145,7 @@ public class SnappyFramedEncoderTest {
channel.writeOutbound(in);
assertTrue(channel.finish());
ByteBuf out = (ByteBuf) channel.readOutbound();
ByteBuf out = channel.readOutbound();
out.release();
}
}

View File

@ -122,7 +122,7 @@ public class SnappyIntegrationTest {
EmbeddedChannel decoder = new EmbeddedChannel(new SnappyFramedDecoder());
try {
encoder.writeOutbound(in.copy());
ByteBuf compressed = (ByteBuf) encoder.readOutbound();
ByteBuf compressed = encoder.readOutbound();
assertThat(compressed, is(notNullValue()));
assertThat(compressed, is(not(in)));
decoder.writeInbound(compressed.retain());

View File

@ -50,7 +50,7 @@ public abstract class ZlibTest {
EmbeddedChannel chDecoderGZip = new EmbeddedChannel(createDecoder(ZlibWrapper.GZIP));
chDecoderGZip.writeInbound(deflatedData.copy());
assertTrue(chDecoderGZip.finish());
ByteBuf buf = (ByteBuf) chDecoderGZip.readInbound();
ByteBuf buf = chDecoderGZip.readInbound();
assertEquals(buf, data);
assertNull(chDecoderGZip.readInbound());
data.release();
@ -67,7 +67,7 @@ public abstract class ZlibTest {
EmbeddedChannel chDecoderZlib = new EmbeddedChannel(createDecoder(decoderWrapper));
for (;;) {
ByteBuf deflatedData = (ByteBuf) chEncoder.readOutbound();
ByteBuf deflatedData = chEncoder.readOutbound();
if (deflatedData == null) {
break;
}
@ -77,7 +77,7 @@ public abstract class ZlibTest {
byte[] decompressed = new byte[bytes.length];
int offset = 0;
for (;;) {
ByteBuf buf = (ByteBuf) chDecoderZlib.readInbound();
ByteBuf buf = chDecoderZlib.readInbound();
if (buf == null) {
break;
}
@ -115,7 +115,7 @@ public abstract class ZlibTest {
EmbeddedChannel chDecoderZlib = new EmbeddedChannel(createDecoder(decoderWrapper));
for (;;) {
ByteBuf deflatedData = (ByteBuf) chEncoder.readOutbound();
ByteBuf deflatedData = chEncoder.readOutbound();
if (deflatedData == null) {
break;
}
@ -124,7 +124,7 @@ public abstract class ZlibTest {
// Decoder should not generate anything at all.
for (;;) {
ByteBuf buf = (ByteBuf) chDecoderZlib.readInbound();
ByteBuf buf = chDecoderZlib.readInbound();
if (buf == null) {
break;
}

View File

@ -39,12 +39,12 @@ public class LengthFieldPrependerTest {
public void testPrependLength() throws Exception {
final EmbeddedChannel ch = new EmbeddedChannel(new LengthFieldPrepender(4));
ch.writeOutbound(msg);
ByteBuf buf = (ByteBuf) ch.readOutbound();
ByteBuf buf = ch.readOutbound();
assertEquals(4, buf.readableBytes());
assertEquals(msg.readableBytes(), buf.readInt());
buf.release();
buf = (ByteBuf) ch.readOutbound();
buf = ch.readOutbound();
assertSame(buf, msg);
buf.release();
}
@ -53,12 +53,12 @@ public class LengthFieldPrependerTest {
public void testPrependLengthIncludesLengthFieldLength() throws Exception {
final EmbeddedChannel ch = new EmbeddedChannel(new LengthFieldPrepender(4, true));
ch.writeOutbound(msg);
ByteBuf buf = (ByteBuf) ch.readOutbound();
ByteBuf buf = ch.readOutbound();
assertEquals(4, buf.readableBytes());
assertEquals(5, buf.readInt());
buf.release();
buf = (ByteBuf) ch.readOutbound();
buf = ch.readOutbound();
assertSame(buf, msg);
buf.release();
}
@ -67,12 +67,12 @@ public class LengthFieldPrependerTest {
public void testPrependAdjustedLength() throws Exception {
final EmbeddedChannel ch = new EmbeddedChannel(new LengthFieldPrepender(4, -1));
ch.writeOutbound(msg);
ByteBuf buf = (ByteBuf) ch.readOutbound();
ByteBuf buf = ch.readOutbound();
assertEquals(4, buf.readableBytes());
assertEquals(msg.readableBytes() - 1, buf.readInt());
buf.release();
buf = (ByteBuf) ch.readOutbound();
buf = ch.readOutbound();
assertSame(buf, msg);
buf.release();
}

View File

@ -53,7 +53,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
ch.writeInbound(input(testBytes));
assertTrue(ch.finish());
String unmarshalled = (String) ch.readInbound();
String unmarshalled = ch.readInbound();
assertEquals(testObject, unmarshalled);
@ -87,7 +87,7 @@ public abstract class AbstractCompatibleMarshallingDecoderTest {
ch.writeInbound(buffer);
assertTrue(ch.finish());
String unmarshalled = (String) ch.readInbound();
String unmarshalled = ch.readInbound();
assertEquals(testObject, unmarshalled);

View File

@ -24,14 +24,12 @@ import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.Unmarshaller;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.*;
public abstract class AbstractCompatibleMarshallingEncoderTest {
@Test
public void testMarshalling() throws IOException, ClassNotFoundException {
public void testMarshalling() throws Exception {
@SuppressWarnings("RedundantStringConstructorCall")
String testObject = new String("test");
@ -43,7 +41,7 @@ public abstract class AbstractCompatibleMarshallingEncoderTest {
ch.writeOutbound(testObject);
assertTrue(ch.finish());
ByteBuf buffer = (ByteBuf) ch.readOutbound();
ByteBuf buffer = ch.readOutbound();
Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
unmarshaller.start(Marshalling.createByteInput(truncate(buffer).nioBuffer()));

View File

@ -29,7 +29,7 @@ public class StringEncoderTest {
EmbeddedChannel channel = new EmbeddedChannel(new StringEncoder());
Assert.assertTrue(channel.writeOutbound(msg));
Assert.assertTrue(channel.finish());
ByteBuf buf = (ByteBuf) channel.readOutbound();
ByteBuf buf = channel.readOutbound();
byte[] data = new byte[buf.readableBytes()];
buf.readBytes(data);
Assert.assertArrayEquals(msg.getBytes(CharsetUtil.UTF_8), data);

View File

@ -150,7 +150,7 @@ public class XmlFrameDecoderTest {
}
List<Object> actual = new ArrayList<Object>();
for (;;) {
ByteBuf buf = (ByteBuf) ch.readInbound();
ByteBuf buf = ch.readInbound();
if (buf == null) {
break;
}

View File

@ -210,7 +210,7 @@ public class LoggingHandlerTest {
channel.writeInbound(msg);
verify(appender);
String handledMsg = (String) channel.readInbound();
String handledMsg = channel.readInbound();
assertThat(msg, is(sameInstance(handledMsg)));
assertThat(channel.readInbound(), is(nullValue()));
}
@ -224,7 +224,7 @@ public class LoggingHandlerTest {
channel.writeInbound(msg);
verify(appender);
ByteBuf handledMsg = (ByteBuf) channel.readInbound();
ByteBuf handledMsg = channel.readInbound();
assertThat(msg, is(sameInstance(handledMsg)));
handledMsg.release();
assertThat(channel.readInbound(), is(nullValue()));
@ -239,7 +239,7 @@ public class LoggingHandlerTest {
channel.writeInbound(msg);
verify(appender);
ByteBuf handledMsg = (ByteBuf) channel.readInbound();
ByteBuf handledMsg = channel.readInbound();
assertThat(msg, is(sameInstance(handledMsg)));
assertThat(channel.readInbound(), is(nullValue()));
}
@ -259,7 +259,7 @@ public class LoggingHandlerTest {
channel.writeInbound(msg);
verify(appender);
ByteBufHolder handledMsg = (ByteBufHolder) channel.readInbound();
ByteBufHolder handledMsg = channel.readInbound();
assertThat(msg, is(sameInstance(handledMsg)));
handledMsg.release();
assertThat(channel.readInbound(), is(nullValue()));
@ -279,12 +279,12 @@ public class LoggingHandlerTest {
/**
* A custom EasyMock matcher that matches on Logback messages.
*/
private static class RegexLogMatcher implements IArgumentMatcher {
private static final class RegexLogMatcher implements IArgumentMatcher {
private final String expected;
private String actualMsg;
public RegexLogMatcher(String expected) {
RegexLogMatcher(String expected) {
this.expected = expected;
}

View File

@ -23,6 +23,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.CharsetUtil;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
@ -30,7 +31,7 @@ import java.io.IOException;
import java.nio.channels.Channels;
import java.util.concurrent.atomic.AtomicBoolean;
import static io.netty.util.ReferenceCountUtil.releaseLater;
import static io.netty.util.ReferenceCountUtil.*;
import static org.junit.Assert.*;
public class ChunkedWriteHandlerTest {
@ -193,7 +194,7 @@ public class ChunkedWriteHandlerTest {
int i = 0;
int read = 0;
for (;;) {
ByteBuf buffer = (ByteBuf) ch.readOutbound();
ByteBuf buffer = ch.readOutbound();
if (buffer == null) {
break;
}

View File

@ -147,15 +147,17 @@ public class EmbeddedChannel extends AbstractChannel {
/**
* Return received data from this {@link Channel}
*/
public Object readInbound() {
return inboundMessages.poll();
@SuppressWarnings("unchecked")
public <T> T readInbound() {
return (T) inboundMessages.poll();
}
/**
* Read data froum the outbound. This may return {@code null} if nothing is readable.
*/
public Object readOutbound() {
return outboundMessages.poll();
@SuppressWarnings("unchecked")
public <T> T readOutbound() {
return (T) outboundMessages.poll();
}
/**