Another round of the new API design

- Channel now creates a ChannelPipeline by itself

  I find no reason to allow a user to use one's own pipeline
  implementation since I saw nobody does except for the cases where a
  user wants to add a user attribute to a channel, which is now covered
  by AttributeMap.

- Removed ChannelEvent and its subtypes because they are replaced by
  direct method invocation.
- Replaced ChannelSink with Channel.unsafe()
- Various getter renaming (e.g. Channel.getId() -> Channel.id())
- Added ChannelHandlerInvoker interface
- Implemented AbstractChannel and AbstractServerChannel
- Some other changes I don't remember
This commit is contained in:
Trustin Lee 2012-05-01 17:19:41 +09:00
parent 0f42719e9b
commit 368156f5d0
162 changed files with 1415 additions and 3267 deletions

View File

@ -91,7 +91,7 @@ public class HttpChunkAggregator extends SimpleChannelUpstreamHandler {
// No need to notify the upstream handlers - just log.
// If decoding a response, just throw an exception.
if (is100ContinueExpected(m)) {
write(ctx, succeededFuture(ctx.getChannel()), CONTINUE.duplicate());
write(ctx, succeededFuture(ctx.channel()), CONTINUE.duplicate());
}
if (m.isChunked()) {
@ -103,7 +103,7 @@ public class HttpChunkAggregator extends SimpleChannelUpstreamHandler {
m.removeHeader(HttpHeaders.Names.TRANSFER_ENCODING);
}
m.setChunked(false);
m.setContent(ChannelBuffers.dynamicBuffer(e.getChannel().getConfig().getBufferFactory()));
m.setContent(ChannelBuffers.dynamicBuffer(e.channel().getConfig().getBufferFactory()));
this.currentMessage = m;
} else {
// Not a chunked message - pass through.

View File

@ -154,7 +154,7 @@ public abstract class HttpContentEncoder extends SimpleChannelHandler {
// the last product on closure,
if (lastProduct.readable()) {
Channels.write(
ctx, Channels.succeededFuture(e.getChannel()), new DefaultHttpChunk(lastProduct), e.getRemoteAddress());
ctx, Channels.succeededFuture(e.channel()), new DefaultHttpChunk(lastProduct), e.getRemoteAddress());
}
// Emit the last chunk.

View File

@ -170,7 +170,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
}
// Write HEADERS frame and append Data Frame
ChannelFuture future = Channels.future(e.getChannel());
ChannelFuture future = Channels.future(e.channel());
future.addListener(new SpdyFrameWriter(ctx, e, spdyDataFrame));
Channels.write(ctx, future, spdyHeadersFrame, e.getRemoteAddress());
}
@ -195,7 +195,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
spdyDataFrame.setLast(true);
// Create new future and add listener
ChannelFuture future = Channels.future(e.getChannel());
ChannelFuture future = Channels.future(e.channel());
future.addListener(new SpdyFrameWriter(ctx, e, spdyDataFrame));
return future;
@ -219,7 +219,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
} else if (future.isCancelled()) {
e.getFuture().cancel();
} else {
e.getFuture().setFailure(future.getCause());
e.getFuture().setFailure(future.cause());
}
}
}

View File

@ -140,7 +140,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
// Stream-IDs must be monotonically increassing
if (streamID < lastGoodStreamID) {
issueSessionError(ctx, e.getChannel(), e.getRemoteAddress());
issueSessionError(ctx, e.channel(), e.getRemoteAddress());
return;
}
@ -219,7 +219,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
if (isRemoteInitiatedID(spdyPingFrame.getID())) {
Channels.write(ctx, Channels.future(e.getChannel()), spdyPingFrame, e.getRemoteAddress());
Channels.write(ctx, Channels.future(e.channel()), spdyPingFrame, e.getRemoteAddress());
return;
}
@ -371,7 +371,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
removeStream(streamID);
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamID, status);
Channels.write(ctx, Channels.future(e.getChannel()), spdyRstStreamFrame, e.getRemoteAddress());
Channels.write(ctx, Channels.future(e.channel()), spdyRstStreamFrame, e.getRemoteAddress());
}
/*
@ -447,16 +447,16 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
private void sendGoAwayFrame(ChannelHandlerContext ctx, ChannelStateEvent e) {
// Avoid NotYetConnectedException
if (!e.getChannel().isConnected()) {
if (!e.channel().isConnected()) {
ctx.sendDownstream(e);
return;
}
ChannelFuture future = sendGoAwayFrame(ctx, e.getChannel(), null);
ChannelFuture future = sendGoAwayFrame(ctx, e.channel(), null);
if (spdySession.noActiveStreams()) {
future.addListener(new ClosingChannelFutureListener(ctx, e));
} else {
closeSessionFuture = Channels.future(e.getChannel());
closeSessionFuture = Channels.future(e.channel());
closeSessionFuture.addListener(new ClosingChannelFutureListener(ctx, e));
}
}
@ -483,7 +483,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
}
public void operationComplete(ChannelFuture sentGoAwayFuture) throws Exception {
if (!(sentGoAwayFuture.getCause() instanceof ClosedChannelException)) {
if (!(sentGoAwayFuture.cause() instanceof ClosedChannelException)) {
Channels.close(ctx, e.getFuture());
} else {
e.getFuture().setSuccess();

View File

@ -169,7 +169,7 @@ public abstract class AbstractSocketSpdyEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(InetAddress.getLocalHost(), port));
assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
cc.write(frames);
while (ch.counter < frames.writerIndex() - ignoredBytes) {
@ -219,7 +219,7 @@ public abstract class AbstractSocketSpdyEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -244,8 +244,8 @@ public abstract class AbstractSocketSpdyEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -281,18 +281,18 @@ public class SpdySessionHandlerTest {
SpdySynStreamFrame spdySynStreamFrame =
new DefaultSpdySynStreamFrame(streamID, 0, (byte) 0);
spdySynStreamFrame.setLast(true);
Channels.write(e.getChannel(), spdySynStreamFrame);
Channels.write(e.channel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
Channels.write(e.channel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
Channels.write(e.channel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
Channels.write(e.channel(), spdySynStreamFrame);
// Limit the number of concurrent streams to 3
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 3);
Channels.write(e.getChannel(), spdySettingsFrame);
Channels.write(e.channel(), spdySettingsFrame);
}
@Override
@ -303,7 +303,7 @@ public class SpdySessionHandlerTest {
(msg instanceof SpdyPingFrame) ||
(msg instanceof SpdyHeadersFrame)) {
Channels.write(e.getChannel(), msg, e.getRemoteAddress());
Channels.write(e.channel(), msg, e.getRemoteAddress());
return;
}
@ -318,7 +318,7 @@ public class SpdySessionHandlerTest {
spdySynReplyFrame.addHeader(entry.getKey(), entry.getValue());
}
Channels.write(e.getChannel(), spdySynReplyFrame, e.getRemoteAddress());
Channels.write(e.channel(), spdySynReplyFrame, e.getRemoteAddress());
return;
}
@ -326,7 +326,7 @@ public class SpdySessionHandlerTest {
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
if (spdySettingsFrame.isSet(closeSignal)) {
Channels.close(e.getChannel());
Channels.close(e.channel());
}
}
}

View File

@ -112,7 +112,7 @@ public class ZlibDecoder extends OneToOneDecoder {
byte[] out = new byte[in.length << 1];
ChannelBuffer decompressed = ChannelBuffers.dynamicBuffer(
compressed.order(), out.length,
ctx.getChannel().getConfig().getBufferFactory());
ctx.channel().getConfig().getBufferFactory());
z.next_out = out;
z.next_out_index = 0;
z.avail_out = out.length;

View File

@ -288,7 +288,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
}
if (z.next_out_index != 0) {
result = ctx.getChannel().getConfig().getBufferFactory().getBuffer(
result = ctx.channel().getConfig().getBufferFactory().getBuffer(
uncompressed.order(), out, 0, z.next_out_index);
} else {
result = ChannelBuffers.EMPTY_BUFFER;
@ -330,7 +330,7 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
if (evt != null) {
ctx.sendDownstream(evt);
}
return Channels.succeededFuture(ctx.getChannel());
return Channels.succeededFuture(ctx.channel());
}
ChannelBuffer footer;
@ -352,19 +352,19 @@ public class ZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChanne
int resultCode = z.deflate(JZlib.Z_FINISH);
if (resultCode != JZlib.Z_OK && resultCode != JZlib.Z_STREAM_END) {
future = Channels.failedFuture(
ctx.getChannel(),
ctx.channel(),
ZlibUtil.exception(z, "compression failure", resultCode));
footer = null;
} else if (z.next_out_index != 0) {
future = Channels.future(ctx.getChannel());
future = Channels.future(ctx.channel());
footer =
ctx.getChannel().getConfig().getBufferFactory().getBuffer(
ctx.channel().getConfig().getBufferFactory().getBuffer(
out, 0, z.next_out_index);
} else {
// Note that we should never use a SucceededChannelFuture
// here just in case any downstream handler or a sink wants
// to notify a write error.
future = Channels.future(ctx.getChannel());
future = Channels.future(ctx.channel());
footer = ChannelBuffers.EMPTY_BUFFER;
}
} finally {

View File

@ -209,7 +209,7 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
boolean offered = productQueue.offer(((MessageEvent) e).getMessage());
assert offered;
} else if (e instanceof ExceptionEvent) {
throw new CodecEmbedderException(((ExceptionEvent) e).getCause());
throw new CodecEmbedderException(((ExceptionEvent) e).cause());
}
// Swallow otherwise.
@ -231,9 +231,9 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
public ChannelFuture execute(ChannelPipeline pipeline, Runnable task) {
try {
task.run();
return Channels.succeededFuture(pipeline.getChannel());
return Channels.succeededFuture(pipeline.channel());
} catch (Throwable t) {
return Channels.failedFuture(pipeline.getChannel(), t);
return Channels.failedFuture(pipeline.channel(), t);
}
}
}

View File

@ -257,13 +257,13 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
private void fail(ChannelHandlerContext ctx, long frameLength) {
if (frameLength > 0) {
Channels.fireExceptionCaught(
ctx.getChannel(),
ctx.channel(),
new TooLongFrameException(
"frame length exceeds " + maxFrameLength +
": " + frameLength + " - discarded"));
} else {
Channels.fireExceptionCaught(
ctx.getChannel(),
ctx.channel(),
new TooLongFrameException(
"frame length exceeds " + maxFrameLength +
" - discarding"));

View File

@ -76,10 +76,10 @@ public class FixedLengthFrameDecoder extends FrameDecoder {
@Override
protected ChannelBuffer newCumulationBuffer(ChannelHandlerContext ctx, int minimumCapacity) {
ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
ChannelBufferFactory factory = ctx.channel().getConfig().getBufferFactory();
if (allocateFullBuffer) {
return ChannelBuffers.dynamicBuffer(
factory.getDefaultOrder(), frameLength, ctx.getChannel().getConfig().getBufferFactory());
factory.getDefaultOrder(), frameLength, ctx.channel().getConfig().getBufferFactory());
}
return super.newCumulationBuffer(ctx, minimumCapacity);
}

View File

@ -204,7 +204,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
if (cumulation == null) {
// the cumulation buffer is not created yet so just pass the input to callDecode(...) method
callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
callDecode(ctx, e.channel(), input, e.getRemoteAddress());
if (input.readable()) {
// seems like there is something readable left in the input buffer. So create the cumulation buffer and copy the input into it
(this.cumulation = newCumulationBuffer(ctx, input.readableBytes())).writeBytes(input);
@ -216,7 +216,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
cumulation.discardReadBytes();
}
cumulation.writeBytes(input);
callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
callDecode(ctx, e.channel(), cumulation, e.getRemoteAddress());
if (!cumulation.readable()) {
this.cumulation = null;
}
@ -333,13 +333,13 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
if (cumulation.readable()) {
// Make sure all frames are read before notifying a closed channel.
callDecode(ctx, ctx.getChannel(), cumulation, null);
callDecode(ctx, ctx.channel(), cumulation, null);
}
// Call decodeLast() finally. Please note that decodeLast() is
// called even if there's nothing more to read from the buffer to
// notify a user that the connection was closed explicitly.
Object partialFrame = decodeLast(ctx, ctx.getChannel(), cumulation);
Object partialFrame = decodeLast(ctx, ctx.channel(), cumulation);
if (partialFrame != null) {
unfoldAndFireMessageReceived(ctx, null, partialFrame);
}
@ -359,7 +359,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler {
*/
protected ChannelBuffer newCumulationBuffer(
ChannelHandlerContext ctx, int minimumCapacity) {
ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
ChannelBufferFactory factory = ctx.channel().getConfig().getBufferFactory();
return ChannelBuffers.dynamicBuffer(
factory.getDefaultOrder(), Math.max(minimumCapacity, 256), factory);
}

View File

@ -439,13 +439,13 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
private void fail(ChannelHandlerContext ctx, long frameLength) {
if (frameLength > 0) {
Channels.fireExceptionCaught(
ctx.getChannel(),
ctx.channel(),
new TooLongFrameException(
"Adjusted frame length exceeds " + maxFrameLength +
": " + frameLength + " - discarded"));
} else {
Channels.fireExceptionCaught(
ctx.getChannel(),
ctx.channel(),
new TooLongFrameException(
"Adjusted frame length exceeds " + maxFrameLength +
" - discarding"));

View File

@ -63,7 +63,7 @@ public abstract class OneToOneDecoder implements ChannelUpstreamHandler {
MessageEvent e = (MessageEvent) evt;
Object originalMessage = e.getMessage();
Object decodedMessage = decode(ctx, e.getChannel(), originalMessage);
Object decodedMessage = decode(ctx, e.channel(), originalMessage);
if (originalMessage == decodedMessage) {
ctx.sendUpstream(evt);
} else if (decodedMessage != null) {

View File

@ -57,7 +57,7 @@ public abstract class OneToOneEncoder implements ChannelDownstreamHandler {
MessageEvent e = (MessageEvent) evt;
Object originalMessage = e.getMessage();
Object encodedMessage = encode(ctx, e.getChannel(), originalMessage);
Object encodedMessage = encode(ctx, e.channel(), originalMessage);
if (originalMessage == encodedMessage) {
ctx.sendDownstream(evt);
} else if (encodedMessage != null) {

View File

@ -438,7 +438,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
int oldReaderIndex = input.readerIndex();
int inputSize = input.readableBytes();
callDecode(
ctx, e.getChannel(),
ctx, e.channel(),
input, replayable,
e.getRemoteAddress());
@ -475,7 +475,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
cumulation.discardReadBytes();
}
cumulation.writeBytes(input);
callDecode(ctx, e.getChannel(), cumulation, replayable, e.getRemoteAddress());
callDecode(ctx, e.channel(), cumulation, replayable, e.getRemoteAddress());
if (!cumulation.readable()) {
this.cumulation = null;
replayable = ReplayingDecoderBuffer.EMPTY_BUFFER;
@ -579,13 +579,13 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
if (cumulation != null && cumulation.readable()) {
// Make sure all data was read before notifying a closed channel.
callDecode(ctx, e.getChannel(), cumulation, replayable, null);
callDecode(ctx, e.channel(), cumulation, replayable, null);
}
// Call decodeLast() finally. Please note that decodeLast() is
// called even if there's nothing more to read from the buffer to
// notify a user that the connection was closed explicitly.
Object partiallyDecoded = decodeLast(ctx, e.getChannel(), replayable, state);
Object partiallyDecoded = decodeLast(ctx, e.channel(), replayable, state);
if (partiallyDecoded != null) {
unfoldAndFireMessageReceived(ctx, partiallyDecoded, null);
}
@ -608,7 +608,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
*/
protected ChannelBuffer newCumulationBuffer(
ChannelHandlerContext ctx, int minimumCapacity) {
ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
ChannelBufferFactory factory = ctx.channel().getConfig().getBufferFactory();
return ChannelBuffers.dynamicBuffer(
factory.getDefaultOrder(), Math.max(minimumCapacity, 256), factory);
}

View File

@ -99,7 +99,7 @@ public class CompatibleObjectEncoder extends OneToOneEncoder {
private ChannelBuffer buffer(ChannelHandlerContext ctx) throws Exception {
ChannelBuffer buf = buffer.get();
if (buf == null) {
ChannelBufferFactory factory = ctx.getChannel().getConfig().getBufferFactory();
ChannelBufferFactory factory = ctx.channel().getConfig().getBufferFactory();
buf = ChannelBuffers.dynamicBuffer(factory);
if (buffer.compareAndSet(null, buf)) {
boolean success = false;

View File

@ -73,7 +73,7 @@ public class ObjectEncoder extends OneToOneEncoder {
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
ChannelBufferOutputStream bout =
new ChannelBufferOutputStream(dynamicBuffer(
estimatedLength, ctx.getChannel().getConfig().getBufferFactory()));
estimatedLength, ctx.channel().getConfig().getBufferFactory()));
bout.write(LENGTH_PLACEHOLDER);
ObjectOutputStream oout = new CompactObjectOutputStream(bout);
oout.writeObject(msg);

View File

@ -58,7 +58,7 @@ public class DiscardClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is closed or the connection attempt fails.
future.getChannel().getCloseFuture().awaitUninterruptibly();
future.channel().getCloseFuture().awaitUninterruptibly();
// Shut down thread pools to exit.
bootstrap.releaseExternalResources();

View File

@ -93,8 +93,8 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
private void generateTraffic(ChannelStateEvent e) {
@ -102,7 +102,7 @@ public class DiscardClientHandler extends SimpleChannelUpstreamHandler {
// A channel becomes unwritable when its internal buffer is full.
// If you keep writing messages ignoring this property,
// you will end up with an OutOfMemoryError.
Channel channel = e.getChannel();
Channel channel = e.channel();
while (channel.isWritable()) {
ChannelBuffer m = nextMessage();
if (m == null) {

View File

@ -62,7 +62,7 @@ public class DiscardServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -61,7 +61,7 @@ public class EchoClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is closed or the connection attempt fails.
future.getChannel().getCloseFuture().awaitUninterruptibly();
future.channel().getCloseFuture().awaitUninterruptibly();
// Shut down thread pools to exit.
bootstrap.releaseExternalResources();

View File

@ -63,7 +63,7 @@ public class EchoClientHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, ChannelStateEvent e) {
// Send the first message. Server will not send anything here
// because the firstMessage's capacity is 0.
e.getChannel().write(firstMessage);
e.channel().write(firstMessage);
}
@Override
@ -71,7 +71,7 @@ public class EchoClientHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, MessageEvent e) {
// Send back the received message to the remote peer.
transferredBytes.addAndGet(((ChannelBuffer) e.getMessage()).readableBytes());
e.getChannel().write(e.getMessage());
e.channel().write(e.getMessage());
}
@Override
@ -81,7 +81,7 @@ public class EchoClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -44,7 +44,7 @@ public class EchoServerHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, MessageEvent e) {
// Send back the received message to the remote peer.
transferredBytes.addAndGet(((ChannelBuffer) e.getMessage()).readableBytes());
e.getChannel().write(e.getMessage());
e.channel().write(e.getMessage());
}
@Override
@ -54,7 +54,7 @@ public class EchoServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -53,11 +53,11 @@ public class FactorialClient {
bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is made successfully.
Channel channel = connectFuture.awaitUninterruptibly().getChannel();
Channel channel = connectFuture.awaitUninterruptibly().channel();
// Get the handler instance to retrieve the answer.
FactorialClientHandler handler =
(FactorialClientHandler) channel.getPipeline().getLast();
(FactorialClientHandler) channel.getPipeline().last();
// Print out the answer.
System.err.format(

View File

@ -93,7 +93,7 @@ public class FactorialClientHandler extends SimpleChannelUpstreamHandler {
receivedMessages ++;
if (receivedMessages == count) {
// Offer the answer after closing the connection.
e.getChannel().close().addListener(new ChannelFutureListener() {
e.channel().close().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
boolean offered = answer.offer((BigInteger) e.getMessage());
@ -109,12 +109,12 @@ public class FactorialClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
private void sendNumbers(ChannelStateEvent e) {
Channel channel = e.getChannel();
Channel channel = e.channel();
while (channel.isWritable()) {
if (i <= count) {
channel.write(Integer.valueOf(i));

View File

@ -65,7 +65,7 @@ public class FactorialServerHandler extends SimpleChannelUpstreamHandler {
}
lastMultiplier = number.intValue();
factorial = factorial.multiply(number);
e.getChannel().write(factorial);
e.channel().write(factorial);
}
@Override
@ -81,7 +81,7 @@ public class FactorialServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -164,7 +164,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
response.setHeader(CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
}
Channel ch = e.getChannel();
Channel ch = e.channel();
// Write the initial line and the header.
ch.write(response);
@ -203,8 +203,8 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
Channel ch = e.getChannel();
Throwable cause = e.getCause();
Channel ch = e.channel();
Throwable cause = e.cause();
if (cause instanceof TooLongFrameException) {
sendError(ctx, BAD_REQUEST);
return;
@ -251,7 +251,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
CharsetUtil.UTF_8));
// Close the connection as soon as the error message is sent.
ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
ctx.channel().write(response).addListener(ChannelFutureListener.CLOSE);
}
/**
@ -265,7 +265,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
setDateHeader(response);
// Close the connection as soon as the error message is sent.
ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
ctx.channel().write(response).addListener(ChannelFutureListener.CLOSE);
}
/**

View File

@ -73,9 +73,9 @@ public class HttpSnoopClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return;
}

View File

@ -152,7 +152,7 @@ public class HttpSnoopServerHandler extends SimpleChannelUpstreamHandler {
}
// Write the response.
ChannelFuture future = e.getChannel().write(response);
ChannelFuture future = e.channel().write(response);
// Close the non-keep-alive connection after the write operation is done.
if (!keepAlive) {
@ -162,13 +162,13 @@ public class HttpSnoopServerHandler extends SimpleChannelUpstreamHandler {
private void send100Continue(MessageEvent e) {
HttpResponse response = new DefaultHttpResponse(HTTP_1_1, CONTINUE);
e.getChannel().write(response);
e.channel().write(response);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
}

View File

@ -154,9 +154,9 @@ public class HttpUploadClient {
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return null;
}
@ -226,9 +226,9 @@ public class HttpUploadClient {
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return null;
}
@ -312,9 +312,9 @@ public class HttpUploadClient {
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return;
}

View File

@ -72,7 +72,7 @@ public class HttpUploadClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
}

View File

@ -157,15 +157,15 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
} catch (ErrorDataDecoderException e1) {
e1.printStackTrace();
responseContent.append(e1.getMessage());
writeResponse(e.getChannel());
Channels.close(e.getChannel());
writeResponse(e.channel());
Channels.close(e.channel());
return;
} catch (IncompatibleDataDecoderException e1) {
// GET Method: should not try to create a HttpPostRequestDecoder
// So OK but stop here
responseContent.append(e1.getMessage());
responseContent.append("\r\n\r\nEND OF GET CONTENT\r\n");
writeResponse(e.getChannel());
writeResponse(e.channel());
return;
}
@ -179,10 +179,10 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
readingChunks = true;
} else {
// Not chunk version
readHttpDataAllReceive(e.getChannel());
readHttpDataAllReceive(e.channel());
responseContent
.append("\r\n\r\nEND OF NOT CHUNKED CONTENT\r\n");
writeResponse(e.getChannel());
writeResponse(e.channel());
}
} else {
// New chunk is received
@ -192,17 +192,17 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
} catch (ErrorDataDecoderException e1) {
e1.printStackTrace();
responseContent.append(e1.getMessage());
writeResponse(e.getChannel());
Channels.close(e.getChannel());
writeResponse(e.channel());
Channels.close(e.channel());
return;
}
responseContent.append("o");
// example of reading chunk by chunk (minimize memory usage due to Factory)
readHttpDataChunkByChunk(e.getChannel());
readHttpDataChunkByChunk(e.channel());
// example of reading only if at the end
if (chunk.isLast()) {
readHttpDataAllReceive(e.getChannel());
writeResponse(e.getChannel());
readHttpDataAllReceive(e.channel());
writeResponse(e.channel());
readingChunks = false;
}
}
@ -474,14 +474,14 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf
.readableBytes()));
// Write the response.
e.getChannel().write(response);
e.channel().write(response);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
e.cause().printStackTrace();
System.err.println(responseContent.toString());
e.getChannel().close();
e.channel().close();
}
}

View File

@ -74,32 +74,32 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
this.getWebSocketLocation(req), null, false);
this.handshaker = wsFactory.newHandshaker(req);
if (this.handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel());
} else {
this.handshaker.handshake(ctx.getChannel(), req);
this.handshaker.handshake(ctx.channel(), req);
}
}
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), frame.getClass()
logger.debug(String.format("Channel %s received %s", ctx.channel().getId(), frame.getClass()
.getSimpleName()));
}
if (frame instanceof CloseWebSocketFrame) {
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
} else if (frame instanceof PingWebSocketFrame) {
ctx.getChannel().write(
ctx.channel().write(
new PongWebSocketFrame(frame.isFinalFragment(), frame.getRsv(), frame.getBinaryData()));
} else if (frame instanceof TextWebSocketFrame) {
// String text = ((TextWebSocketFrame) frame).getText();
ctx.getChannel().write(
ctx.channel().write(
new TextWebSocketFrame(frame.isFinalFragment(), frame.getRsv(), frame.getBinaryData()));
} else if (frame instanceof BinaryWebSocketFrame) {
ctx.getChannel().write(
ctx.channel().write(
new BinaryWebSocketFrame(frame.isFinalFragment(), frame.getRsv(), frame.getBinaryData()));
} else if (frame instanceof ContinuationWebSocketFrame) {
ctx.getChannel().write(
ctx.channel().write(
new ContinuationWebSocketFrame(frame.isFinalFragment(), frame.getRsv(), frame.getBinaryData()));
} else if (frame instanceof PongWebSocketFrame) {
// Ignore
@ -117,7 +117,7 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.getChannel().write(res);
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.getStatus().getCode() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
@ -125,8 +125,8 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
private String getWebSocketLocation(HttpRequest req) {

View File

@ -107,7 +107,7 @@ public class WebSocketClient {
new InetSocketAddress(uri.getHost(), uri.getPort()));
future.awaitUninterruptibly().rethrowIfFailed();
ch = future.getChannel();
ch = future.channel();
handshaker.handshake(ch).awaitUninterruptibly().rethrowIfFailed();
// Send 10 messages and wait for responses

View File

@ -66,7 +66,7 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
Channel ch = ctx.getChannel();
Channel ch = ctx.channel();
if (!handshaker.isHandshakeComplete()) {
handshaker.finishHandshake(ch, (HttpResponse) e.getMessage());
System.out.println("WebSocket Client connected!");
@ -93,8 +93,8 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
final Throwable t = e.getCause();
final Throwable t = e.cause();
t.printStackTrace();
e.getChannel().close();
e.channel().close();
}
}

View File

@ -94,9 +94,9 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
this.getWebSocketLocation(req), null, false);
this.handshaker = wsFactory.newHandshaker(req);
if (this.handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel());
} else {
this.handshaker.handshake(ctx.getChannel(), req);
this.handshaker.handshake(ctx.channel(), req);
}
}
@ -104,10 +104,10 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
// Check for closing frame
if (frame instanceof CloseWebSocketFrame) {
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
return;
} else if (frame instanceof PingWebSocketFrame) {
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
ctx.channel().write(new PongWebSocketFrame(frame.getBinaryData()));
return;
} else if (!(frame instanceof TextWebSocketFrame)) {
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
@ -117,9 +117,9 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
// Send the uppercase string back.
String request = ((TextWebSocketFrame) frame).getText();
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
logger.debug(String.format("Channel %s received %s", ctx.channel().getId(), request));
}
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
ctx.channel().write(new TextWebSocketFrame(request.toUpperCase()));
}
private void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
@ -130,7 +130,7 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.getChannel().write(res);
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.getStatus().getCode() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
@ -138,8 +138,8 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
private String getWebSocketLocation(HttpRequest req) {

View File

@ -94,9 +94,9 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
this.getWebSocketLocation(req), null, false);
this.handshaker = wsFactory.newHandshaker(req);
if (this.handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.getChannel());
wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel());
} else {
this.handshaker.handshake(ctx.getChannel(), req);
this.handshaker.handshake(ctx.channel(), req);
}
}
@ -104,10 +104,10 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
// Check for closing frame
if (frame instanceof CloseWebSocketFrame) {
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
return;
} else if (frame instanceof PingWebSocketFrame) {
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
ctx.channel().write(new PongWebSocketFrame(frame.getBinaryData()));
return;
} else if (!(frame instanceof TextWebSocketFrame)) {
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
@ -117,9 +117,9 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
// Send the uppercase string back.
String request = ((TextWebSocketFrame) frame).getText();
if (logger.isDebugEnabled()) {
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
logger.debug(String.format("Channel %s received %s", ctx.channel().getId(), request));
}
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
ctx.channel().write(new TextWebSocketFrame(request.toUpperCase()));
}
private void sendHttpResponse(ChannelHandlerContext ctx, HttpRequest req, HttpResponse res) {
@ -130,7 +130,7 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
}
// Send the response and close the connection if necessary.
ChannelFuture f = ctx.getChannel().write(res);
ChannelFuture f = ctx.channel().write(res);
if (!isKeepAlive(req) || res.getStatus().getCode() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
@ -138,8 +138,8 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
private String getWebSocketLocation(HttpRequest req) {

View File

@ -86,17 +86,17 @@ public class LocalExample {
}
// Sends the received line to the server.
lastWriteFuture = channelFuture.getChannel().write(line);
lastWriteFuture = channelFuture.channel().write(line);
}
// Wait until all messages are flushed before closing the channel.
if (lastWriteFuture != null) {
lastWriteFuture.awaitUninterruptibly();
}
channelFuture.getChannel().close();
channelFuture.channel().close();
// Wait until the connection is closed or the connection attempt fails.
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
channelFuture.channel().getCloseFuture().awaitUninterruptibly();
// Release all resources used by the local transport.
cb.releaseExternalResources();

View File

@ -74,22 +74,22 @@ public class LocalExampleMultithreaded {
channelFuture.awaitUninterruptibly();
if (! channelFuture.isSuccess()) {
System.err.println("CANNOT CONNECT");
channelFuture.getCause().printStackTrace();
channelFuture.cause().printStackTrace();
break;
}
ChannelFuture lastWriteFuture = null;
for (String line: commands) {
// Sends the received line to the server.
lastWriteFuture = channelFuture.getChannel().write(line);
lastWriteFuture = channelFuture.channel().write(line);
}
// Wait until all messages are flushed before closing the channel.
if (lastWriteFuture != null) {
lastWriteFuture.awaitUninterruptibly();
}
channelFuture.getChannel().close();
channelFuture.channel().close();
// Wait until the connection is closed or the connection attempt fails.
channelFuture.getChannel().getCloseFuture().awaitUninterruptibly();
channelFuture.channel().getCloseFuture().awaitUninterruptibly();
System.err.println("End " + j);
}

View File

@ -58,7 +58,7 @@ public class LocalTimeClient {
bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is made successfully.
Channel channel = connectFuture.awaitUninterruptibly().getChannel();
Channel channel = connectFuture.awaitUninterruptibly().channel();
// Get the handler instance to initiate the request.
LocalTimeClientHandler handler =

View File

@ -102,7 +102,7 @@ public class LocalTimeClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
super.channelOpen(ctx, e);
}
@ -119,7 +119,7 @@ public class LocalTimeClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -73,7 +73,7 @@ public class LocalTimeServerHandler extends SimpleChannelUpstreamHandler {
setSecond(calendar.get(SECOND)).build());
}
e.getChannel().write(builder.build());
e.channel().write(builder.build());
}
@Override
@ -82,8 +82,8 @@ public class LocalTimeServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
private static String toString(Continent c) {

View File

@ -74,7 +74,7 @@ public class ObjectEchoClientHandler extends SimpleChannelUpstreamHandler {
public void channelConnected(
ChannelHandlerContext ctx, ChannelStateEvent e) {
// Send the first message if this handler is a client-side handler.
e.getChannel().write(firstMessage);
e.channel().write(firstMessage);
}
@Override
@ -82,7 +82,7 @@ public class ObjectEchoClientHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, MessageEvent e) {
// Echo back the received object to the client.
transferredMessages.incrementAndGet();
e.getChannel().write(e.getMessage());
e.channel().write(e.getMessage());
}
@Override
@ -91,7 +91,7 @@ public class ObjectEchoClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -57,7 +57,7 @@ public class ObjectEchoServerHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, MessageEvent e) {
// Echo back the received object to the client.
transferredMessages.incrementAndGet();
e.getChannel().write(e.getMessage());
e.channel().write(e.getMessage());
}
@Override
@ -66,7 +66,7 @@ public class ObjectEchoServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -75,7 +75,7 @@ public class PortUnificationServerHandler extends FrameDecoder {
} else {
// Unknown protocol; discard everything and close the connection.
buffer.skipBytes(buffer.readableBytes());
ctx.getChannel().close();
ctx.channel().close();
return null;
}

View File

@ -54,15 +54,15 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
// Suspend incoming traffic until connected to the remote host.
final Channel inboundChannel = e.getChannel();
final Channel inboundChannel = e.channel();
inboundChannel.setReadable(false);
// Start the connection attempt.
ClientBootstrap cb = new ClientBootstrap(cf);
cb.getPipeline().addLast("handler", new OutboundHandler(e.getChannel()));
cb.getPipeline().addLast("handler", new OutboundHandler(e.channel()));
ChannelFuture f = cb.connect(new InetSocketAddress(remoteHost, remotePort));
outboundChannel = f.getChannel();
outboundChannel = f.channel();
f.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
@ -88,7 +88,7 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
// If outboundChannel is saturated, do not read until notified in
// OutboundHandler.channelInterestChanged().
if (!outboundChannel.isWritable()) {
e.getChannel().setReadable(false);
e.channel().setReadable(false);
}
}
}
@ -99,7 +99,7 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
// If inboundChannel is not saturated anymore, continue accepting
// the incoming traffic from the outboundChannel.
synchronized (trafficLock) {
if (e.getChannel().isWritable()) {
if (e.channel().isWritable()) {
outboundChannel.setReadable(true);
}
}
@ -116,8 +116,8 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
closeOnFlush(e.getChannel());
e.cause().printStackTrace();
closeOnFlush(e.channel());
}
private class OutboundHandler extends SimpleChannelUpstreamHandler {
@ -138,7 +138,7 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
// If inboundChannel is saturated, do not read until notified in
// HexDumpProxyInboundHandler.channelInterestChanged().
if (!inboundChannel.isWritable()) {
e.getChannel().setReadable(false);
e.channel().setReadable(false);
}
}
}
@ -149,7 +149,7 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
// If outboundChannel is not saturated anymore, continue accepting
// the incoming traffic from the inboundChannel.
synchronized (trafficLock) {
if (e.getChannel().isWritable()) {
if (e.channel().isWritable()) {
inboundChannel.setReadable(true);
}
}
@ -164,8 +164,8 @@ public class HexDumpProxyInboundHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
closeOnFlush(e.getChannel());
e.cause().printStackTrace();
closeOnFlush(e.channel());
}
}

View File

@ -28,14 +28,14 @@ public class QuoteOfTheMomentClientHandler extends SimpleChannelUpstreamHandler
String msg = (String) e.getMessage();
if (msg.startsWith("QOTM: ")) {
System.out.println("Quote of the Moment: " + msg.substring(6));
e.getChannel().close();
e.channel().close();
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
e.getChannel().close();
e.cause().printStackTrace();
e.channel().close();
}
}

View File

@ -47,14 +47,14 @@ public class QuoteOfTheMomentServerHandler extends SimpleChannelUpstreamHandler
throws Exception {
String msg = (String) e.getMessage();
if (msg.equals("QOTM?")) {
e.getChannel().write("QOTM: " + nextQuote(), e.getRemoteAddress());
e.channel().write("QOTM: " + nextQuote(), e.getRemoteAddress());
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
e.getCause().printStackTrace();
e.cause().printStackTrace();
// We don't close the channel because we can keep serving requests.
}
}

View File

@ -53,7 +53,7 @@ public final class RedisClient {
});
ChannelFuture redis = cb.connect(new InetSocketAddress("localhost", 6379));
redis.await().rethrowIfFailed();
Channel channel = redis.getChannel();
Channel channel = redis.channel();
channel.write(new Command("set", "1", "value"));
System.out.print(blockingReadHandler.read());

View File

@ -66,7 +66,7 @@ public class SctpClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection is closed or the connection attempt fails.
future.getChannel().getCloseFuture().awaitUninterruptibly();
future.channel().getCloseFuture().awaitUninterruptibly();
// Please check SctpClientHandler to see, how echo message is sent & received

View File

@ -47,20 +47,20 @@ public class SctpClientHandler extends SimpleChannelUpstreamHandler {
*/
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent stateEvent) {
stateEvent.getChannel().write(new SctpFrame(0, 0, ChannelBuffers.wrappedBuffer("SCTP ECHO".getBytes())));
stateEvent.channel().write(new SctpFrame(0, 0, ChannelBuffers.wrappedBuffer("SCTP ECHO".getBytes())));
}
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) {
// Send back the received message to the remote peer.
logger.log(Level.INFO, "Received " + counter.incrementAndGet() + "th message from server, sending it back.");
messageEvent.getChannel().write(messageEvent.getMessage());
messageEvent.channel().write(messageEvent.getMessage());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent exceptionEvent) {
// Close the connection when an exception is raised.
logger.log(Level.WARNING, "Unexpected exception from downstream.", exceptionEvent.getCause());
exceptionEvent.getChannel().close();
logger.log(Level.WARNING, "Unexpected exception from downstream.", exceptionEvent.cause());
exceptionEvent.channel().close();
}
}

View File

@ -36,13 +36,13 @@ public class SctpServerHandler extends SimpleChannelUpstreamHandler {
public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) {
// Send back the received message to the remote peer.
logger.log(Level.INFO, "Received " + counter.incrementAndGet() + "th message from client, sending it back.");
messageEvent.getChannel().write(messageEvent.getMessage());
messageEvent.channel().write(messageEvent.getMessage());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
// Close the connection when an exception is raised.
logger.log(Level.WARNING, "Unexpected exception from downstream.", event.getCause());
event.getChannel().close();
logger.log(Level.WARNING, "Unexpected exception from downstream.", event.cause());
event.channel().close();
}
}

View File

@ -53,9 +53,9 @@ public class SecureChatClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return;
}

View File

@ -66,7 +66,7 @@ public class SecureChatClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -69,7 +69,7 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// Unregister the channel from the global channel list
// so the channel does not receive messages anymore.
channels.remove(e.getChannel());
channels.remove(e.channel());
}
@Override
@ -81,8 +81,8 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
// Send the received message to all channels but the current one.
for (Channel c: channels) {
if (c != e.getChannel()) {
c.write("[" + e.getChannel().getRemoteAddress() + "] " +
if (c != e.channel()) {
c.write("[" + e.channel().getRemoteAddress() + "] " +
request + '\n');
} else {
c.write("[you] " + request + '\n');
@ -91,7 +91,7 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
// Close the connection if the client has sent 'bye'.
if (request.toLowerCase().equals("bye")) {
e.getChannel().close();
e.channel().close();
}
}
@ -101,8 +101,8 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
private static final class Greeter implements ChannelFutureListener {
@ -117,19 +117,19 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
// Once session is secured, send a greeting.
future.getChannel().write(
future.channel().write(
"Welcome to " + InetAddress.getLocalHost().getHostName() +
" secure chat service!\n");
future.getChannel().write(
future.channel().write(
"Your session is protected by " +
sslHandler.getEngine().getSession().getCipherSuite() +
" cipher suite.\n");
// Register the channel to the global channel list
// so the channel received the messages from others.
channels.add(future.getChannel());
channels.add(future.channel());
} else {
future.getChannel().close();
future.channel().close();
}
}
}

View File

@ -60,7 +60,7 @@ public class StdioLogger {
final String message = (String) e.getMessage();
synchronized (System.out) {
e.getChannel().write("Message received: " + message);
e.channel().write("Message received: " + message);
}
if ("exit".equals(message)) {
running = false;
@ -77,7 +77,7 @@ public class StdioLogger {
ChannelFuture connectFuture = bootstrap.connect(new IoStreamAddress(System.in, System.out));
// Wait until the connection is made successfully.
Channel channel = connectFuture.awaitUninterruptibly().getChannel();
Channel channel = connectFuture.awaitUninterruptibly().channel();
while (running) {
try {

View File

@ -52,9 +52,9 @@ public class TelnetClient {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
// Wait until the connection attempt succeeds or fails.
Channel channel = future.awaitUninterruptibly().getChannel();
Channel channel = future.awaitUninterruptibly().channel();
if (!future.isSuccess()) {
future.getCause().printStackTrace();
future.cause().printStackTrace();
bootstrap.releaseExternalResources();
return;
}

View File

@ -55,7 +55,7 @@ public class TelnetClientHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -50,9 +50,9 @@ public class TelnetServerHandler extends SimpleChannelUpstreamHandler {
public void channelConnected(
ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// Send greeting for a new connection.
e.getChannel().write(
e.channel().write(
"Welcome to " + InetAddress.getLocalHost().getHostName() + "!\r\n");
e.getChannel().write("It is " + new Date() + " now.\r\n");
e.channel().write("It is " + new Date() + " now.\r\n");
}
@Override
@ -77,7 +77,7 @@ public class TelnetServerHandler extends SimpleChannelUpstreamHandler {
// We do not need to write a ChannelBuffer here.
// We know the encoder inserted at TelnetPipelineFactory will do the conversion.
ChannelFuture future = e.getChannel().write(response);
ChannelFuture future = e.channel().write(response);
// Close the connection after sending 'Have a good day!'
// if the client has sent 'bye'.
@ -92,7 +92,7 @@ public class TelnetServerHandler extends SimpleChannelUpstreamHandler {
logger.log(
Level.WARNING,
"Unexpected exception from downstream.",
e.getCause());
e.getChannel().close();
e.cause());
e.channel().close();
}
}

View File

@ -75,7 +75,7 @@ public class UptimeClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
Throwable cause = e.getCause();
Throwable cause = e.cause();
if (cause instanceof ConnectException) {
startTime = -1;
println("Failed to connect: " + cause.getMessage());
@ -86,7 +86,7 @@ public class UptimeClientHandler extends SimpleChannelUpstreamHandler {
} else {
cause.printStackTrace();
}
ctx.getChannel().close();
ctx.channel().close();
}
void println(String msg) {

View File

@ -213,7 +213,7 @@ public class LoggingHandler implements ChannelUpstreamHandler, ChannelDownstream
// Log the message (and exception if available.)
if (e instanceof ExceptionEvent) {
getLogger().log(level, msg, ((ExceptionEvent) e).getCause());
getLogger().log(level, msg, ((ExceptionEvent) e).cause());
} else {
getLogger().log(level, msg);
}

View File

@ -133,7 +133,7 @@ public class BlockingReadHandler<E> extends SimpleChannelUpstreamHandler {
if (e instanceof MessageEvent) {
return getMessage((MessageEvent) e);
} else if (e instanceof ExceptionEvent) {
throw (IOException) new IOException().initCause(((ExceptionEvent) e).getCause());
throw (IOException) new IOException().initCause(((ExceptionEvent) e).cause());
} else {
throw new IllegalStateException();
}
@ -168,7 +168,7 @@ public class BlockingReadHandler<E> extends SimpleChannelUpstreamHandler {
if (e instanceof MessageEvent) {
return getMessage((MessageEvent) e);
} else if (e instanceof ExceptionEvent) {
throw (IOException) new IOException().initCause(((ExceptionEvent) e).getCause());
throw (IOException) new IOException().initCause(((ExceptionEvent) e).cause());
} else {
throw new IllegalStateException();
}

View File

@ -294,7 +294,7 @@ public class BufferedWriteHandler extends SimpleChannelHandler {
}
ChannelBuffer composite = ChannelBuffers.wrappedBuffer(data);
ChannelFuture future = Channels.future(ctx.getChannel());
ChannelFuture future = Channels.future(ctx.channel());
future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future)
@ -304,7 +304,7 @@ public class BufferedWriteHandler extends SimpleChannelHandler {
e.getFuture().setSuccess();
}
} else {
Throwable cause = future.getCause();
Throwable cause = future.cause();
for (MessageEvent e: pendingWrites) {
e.getFuture().setFailure(cause);
}

View File

@ -56,7 +56,7 @@ public class ChannelWritableByteChannel implements WritableByteChannel {
@Override
public boolean isOpen() {
return !closed && context.getChannel().isOpen();
return !closed && context.channel().isOpen();
}
@Override
@ -69,7 +69,7 @@ public class ChannelWritableByteChannel implements WritableByteChannel {
int written = src.remaining();
// create a new ChannelFuture and add it to the aggregator
ChannelFuture future = Channels.future(context.getChannel(), true);
ChannelFuture future = Channels.future(context.channel(), true);
aggregator.addFuture(future);
Channels.write(context, future, ChannelBuffers.wrappedBuffer(src), remote);

View File

@ -201,7 +201,7 @@ public class SslHandler extends FrameDecoder
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
Channels.fireExceptionCaught(future.getChannel(), future.getCause());
Channels.fireExceptionCaught(future.channel(), future.cause());
}
}
@ -346,7 +346,7 @@ public class SslHandler extends FrameDecoder
}
ChannelHandlerContext ctx = this.ctx;
Channel channel = ctx.getChannel();
Channel channel = ctx.channel();
ChannelFuture handshakeFuture;
Exception exception = null;
@ -386,7 +386,7 @@ public class SslHandler extends FrameDecoder
*/
public ChannelFuture close() {
ChannelHandlerContext ctx = this.ctx;
Channel channel = ctx.getChannel();
Channel channel = ctx.channel();
try {
engine.closeOutbound();
return wrapNonAppData(ctx, channel);
@ -491,7 +491,7 @@ public class SslHandler extends FrameDecoder
try {
super.channelDisconnected(ctx, e);
} finally {
unwrap(ctx, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
unwrap(ctx, e.channel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
engine.closeOutbound();
if (!sentCloseNotify.get() && handshaken) {
try {
@ -509,7 +509,7 @@ public class SslHandler extends FrameDecoder
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
Throwable cause = e.getCause();
Throwable cause = e.cause();
if (cause instanceof IOException) {
if (cause instanceof ClosedChannelException) {
synchronized (ignoreClosedChannelExceptionLock) {
@ -538,7 +538,7 @@ public class SslHandler extends FrameDecoder
// Close the connection explicitly just in case the transport
// did not close the connection automatically.
Channels.close(ctx, succeededFuture(e.getChannel()));
Channels.close(ctx, succeededFuture(e.channel()));
return;
}
}
@ -843,7 +843,7 @@ public class SslHandler extends FrameDecoder
@Override
public void operationComplete(ChannelFuture future)
throws Exception {
if (future.getCause() instanceof ClosedChannelException) {
if (future.cause() instanceof ClosedChannelException) {
synchronized (ignoreClosedChannelExceptionLock) {
ignoreClosedChannelException ++;
}
@ -972,7 +972,7 @@ public class SslHandler extends FrameDecoder
outAppBuf.flip();
if (outAppBuf.hasRemaining()) {
ChannelBuffer frame = ctx.getChannel().getConfig().getBufferFactory().getBuffer(outAppBuf.remaining());
ChannelBuffer frame = ctx.channel().getConfig().getBufferFactory().getBuffer(outAppBuf.remaining());
frame.writeBytes(outAppBuf.array(), 0, frame.capacity());
return frame;
} else {
@ -1033,7 +1033,7 @@ public class SslHandler extends FrameDecoder
"closing the connection"));
// Close the connection to stop renegotiation.
Channels.close(ctx, succeededFuture(ctx.getChannel()));
Channels.close(ctx, succeededFuture(ctx.channel()));
}
}
@ -1106,7 +1106,7 @@ public class SslHandler extends FrameDecoder
private void closeOutboundAndChannel(
final ChannelHandlerContext context, final ChannelStateEvent e) {
if (!e.getChannel().isConnected()) {
if (!e.channel().isConnected()) {
context.sendDownstream(e);
return;
}
@ -1114,7 +1114,7 @@ public class SslHandler extends FrameDecoder
boolean success = false;
try {
try {
unwrap(context, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
unwrap(context, e.channel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
} catch (SSLException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to unwrap before sending a close_notify message", ex);
@ -1125,7 +1125,7 @@ public class SslHandler extends FrameDecoder
if (sentCloseNotify.compareAndSet(false, true)) {
engine.closeOutbound();
try {
ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.getChannel());
ChannelFuture closeNotifyFuture = wrapNonAppData(context, e.channel());
closeNotifyFuture.addListener(
new ClosingChannelFutureListener(context, e));
success = true;
@ -1168,7 +1168,7 @@ public class SslHandler extends FrameDecoder
@Override
public void operationComplete(ChannelFuture closeNotifyFuture) throws Exception {
if (!(closeNotifyFuture.getCause() instanceof ClosedChannelException)) {
if (!(closeNotifyFuture.cause() instanceof ClosedChannelException)) {
Channels.close(context, e.getFuture());
} else {
e.getFuture().setSuccess();

View File

@ -109,7 +109,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
boolean offered = queue.offer((MessageEvent) e);
assert offered;
final Channel channel = ctx.getChannel();
final Channel channel = ctx.channel();
if (channel.isWritable()) {
this.ctx = ctx;
flush(ctx, false);
@ -182,7 +182,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
}
private synchronized void flush(ChannelHandlerContext ctx, boolean fireNow) throws Exception {
final Channel channel = ctx.getChannel();
final Channel channel = ctx.channel();
if (!channel.isConnected()) {
discard(ctx, fireNow);
}
@ -250,7 +250,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
public void operationComplete(ChannelFuture future)
throws Exception {
if (!future.isSuccess()) {
currentEvent.getFuture().setFailure(future.getCause());
currentEvent.getFuture().setFailure(future.cause());
closeInput((ChunkedInput) currentEvent.getMessage());
}
}

View File

@ -350,7 +350,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
protected void channelIdle(
ChannelHandlerContext ctx, IdleState state, long lastActivityTimeMillis) throws Exception {
ctx.sendUpstream(new DefaultIdleStateEvent(ctx.getChannel(), state, lastActivityTimeMillis));
ctx.sendUpstream(new DefaultIdleStateEvent(ctx.channel(), state, lastActivityTimeMillis));
}
private final class ReaderIdleTimeoutTask implements TimerTask {
@ -363,7 +363,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
@Override
public void run(Timeout timeout) throws Exception {
if (timeout.isCancelled() || !ctx.getChannel().isOpen()) {
if (timeout.isCancelled() || !ctx.channel().isOpen()) {
return;
}
@ -399,7 +399,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
@Override
public void run(Timeout timeout) throws Exception {
if (timeout.isCancelled() || !ctx.getChannel().isOpen()) {
if (timeout.isCancelled() || !ctx.channel().isOpen()) {
return;
}
@ -434,7 +434,7 @@ public class IdleStateHandler extends SimpleChannelUpstreamHandler
@Override
public void run(Timeout timeout) throws Exception {
if (timeout.isCancelled() || !ctx.getChannel().isOpen()) {
if (timeout.isCancelled() || !ctx.channel().isOpen()) {
return;
}

View File

@ -248,7 +248,7 @@ public class ReadTimeoutHandler extends SimpleChannelUpstreamHandler
return;
}
if (!ctx.getChannel().isOpen()) {
if (!ctx.channel().isOpen()) {
return;
}

View File

@ -173,7 +173,7 @@ public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler
return;
}
if (!ctx.getChannel().isOpen()) {
if (!ctx.channel().isOpen()) {
return;
}

View File

@ -225,12 +225,12 @@ public abstract class AbstractTrafficShapingHandler extends
return;
}
// logger.info("WAKEUP!");
if (ctx != null && ctx.getChannel() != null &&
ctx.getChannel().isConnected()) {
if (ctx != null && ctx.channel() != null &&
ctx.channel().isConnected()) {
//logger.info(" setReadable TRUE: "+timeToWait);
// readSuspended = false;
ctx.setAttachment(null);
ctx.getChannel().setReadable(true);
ctx.channel().setReadable(true);
}
}
}
@ -267,7 +267,7 @@ public abstract class AbstractTrafficShapingHandler extends
.getCurrentReadBytes(), trafficCounter.getLastTime(),
curtime);
if (wait > MINIMAL_WAIT) { // At least 10ms seems a minimal time in order to
Channel channel = arg0.getChannel();
Channel channel = arg0.channel();
// try to limit the traffic
if (channel != null && channel.isConnected()) {
// Channel version

View File

@ -95,11 +95,11 @@ public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler
throws Exception {
// readSuspended = true;
ctx.setAttachment(Boolean.TRUE);
ctx.getChannel().setReadable(false);
ctx.channel().setReadable(false);
if (trafficCounter == null) {
// create a new counter now
trafficCounter = new TrafficCounter(this, executor, "ChannelTC" +
ctx.getChannel().getId(), checkInterval);
ctx.channel().getId(), checkInterval);
}
if (trafficCounter != null) {
trafficCounter.start();
@ -107,7 +107,7 @@ public class ChannelTrafficShapingHandler extends AbstractTrafficShapingHandler
super.channelConnected(ctx, e);
// readSuspended = false;
ctx.setAttachment(null);
ctx.getChannel().setReadable(true);
ctx.channel().setReadable(true);
}
}

View File

@ -67,7 +67,7 @@ public abstract class AbstractSocketClientBootstrapTest {
ChannelFuture future = bootstrap.connect();
future.awaitUninterruptibly();
assertFalse(future.isSuccess());
assertTrue(future.getCause() instanceof IOException);
assertTrue(future.cause() instanceof IOException);
}
@Test(timeout = 10000)
@ -92,12 +92,12 @@ public abstract class AbstractSocketClientBootstrapTest {
serverSocket.accept();
future.awaitUninterruptibly();
if (future.getCause() != null) {
throw future.getCause();
if (future.cause() != null) {
throw future.cause();
}
assertTrue(future.isSuccess());
future.getChannel().close().awaitUninterruptibly();
future.channel().close().awaitUninterruptibly();
} finally {
try {
serverSocket.close();
@ -130,12 +130,12 @@ public abstract class AbstractSocketClientBootstrapTest {
serverSocket.accept();
future.awaitUninterruptibly();
if (future.getCause() != null) {
throw future.getCause();
if (future.cause() != null) {
throw future.cause();
}
assertTrue(future.isSuccess());
future.getChannel().close().awaitUninterruptibly();
future.channel().close().awaitUninterruptibly();
} finally {
try {
serverSocket.close();

View File

@ -98,7 +98,7 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
for (String element : data) {
cc.write(element);
}
@ -162,7 +162,7 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -182,8 +182,8 @@ public abstract class AbstractSocketCompatibleObjectStreamEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -84,7 +84,7 @@ public abstract class AbstractSocketEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
for (int i = 0; i < data.length;) {
int length = Math.min(random.nextInt(1024 * 64), data.length - i);
cc.write(ChannelBuffers.wrappedBuffer(data, i, length));
@ -150,7 +150,7 @@ public abstract class AbstractSocketEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -175,8 +175,8 @@ public abstract class AbstractSocketEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -87,7 +87,7 @@ public abstract class AbstractSocketFixedLengthEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
for (int i = 0; i < data.length;) {
int length = Math.min(random.nextInt(1024 * 3), data.length - i);
cc.write(ChannelBuffers.wrappedBuffer(data, i, length));
@ -153,7 +153,7 @@ public abstract class AbstractSocketFixedLengthEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -180,8 +180,8 @@ public abstract class AbstractSocketFixedLengthEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -100,7 +100,7 @@ public abstract class AbstractSocketObjectStreamEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
assertTrue(ccf.awaitUninterruptibly().isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
for (String element : data) {
cc.write(element);
}
@ -164,7 +164,7 @@ public abstract class AbstractSocketObjectStreamEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -184,8 +184,8 @@ public abstract class AbstractSocketObjectStreamEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -130,17 +130,17 @@ public abstract class AbstractSocketSslEchoTest {
ccf.awaitUninterruptibly();
if (!ccf.isSuccess()) {
if(logger.isErrorEnabled()) {
logger.error("Connection attempt failed", ccf.getCause());
logger.error("Connection attempt failed", ccf.cause());
}
sc.close().awaitUninterruptibly();
}
assertTrue(ccf.isSuccess());
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
ChannelFuture hf = cc.getPipeline().get(SslHandler.class).handshake();
hf.awaitUninterruptibly();
if (!hf.isSuccess()) {
logger.error("Handshake failed", hf.getCause());
logger.error("Handshake failed", hf.cause());
sh.channel.close().awaitUninterruptibly();
ch.channel.close().awaitUninterruptibly();
sc.close().awaitUninterruptibly();
@ -215,7 +215,7 @@ public abstract class AbstractSocketSslEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -243,11 +243,11 @@ public abstract class AbstractSocketSslEchoTest {
if (logger.isWarnEnabled()) {
logger.warn(
"Unexpected exception from the " +
(server? "server" : "client") + " side", e.getCause());
(server? "server" : "client") + " side", e.cause());
}
exception.compareAndSet(null, e.getCause());
e.getChannel().close();
exception.compareAndSet(null, e.cause());
e.channel().close();
}
}

View File

@ -102,11 +102,11 @@ public abstract class AbstractSocketStringEchoTest {
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
boolean success = ccf.awaitUninterruptibly().isSuccess();
if (!success) {
ccf.getCause().printStackTrace();
ccf.cause().printStackTrace();
}
assertTrue(success);
Channel cc = ccf.getChannel();
Channel cc = ccf.channel();
for (String element : data) {
String delimiter = random.nextBoolean() ? "\r\n" : "\n";
cc.write(element + delimiter);
@ -170,7 +170,7 @@ public abstract class AbstractSocketStringEchoTest {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channel = e.getChannel();
channel = e.channel();
}
@Override
@ -190,8 +190,8 @@ public abstract class AbstractSocketStringEchoTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
if (exception.compareAndSet(null, e.getCause())) {
e.getChannel().close();
if (exception.compareAndSet(null, e.cause())) {
e.channel().close();
}
}
}

View File

@ -54,14 +54,14 @@ public class NioClientSocketShutdownTimeTest {
serverSocket.accept();
f.awaitUninterruptibly();
if (f.getCause() != null) {
throw f.getCause();
if (f.cause() != null) {
throw f.cause();
}
assertTrue(f.isSuccess());
startTime = System.currentTimeMillis();
f.getChannel().close().awaitUninterruptibly();
f.channel().close().awaitUninterruptibly();
} finally {
b.getFactory().releaseExternalResources();

View File

@ -70,11 +70,11 @@ class AcceptedServerChannelRequestDispatch extends SimpleChannelUpstreamHandler
private void handleOpenTunnel(ChannelHandlerContext ctx) {
String tunnelId =
messageSwitch.createTunnel((InetSocketAddress) ctx.getChannel()
messageSwitch.createTunnel((InetSocketAddress) ctx.channel()
.getRemoteAddress());
if (LOG.isDebugEnabled()) {
LOG.debug("open tunnel request received from " +
ctx.getChannel().getRemoteAddress() + " - allocated ID " +
ctx.channel().getRemoteAddress() + " - allocated ID " +
tunnelId);
}
respondWith(ctx,
@ -126,7 +126,7 @@ class AcceptedServerChannelRequestDispatch extends SimpleChannelUpstreamHandler
if (LOG.isDebugEnabled()) {
LOG.debug("poll data request received for tunnel " + tunnelId);
}
messageSwitch.pollOutboundData(tunnelId, ctx.getChannel());
messageSwitch.pollOutboundData(tunnelId, ctx.channel());
}
private String checkTunnelId(HttpRequest request, ChannelHandlerContext ctx) {
@ -149,7 +149,7 @@ class AcceptedServerChannelRequestDispatch extends SimpleChannelUpstreamHandler
*/
private ChannelFuture respondWith(ChannelHandlerContext ctx,
HttpResponse response) {
ChannelFuture writeFuture = Channels.future(ctx.getChannel());
ChannelFuture writeFuture = Channels.future(ctx.channel());
Channels.write(ctx, writeFuture, response);
return writeFuture;
}
@ -161,7 +161,7 @@ class AcceptedServerChannelRequestDispatch extends SimpleChannelUpstreamHandler
private void respondWithRejection(ChannelHandlerContext ctx,
HttpRequest rejectedRequest, String errorMessage) {
if (LOG.isWarnEnabled()) {
SocketAddress remoteAddress = ctx.getChannel().getRemoteAddress();
SocketAddress remoteAddress = ctx.channel().getRemoteAddress();
String tunnelId =
HttpTunnelMessageUtils.extractTunnelId(rejectedRequest);
if (tunnelId == null) {

View File

@ -74,7 +74,7 @@ class HttpTunnelAcceptedChannelSink extends AbstractChannelSink {
}
final HttpTunnelAcceptedChannelReceiver channel =
(HttpTunnelAcceptedChannelReceiver) ev.getChannel();
(HttpTunnelAcceptedChannelReceiver) ev.channel();
final ChannelBuffer message = (ChannelBuffer) ev.getMessage();
final int messageSize = message.readableBytes();
final ChannelFuture future = ev.getFuture();
@ -98,7 +98,7 @@ class HttpTunnelAcceptedChannelSink extends AbstractChannelSink {
private void handleStateEvent(ChannelStateEvent ev) {
/* TODO: as any of disconnect, unbind or close destroys a server
channel, should we fire all three events always? */
Channel owner = ev.getChannel();
Channel owner = ev.channel();
switch (ev.getState()) {
case OPEN:
if (Boolean.FALSE.equals(ev.getValue())) {

View File

@ -252,7 +252,7 @@ final class HttpTunnelClientChannel extends AbstractChannel implements
if (future.isSuccess()) {
originalFuture.setSuccess();
} else {
originalFuture.setFailure(future.getCause());
originalFuture.setFailure(future.cause());
}
updateSaturationStatus(-messageSize);
}
@ -312,7 +312,7 @@ final class HttpTunnelClientChannel extends AbstractChannel implements
}
protected void futureFailed(ChannelFuture future) {
completionFuture.setFailure(future.getCause());
completionFuture.setFailure(future.cause());
}
}

View File

@ -41,13 +41,13 @@ class HttpTunnelClientChannelSink extends AbstractChannelSink {
private void handleMessageEvent(MessageEvent e) {
HttpTunnelClientChannel channel =
(HttpTunnelClientChannel) e.getChannel();
(HttpTunnelClientChannel) e.channel();
channel.sendData(e);
}
private void handleChannelStateEvent(ChannelStateEvent e) {
HttpTunnelClientChannel channel =
(HttpTunnelClientChannel) e.getChannel();
(HttpTunnelClientChannel) e.channel();
switch (e.getState()) {
case CONNECTED:

View File

@ -88,6 +88,6 @@ class HttpTunnelClientPollHandler extends SimpleChannelHandler {
HttpRequest request =
HttpTunnelMessageUtils.createReceiveDataRequest(
tunnelChannel.getServerHostName(), tunnelId);
Channels.write(ctx, Channels.future(ctx.getChannel()), request);
Channels.write(ctx, Channels.future(ctx.channel()), request);
}
}

View File

@ -75,7 +75,7 @@ class HttpTunnelClientSendHandler extends SimpleChannelHandler {
HttpTunnelMessageUtils
.createOpenTunnelRequest(tunnelChannel
.getServerHostName());
Channel thisChannel = ctx.getChannel();
Channel thisChannel = ctx.channel();
DownstreamMessageEvent event =
new DownstreamMessageEvent(thisChannel,
Channels.future(thisChannel), request,
@ -121,7 +121,7 @@ class HttpTunnelClientSendHandler extends SimpleChannelHandler {
LOG.warn("unknown response received for tunnel " + tunnelId +
", closing connection");
}
Channels.close(ctx, ctx.getChannel().getCloseFuture());
Channels.close(ctx, ctx.channel().getCloseFuture());
}
}
@ -143,7 +143,7 @@ class HttpTunnelClientSendHandler extends SimpleChannelHandler {
HttpRequest closeRequest =
HttpTunnelMessageUtils.createCloseTunnelRequest(
tunnelChannel.getServerHostName(), tunnelId);
Channels.write(ctx, Channels.future(ctx.getChannel()), closeRequest);
Channels.write(ctx, Channels.future(ctx.channel()), closeRequest);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("sending next request for tunnel " + tunnelId);
@ -174,8 +174,8 @@ class HttpTunnelClientSendHandler extends SimpleChannelHandler {
HttpTunnelMessageUtils.createSendDataRequest(
tunnelChannel.getServerHostName(), tunnelId, data);
DownstreamMessageEvent translatedEvent =
new DownstreamMessageEvent(ctx.getChannel(), e.getFuture(),
request, ctx.getChannel().getRemoteAddress());
new DownstreamMessageEvent(ctx.channel(), e.getFuture(),
request, ctx.channel().getRemoteAddress());
queuedWrites.offer(translatedEvent);
if (pendingRequestCount.incrementAndGet() == 1) {
sendQueuedData(ctx);
@ -210,7 +210,7 @@ class HttpTunnelClientSendHandler extends SimpleChannelHandler {
LOG.debug("tunnel shutdown requested for send channel of tunnel " +
tunnelId);
}
if (!ctx.getChannel().isConnected()) {
if (!ctx.channel().isConnected()) {
if (LOG.isDebugEnabled()) {
LOG.debug("send channel of tunnel " + tunnelId +
" is already disconnected");

View File

@ -70,7 +70,7 @@ class HttpTunnelServerChannelSink extends AbstractChannelSink {
if (future.isSuccess()) {
upstreamFuture.setSuccess();
} else {
upstreamFuture.setFailure(future.getCause());
upstreamFuture.setFailure(future.cause());
}
}
}

View File

@ -147,7 +147,7 @@ public class HttpTunnelingServlet extends HttpServlet {
Channel channel = channelFactory.newChannel(pipeline);
ChannelFuture future = channel.connect(remoteAddress).awaitUninterruptibly();
if (!future.isSuccess()) {
Throwable cause = future.getCause();
Throwable cause = future.cause();
if (logger.isWarnEnabled()) {
logger.warn("Endpoint unavailable: " + cause.getMessage(), cause);
}
@ -240,9 +240,9 @@ public class HttpTunnelingServlet extends HttpServlet {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
if (logger.isWarnEnabled()) {
logger.warn("Unexpected exception while HTTP tunneling", e.getCause());
logger.warn("Unexpected exception while HTTP tunneling", e.cause());
}
e.getChannel().close();
e.channel().close();
}
}
}

View File

@ -223,7 +223,7 @@ class ServerMessageSwitch implements ServerMessageSwitchUpstreamInterface,
}
for (ChannelBuffer fragment: fragments) {
ChannelFuture fragmentFuture =
Channels.future(writeFuture.getChannel());
Channels.future(writeFuture.channel());
aggregator.addFuture(fragmentFuture);
tunnel.queuedResponses.offer(new QueuedResponse(fragment,
fragmentFuture));
@ -248,7 +248,7 @@ class ServerMessageSwitch implements ServerMessageSwitchUpstreamInterface,
if (future.isSuccess()) {
originalFuture.setSuccess();
} else {
originalFuture.setFailure(future.getCause());
originalFuture.setFailure(future.cause());
}
}
}

View File

@ -48,7 +48,7 @@ class TunnelWrappedServerChannelHandler extends SimpleChannelUpstreamHandler {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
e.getChannel().getConfig().setPipelineFactory(pipelineFactory);
e.channel().getConfig().setPipelineFactory(pipelineFactory);
super.channelOpen(ctx, e);
}

View File

@ -62,7 +62,7 @@ public class WriteFragmenter extends SimpleChannelDownstreamHandler {
new ChannelFutureAggregator(e.getFuture());
for (ChannelBuffer fragment: fragments) {
ChannelFuture fragmentFuture =
Channels.future(ctx.getChannel(), true);
Channels.future(ctx.channel(), true);
aggregator.addFuture(fragmentFuture);
Channels.write(ctx, fragmentFuture, fragment);
}

View File

@ -251,7 +251,7 @@ public class HttpTunnelClientChannelTest {
bindFailureReason);
assertTrue(bindFuture.isDone());
assertFalse(bindFuture.isSuccess());
assertSame(bindFailureReason, bindFuture.getCause());
assertSame(bindFailureReason, bindFuture.cause());
}
@Test
@ -264,6 +264,6 @@ public class HttpTunnelClientChannelTest {
bindFailureReason);
assertTrue(bindFuture.isDone());
assertFalse(bindFuture.isSuccess());
assertSame(bindFailureReason, bindFuture.getCause());
assertSame(bindFailureReason, bindFuture.cause());
}
}

View File

@ -149,7 +149,7 @@ public class HttpTunnelServerChannelSinkTest {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
exceptionInPipeline = e.getCause();
exceptionInPipeline = e.cause();
}
}
}

View File

@ -231,7 +231,7 @@ public class HttpTunnelServerChannelTest {
Object expectedValue) {
assertTrue(ev instanceof UpstreamChannelStateEvent);
UpstreamChannelStateEvent checkedEv = (UpstreamChannelStateEvent) ev;
assertSame(expectedChannel, checkedEv.getChannel());
assertSame(expectedChannel, checkedEv.channel());
assertEquals(expectedState, checkedEv.getState());
assertEquals(expectedValue, checkedEv.getValue());
}

View File

@ -185,7 +185,7 @@ public class HttpTunnelSoakTester {
public void channelConnected(
ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
Channel childChannel = e.getChannel();
Channel childChannel = e.channel();
channels.add(childChannel);
s2cDataSender.setChannel(childChannel);
executor.execute(s2cDataSender);
@ -268,17 +268,17 @@ public class HttpTunnelSoakTester {
if (!clientChannelFuture.isSuccess()) {
LOG.log(Level.SEVERE, "did not connect successfully",
clientChannelFuture.getCause());
clientChannelFuture.cause());
return null;
}
HttpTunnelClientChannelConfig config =
(HttpTunnelClientChannelConfig) clientChannelFuture
.getChannel().getConfig();
.channel().getConfig();
config.setWriteBufferHighWaterMark(2 * 1024 * 1024);
config.setWriteBufferLowWaterMark(1024 * 1024);
return (SocketChannel) clientChannelFuture.getChannel();
return (SocketChannel) clientChannelFuture.channel();
}
ChannelBuffer createRandomSizeBuffer(AtomicInteger nextWriteByte) {
@ -350,7 +350,7 @@ public class HttpTunnelSoakTester {
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
channels.add(ctx.getChannel());
channels.add(ctx.channel());
}
public boolean waitForCompletion(long timeout, TimeUnit timeoutUnit)
@ -369,7 +369,7 @@ public class HttpTunnelSoakTester {
@Override
public void channelInterestChanged(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
boolean writeEnabled = ctx.getChannel().isWritable();
boolean writeEnabled = ctx.channel().isWritable();
sender.setWriteEnabled(writeEnabled);
}

View File

@ -147,9 +147,9 @@ public class HttpTunnelTest {
.getLocalHost(), 12345));
assertTrue(connectFuture.await(1000L));
assertTrue(connectFuture.isSuccess());
assertNotNull(connectFuture.getChannel());
assertNotNull(connectFuture.channel());
Channel clientChannel = connectFuture.getChannel();
Channel clientChannel = connectFuture.channel();
activeConnections.add(clientChannel);
assertEquals(serverChannel.getLocalAddress(),
clientChannel.getRemoteAddress());
@ -172,7 +172,7 @@ public class HttpTunnelTest {
.getLocalHost(), 12345));
assertTrue(connectFuture.await(1000L));
Channel clientEnd = connectFuture.getChannel();
Channel clientEnd = connectFuture.channel();
activeConnections.add(clientEnd);
assertTrue(serverEndLatch.await(1000, TimeUnit.MILLISECONDS));
@ -193,7 +193,7 @@ public class HttpTunnelTest {
.getLocalHost(), 12345));
assertTrue(connectFuture.await(1000L));
Channel clientEnd = connectFuture.getChannel();
Channel clientEnd = connectFuture.channel();
activeConnections.add(clientEnd);
assertTrue(serverEndLatch.await(1000, TimeUnit.MILLISECONDS));
@ -213,7 +213,7 @@ public class HttpTunnelTest {
@Override
public void channelConnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
serverEnd = e.getChannel();
serverEnd = e.channel();
activeConnections.add(serverEnd);
serverEndLatch.countDown();
super.channelConnected(ctx, e);

View File

@ -167,7 +167,7 @@ public class NettyTestUtils {
public static Throwable checkIsExceptionEvent(ChannelEvent ev) {
assertTrue(ev instanceof ExceptionEvent);
ExceptionEvent exceptionEv = (ExceptionEvent) ev;
return exceptionEv.getCause();
return exceptionEv.cause();
}
public static ChannelStateEvent checkIsStateEvent(ChannelEvent event,

View File

@ -41,7 +41,7 @@ class SctpClientPipelineSink extends AbstractNioChannelSink {
if (e instanceof ChannelStateEvent) {
ChannelStateEvent event = (ChannelStateEvent) e;
SctpClientChannel channel =
(SctpClientChannel) event.getChannel();
(SctpClientChannel) event.channel();
ChannelFuture future = event.getFuture();
ChannelState state = event.getState();
Object value = event.getValue();
@ -80,7 +80,7 @@ class SctpClientPipelineSink extends AbstractNioChannelSink {
}
} else if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
SctpChannelImpl channel = (SctpChannelImpl) event.getChannel();
SctpChannelImpl channel = (SctpChannelImpl) event.channel();
boolean offered = channel.getWriteBufferQueue().offer(event);
assert offered;
channel.getWorker().writeFromUserCode(channel);

View File

@ -58,7 +58,7 @@ class SctpServerPipelineSink extends AbstractNioChannelSink {
ChannelStateEvent event = (ChannelStateEvent) e;
SctpServerChannelImpl channel =
(SctpServerChannelImpl) event.getChannel();
(SctpServerChannelImpl) event.channel();
ChannelFuture future = event.getFuture();
ChannelState state = event.getState();
Object value = event.getValue();
@ -92,7 +92,7 @@ class SctpServerPipelineSink extends AbstractNioChannelSink {
private void handleAcceptedSocket(ChannelEvent e) {
if (e instanceof ChannelStateEvent) {
ChannelStateEvent event = (ChannelStateEvent) e;
SctpChannelImpl channel = (SctpChannelImpl) event.getChannel();
SctpChannelImpl channel = (SctpChannelImpl) event.channel();
ChannelFuture future = event.getFuture();
ChannelState state = event.getState();
Object value = event.getValue();
@ -115,7 +115,7 @@ class SctpServerPipelineSink extends AbstractNioChannelSink {
}
} else if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
SctpChannelImpl channel = (SctpChannelImpl) event.getChannel();
SctpChannelImpl channel = (SctpChannelImpl) event.channel();
boolean offered = channel.getWriteBufferQueue().offer(event);
assert offered;
channel.getWorker().writeFromUserCode(channel);

View File

@ -76,7 +76,7 @@ public abstract class AbstractSocketClientBootstrapTest {
ChannelFuture future = bootstrap.connect();
future.awaitUninterruptibly();
assertFalse(future.isSuccess());
assertTrue(future.getCause() instanceof IOException);
assertTrue(future.cause() instanceof IOException);
}
@Test(timeout = 10000)
@ -109,12 +109,12 @@ public abstract class AbstractSocketClientBootstrapTest {
serverChannel.accept();
future.awaitUninterruptibly();
if (future.getCause() != null) {
throw future.getCause();
if (future.cause() != null) {
throw future.cause();
}
assertTrue(future.isSuccess());
future.getChannel().close().awaitUninterruptibly();
future.channel().close().awaitUninterruptibly();
} finally {
try {
serverChannel.close();
@ -152,12 +152,12 @@ public abstract class AbstractSocketClientBootstrapTest {
serverChannel.accept();
future.awaitUninterruptibly();
if (future.getCause() != null) {
throw future.getCause();
if (future.cause() != null) {
throw future.cause();
}
assertTrue(future.isSuccess());
future.getChannel().close().awaitUninterruptibly();
future.channel().close().awaitUninterruptibly();
} finally {
try {
serverChannel.close();

Some files were not shown because too many files have changed in this diff Show More