Synchronized between 4.1 and master

Motivation:

4 and 5 were diverged long time ago and we recently reverted some of the
early commits in master.  We must make sure 4.1 and master are not very
different now.

Modification:

Fix found differences

Result:

4.1 and master got closer.
This commit is contained in:
Trustin Lee 2014-04-24 21:12:51 +09:00
parent 48f2e705d9
commit d2614cfc01
49 changed files with 119 additions and 154 deletions

View File

@ -36,28 +36,6 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
this.leak = leak; this.leak = leak;
} }
@Override
public boolean release() {
boolean deallocated = super.release();
if (deallocated) {
leak.close();
} else {
leak.record();
}
return deallocated;
}
@Override
public boolean release(int decrement) {
boolean deallocated = super.release(decrement);
if (deallocated) {
leak.close();
} else {
leak.record();
}
return deallocated;
}
@Override @Override
public ByteBuf order(ByteOrder endianness) { public ByteBuf order(ByteOrder endianness) {
leak.record(); leak.record();
@ -704,6 +682,12 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
return super.toString(index, length, charset); return super.toString(index, length, charset);
} }
@Override
public ByteBuf capacity(int newCapacity) {
leak.record();
return super.capacity(newCapacity);
}
@Override @Override
public ByteBuf retain() { public ByteBuf retain() {
leak.record(); leak.record();
@ -729,8 +713,24 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
} }
@Override @Override
public ByteBuf capacity(int newCapacity) { public boolean release() {
boolean deallocated = super.release();
if (deallocated) {
leak.close();
} else {
leak.record(); leak.record();
return super.capacity(newCapacity); }
return deallocated;
}
@Override
public boolean release(int decrement) {
boolean deallocated = super.release(decrement);
if (deallocated) {
leak.close();
} else {
leak.record();
}
return deallocated;
} }
} }

View File

@ -25,7 +25,6 @@ import io.netty.buffer.Unpooled;
public class DefaultFullHttpResponse extends DefaultHttpResponse implements FullHttpResponse { public class DefaultFullHttpResponse extends DefaultHttpResponse implements FullHttpResponse {
private final ByteBuf content; private final ByteBuf content;
private final HttpHeaders trailingHeaders; private final HttpHeaders trailingHeaders;
private final boolean validateHeaders; private final boolean validateHeaders;

View File

@ -92,6 +92,6 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent
@Override @Override
public String toString() { public String toString() {
return StringUtil.simpleClassName(this) + return StringUtil.simpleClassName(this) +
"(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')'; "(data: " + content() + ", decoderResult: " + getDecoderResult() + ')';
} }
} }

View File

@ -42,7 +42,7 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
* @param httpVersion the HTTP version of the request * @param httpVersion the HTTP version of the request
* @param method the HTTP getMethod of the request * @param method the HTTP getMethod of the request
* @param uri the URI or path of the request * @param uri the URI or path of the request
* @param validateHeaders validate the header names and values when adding them to the {@link HttpHeaders}. * @param validateHeaders validate the header names and values when adding them to the {@link HttpHeaders}
*/ */
public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, boolean validateHeaders) { public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri, boolean validateHeaders) {
super(httpVersion, validateHeaders); super(httpVersion, validateHeaders);
@ -98,7 +98,7 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
buf.append(getDecoderResult()); buf.append(getDecoderResult());
buf.append(')'); buf.append(')');
buf.append(StringUtil.NEWLINE); buf.append(StringUtil.NEWLINE);
buf.append(getMethod().toString()); buf.append(getMethod());
buf.append(' '); buf.append(' ');
buf.append(getUri()); buf.append(getUri());
buf.append(' '); buf.append(' ');

View File

@ -39,7 +39,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
* *
* @param version the HTTP version of this response * @param version the HTTP version of this response
* @param status the getStatus of this response * @param status the getStatus of this response
* @param validateHeaders validate the header names and values when adding them to the {@link HttpHeaders}. * @param validateHeaders validate the header names and values when adding them to the {@link HttpHeaders}
*/ */
public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders) { public DefaultHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders) {
super(version, validateHeaders); super(version, validateHeaders);

View File

@ -17,8 +17,8 @@ package io.netty.handler.codec.http;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelHandlerAppender; import io.netty.channel.ChannelHandlerAppender;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.PrematureChannelClosureException; import io.netty.handler.codec.PrematureChannelClosureException;
import java.util.ArrayDeque; import java.util.ArrayDeque;
@ -81,7 +81,8 @@ public final class HttpClientCodec extends ChannelHandlerAppender {
public HttpClientCodec( public HttpClientCodec(
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse, int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
boolean validateHeaders) { boolean validateHeaders) {
add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder()); add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders));
add(new Encoder());
this.failOnMissingResponse = failOnMissingResponse; this.failOnMissingResponse = failOnMissingResponse;
} }

View File

@ -149,8 +149,8 @@ public class HttpMethod implements Comparable<HttpMethod> {
} }
for (int i = 0; i < name.length(); i ++) { for (int i = 0; i < name.length(); i ++) {
if (Character.isISOControl(name.charAt(i)) || char c = name.charAt(i);
Character.isWhitespace(name.charAt(i))) { if (Character.isISOControl(c) || Character.isWhitespace(c)) {
throw new IllegalArgumentException("invalid character in name"); throw new IllegalArgumentException("invalid character in name");
} }
} }

View File

@ -177,6 +177,7 @@ public class HttpVersion implements Comparable<HttpVersion> {
this.minorVersion = minorVersion; this.minorVersion = minorVersion;
text = protocolName + '/' + majorVersion + '.' + minorVersion; text = protocolName + '/' + majorVersion + '.' + minorVersion;
this.keepAliveDefault = keepAliveDefault; this.keepAliveDefault = keepAliveDefault;
if (bytes) { if (bytes) {
this.bytes = text.getBytes(CharsetUtil.US_ASCII); this.bytes = text.getBytes(CharsetUtil.US_ASCII);
} else { } else {

View File

@ -27,7 +27,6 @@ public interface HttpDataFactory {
/** /**
* To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException. * To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException.
* A value of -1 means no limitation (default). * A value of -1 means no limitation (default).
* @param max
*/ */
void setMaxLimit(long max); void setMaxLimit(long max);

View File

@ -40,8 +40,7 @@ import java.net.URI;
public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker { public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketClientHandshaker08.class); private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketClientHandshaker08.class);
private static final CharSequence WEBSOCKET = HttpHeaders.newEntity( private static final CharSequence WEBSOCKET = HttpHeaders.newEntity(Values.WEBSOCKET.toString().toLowerCase());
HttpHeaders.Values.WEBSOCKET.toString().toLowerCase());
public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; public static final String MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

View File

@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpHeaders.Names; import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
@ -34,8 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
*/ */
public class WebSocketServerHandshaker07 extends WebSocketServerHandshaker { public class WebSocketServerHandshaker07 extends WebSocketServerHandshaker {
private static final CharSequence WEBSOCKET = HttpHeaders.newEntity( private static final CharSequence WEBSOCKET = HttpHeaders.newEntity(Values.WEBSOCKET.toString().toLowerCase());
HttpHeaders.Values.WEBSOCKET.toString().toLowerCase());
public static final String WEBSOCKET_07_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; public static final String WEBSOCKET_07_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

View File

@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpHeaders.Names; import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
@ -34,8 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
*/ */
public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker { public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
private static final CharSequence WEBSOCKET = HttpHeaders.newEntity( private static final CharSequence WEBSOCKET = HttpHeaders.newEntity(Values.WEBSOCKET.toString().toLowerCase());
HttpHeaders.Values.WEBSOCKET.toString().toLowerCase());
public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; public static final String WEBSOCKET_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

View File

@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse; import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpHeaders.Names; import io.netty.handler.codec.http.HttpHeaders.Names;
import io.netty.handler.codec.http.HttpHeaders.Values;
import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.CharsetUtil; import io.netty.util.CharsetUtil;
@ -32,8 +33,8 @@ import static io.netty.handler.codec.http.HttpVersion.*;
* </p> * </p>
*/ */
public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker { public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
private static final CharSequence WEBSOCKET = HttpHeaders.newEntity(
HttpHeaders.Values.WEBSOCKET.toString().toLowerCase()); private static final CharSequence WEBSOCKET = HttpHeaders.newEntity(Values.WEBSOCKET.toString().toLowerCase());
public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; public static final String WEBSOCKET_13_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

View File

@ -19,10 +19,10 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Map.Entry;
public class DefaultSpdyHeaders extends SpdyHeaders { public class DefaultSpdyHeaders extends SpdyHeaders {

View File

@ -493,10 +493,10 @@ public class HttpResponseDecoderTest {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder()); EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.wrappedBuffer(data, otherData)); ch.writeInbound(Unpooled.wrappedBuffer(data, otherData));
HttpResponse res = (HttpResponse) ch.readInbound(); HttpResponse res = ch.readInbound();
assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1)); assertThat(res.getProtocolVersion(), sameInstance(HttpVersion.HTTP_1_1));
assertThat(res.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS)); assertThat(res.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
HttpContent content = (HttpContent) ch.readInbound(); HttpContent content = ch.readInbound();
assertThat(content.content().readableBytes(), is(16)); assertThat(content.content().readableBytes(), is(16));
content.release(); content.release();

View File

@ -15,8 +15,8 @@
*/ */
package io.netty.handler.codec.http.cors; package io.netty.handler.codec.http.cors;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.http.DefaultFullHttpRequest; import io.netty.handler.codec.http.DefaultFullHttpRequest;
import io.netty.handler.codec.http.DefaultHttpResponse; import io.netty.handler.codec.http.DefaultHttpResponse;
@ -239,12 +239,10 @@ public class CorsHandlerTest {
return new DefaultFullHttpRequest(HTTP_1_1, method, "/info"); return new DefaultFullHttpRequest(HTTP_1_1, method, "/info");
} }
private static class EchoHandler extends ChannelHandlerAdapter { private static class EchoHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
ctx.writeAndFlush(new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK)); ctx.writeAndFlush(new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK));
} }
} }
} }

View File

@ -16,8 +16,8 @@
package io.netty.handler.codec.memcache.binary; package io.netty.handler.codec.memcache.binary;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelHandlerAppender; import io.netty.channel.ChannelHandlerAppender;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.PrematureChannelClosureException; import io.netty.handler.codec.PrematureChannelClosureException;
import io.netty.handler.codec.memcache.LastMemcacheContent; import io.netty.handler.codec.memcache.LastMemcacheContent;
@ -35,8 +35,7 @@ import java.util.concurrent.atomic.AtomicLong;
* content, which defaults to 8192. This chunk size is the maximum, so if smaller chunks arrive they * content, which defaults to 8192. This chunk size is the maximum, so if smaller chunks arrive they
* will be passed up the pipeline and not queued up to the chunk size. * will be passed up the pipeline and not queued up to the chunk size.
*/ */
public final class BinaryMemcacheClientCodec public final class BinaryMemcacheClientCodec extends ChannelHandlerAppender {
extends ChannelHandlerAppender {
private final boolean failOnMissingResponse; private final boolean failOnMissingResponse;
private final AtomicLong requestResponseCounter = new AtomicLong(); private final AtomicLong requestResponseCounter = new AtomicLong();
@ -65,7 +64,8 @@ public final class BinaryMemcacheClientCodec
*/ */
public BinaryMemcacheClientCodec(int decodeChunkSize, boolean failOnMissingResponse) { public BinaryMemcacheClientCodec(int decodeChunkSize, boolean failOnMissingResponse) {
this.failOnMissingResponse = failOnMissingResponse; this.failOnMissingResponse = failOnMissingResponse;
add(new Decoder(decodeChunkSize), new Encoder()); add(new Decoder(decodeChunkSize));
add(new Encoder());
} }
private final class Encoder extends BinaryMemcacheRequestEncoder { private final class Encoder extends BinaryMemcacheRequestEncoder {
@ -82,7 +82,7 @@ public final class BinaryMemcacheClientCodec
private final class Decoder extends BinaryMemcacheResponseDecoder { private final class Decoder extends BinaryMemcacheResponseDecoder {
public Decoder(int chunkSize) { Decoder(int chunkSize) {
super(chunkSize); super(chunkSize);
} }

View File

@ -31,6 +31,7 @@ public class BinaryMemcacheServerCodec extends ChannelHandlerAppender {
} }
public BinaryMemcacheServerCodec(int decodeChunkSize) { public BinaryMemcacheServerCodec(int decodeChunkSize) {
add(new BinaryMemcacheRequestDecoder(decodeChunkSize), new BinaryMemcacheResponseEncoder()); add(new BinaryMemcacheRequestDecoder(decodeChunkSize));
add(new BinaryMemcacheResponseEncoder());
} }
} }

View File

@ -39,7 +39,7 @@ public abstract class Recycler<T> {
// In the future, we might have different maxCapacity for different object types. // In the future, we might have different maxCapacity for different object types.
// e.g. io.netty.recycler.maxCapacity.writeTask // e.g. io.netty.recycler.maxCapacity.writeTask
// io.netty.recycler.maxCapacity.outboundBuffer // io.netty.recycler.maxCapacity.outboundBuffer
int maxCapacity = SystemPropertyUtil.getInt("io.netty.recycler.maxCapacity.default", 0); int maxCapacity = SystemPropertyUtil.getInt("io.netty.recycler.maxCapacity", 0);
if (maxCapacity <= 0) { if (maxCapacity <= 0) {
// TODO: Some arbitrary large number - should adjust as we get more production experience. // TODO: Some arbitrary large number - should adjust as we get more production experience.
maxCapacity = 262144; maxCapacity = 262144;
@ -47,7 +47,7 @@ public abstract class Recycler<T> {
DEFAULT_MAX_CAPACITY = maxCapacity; DEFAULT_MAX_CAPACITY = maxCapacity;
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("-Dio.netty.recycler.maxCapacity.default: {}", DEFAULT_MAX_CAPACITY); logger.debug("-Dio.netty.recycler.maxCapacity: {}", DEFAULT_MAX_CAPACITY);
} }
INITIAL_CAPACITY = Math.min(DEFAULT_MAX_CAPACITY, 256); INITIAL_CAPACITY = Math.min(DEFAULT_MAX_CAPACITY, 256);

View File

@ -49,9 +49,7 @@ public final class Signal extends Error implements Constant<Signal> {
private final String name; private final String name;
/** /**
* Create a new instance * Creates a new {@link Signal} with the specified {@code name}.
*
* @param name the name under which it is registered
*/ */
private Signal(int id, String name) { private Signal(int id, String name) {
this.id = id; this.id = id;

View File

@ -20,8 +20,7 @@ import java.util.concurrent.ThreadFactory;
/** /**
* Default {@link SingleThreadEventExecutor} implementation which just execute all submitted task in a * Default {@link SingleThreadEventExecutor} implementation which just execute all submitted task in a
* serial fashion * serial fashion.
*
*/ */
public final class DefaultEventExecutor extends SingleThreadEventExecutor { public final class DefaultEventExecutor extends SingleThreadEventExecutor {

View File

@ -41,8 +41,8 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
return 0; return 0;
} }
}; };
private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class.getName() + ".SUCCESS"); private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class, "SUCCESS");
private static final Signal UNCANCELLABLE = Signal.valueOf(DefaultPromise.class.getName() + ".UNCANCELLABLE"); private static final Signal UNCANCELLABLE = Signal.valueOf(DefaultPromise.class, "UNCANCELLABLE");
private static final CauseHolder CANCELLATION_CAUSE_HOLDER = new CauseHolder(new CancellationException()); private static final CauseHolder CANCELLATION_CAUSE_HOLDER = new CauseHolder(new CancellationException());
static { static {

View File

@ -16,8 +16,6 @@
package io.netty.util.concurrent; package io.netty.util.concurrent;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/** /**
* The {@link EventExecutor} is a special {@link EventExecutorGroup} which comes * The {@link EventExecutor} is a special {@link EventExecutorGroup} which comes
@ -79,25 +77,4 @@ public interface EventExecutor extends EventExecutorGroup {
* every call of blocking methods will just return without blocking. * every call of blocking methods will just return without blocking.
*/ */
<V> Future<V> newFailedFuture(Throwable cause); <V> Future<V> newFailedFuture(Throwable cause);
@Override
Future<?> submit(Runnable task);
@Override
<T> Future<T> submit(Runnable task, T result);
@Override
<T> Future<T> submit(Callable<T> task);
@Override
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
@Override
<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
@Override
ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
@Override
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit);
} }

View File

@ -88,6 +88,7 @@ public final class GlobalEventExecutor extends AbstractEventExecutor {
try { try {
task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS); task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Waken up.
return null; return null;
} }
} else { } else {

View File

@ -196,6 +196,7 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
try { try {
task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS); task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Waken up.
return null; return null;
} }
} }

View File

@ -67,6 +67,7 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
}); });
final Channel inboundChannel = ctx.channel(); final Channel inboundChannel = ctx.channel();
b.group(inboundChannel.eventLoop()) b.group(inboundChannel.eventLoop())
.channel(NioSocketChannel.class) .channel(NioSocketChannel.class)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)

View File

@ -41,4 +41,3 @@
* mvn exec:exec -Pspdy-client * mvn exec:exec -Pspdy-client
*/ */
package io.netty.example.spdy.client; package io.netty.example.spdy.client;

View File

@ -38,7 +38,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
* <p> * <p>
* Once started, you can test the server with your * Once started, you can test the server with your
* <a href="http://en.wikipedia.org/wiki/SPDY#Browser_support_and_usage">SPDY enabled web browser</a> by navigating * <a href="http://en.wikipedia.org/wiki/SPDY#Browser_support_and_usage">SPDY enabled web browser</a> by navigating
* to https://localhost:8443/. * to to <a href="https://localhost:8443/">https://localhost:8443/</a>
*/ */
public class SpdyServer { public class SpdyServer {

View File

@ -34,7 +34,7 @@ public enum LogLevel {
} }
/** /**
* Convert the {@link LogLevel} to its {@link InternalLogLevel} variant. * Converts the specified {@link LogLevel} to its {@link InternalLogLevel} variant.
* *
* @return the converted level. * @return the converted level.
*/ */

View File

@ -127,7 +127,7 @@ public class LoggingHandler extends ChannelHandlerAdapter {
* Creates a new instance with the specified logger name and with hex dump * Creates a new instance with the specified logger name and with hex dump
* enabled. * enabled.
* *
* @param clazz the class type to generate the logger for. * @param clazz the class type to generate the logger for
*/ */
public LoggingHandler(Class<?> clazz) { public LoggingHandler(Class<?> clazz) {
this(clazz, DEFAULT_LEVEL); this(clazz, DEFAULT_LEVEL);
@ -136,8 +136,8 @@ public class LoggingHandler extends ChannelHandlerAdapter {
/** /**
* Creates a new instance with the specified logger name. * Creates a new instance with the specified logger name.
* *
* @param clazz the class type to generate the logger for. * @param clazz the class type to generate the logger for
* @param level the log level. * @param level the log level
*/ */
public LoggingHandler(Class<?> clazz, LogLevel level) { public LoggingHandler(Class<?> clazz, LogLevel level) {
if (clazz == null) { if (clazz == null) {
@ -155,7 +155,7 @@ public class LoggingHandler extends ChannelHandlerAdapter {
/** /**
* Creates a new instance with the specified logger name using the default log level. * Creates a new instance with the specified logger name using the default log level.
* *
* @param name the name of the class to use for the logger. * @param name the name of the class to use for the logger
*/ */
public LoggingHandler(String name) { public LoggingHandler(String name) {
this(name, DEFAULT_LEVEL); this(name, DEFAULT_LEVEL);
@ -164,8 +164,8 @@ public class LoggingHandler extends ChannelHandlerAdapter {
/** /**
* Creates a new instance with the specified logger name. * Creates a new instance with the specified logger name.
* *
* @param name the name of the class to use for the logger. * @param name the name of the class to use for the logger
* @param level the log level. * @param level the log level
*/ */
public LoggingHandler(String name, LogLevel level) { public LoggingHandler(String name, LogLevel level) {
if (name == null) { if (name == null) {

View File

@ -37,7 +37,7 @@
* <p>Both inbound and outbound traffic can be shaped independently. This is done by either passing in * <p>Both inbound and outbound traffic can be shaped independently. This is done by either passing in
* the desired limiting values to the constructors of both the Channel and Global traffic shaping handlers, * the desired limiting values to the constructors of both the Channel and Global traffic shaping handlers,
* or by calling the <tt>configure</tt> method on the {@link io.netty.handler.traffic.AbstractTrafficShapingHandler}. * or by calling the <tt>configure</tt> method on the {@link io.netty.handler.traffic.AbstractTrafficShapingHandler}.
* A value of for either parameter indicates that there should be no limitation. This allows you to monitor the * A value of 0 for either parameter indicates that there should be no limitation. This allows you to monitor the
* incoming and outgoing traffic without shaping.</p> * incoming and outgoing traffic without shaping.</p>
* *
* <p>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms * <p>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms

View File

@ -23,10 +23,10 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerAdapter; import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -42,7 +42,7 @@ public class SocketEchoTest extends AbstractSocketTest {
private static final Random random = new Random(); private static final Random random = new Random();
static final byte[] data = new byte[1048576]; static final byte[] data = new byte[1048576];
private static EventLoopGroup group; private static EventExecutorGroup group;
static { static {
random.nextBytes(data); random.nextBytes(data);
@ -50,7 +50,7 @@ public class SocketEchoTest extends AbstractSocketTest {
@BeforeClass @BeforeClass
public static void createGroup() { public static void createGroup() {
group = new DefaultEventLoopGroup(2); group = new DefaultEventExecutorGroup(2);
} }
@AfterClass @AfterClass

View File

@ -21,8 +21,6 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder; import io.netty.handler.codec.LineBasedFrameDecoder;
@ -32,6 +30,7 @@ import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslHandler; import io.netty.handler.ssl.SslHandler;
import io.netty.testsuite.util.BogusSslContextFactory; import io.netty.testsuite.util.BogusSslContextFactory;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup; import io.netty.util.concurrent.EventExecutorGroup;
import io.netty.util.concurrent.Future; import io.netty.util.concurrent.Future;
import org.junit.AfterClass; import org.junit.AfterClass;
@ -47,11 +46,11 @@ import static org.junit.Assert.*;
public class SocketStartTlsTest extends AbstractSocketTest { public class SocketStartTlsTest extends AbstractSocketTest {
private static final LogLevel LOG_LEVEL = LogLevel.TRACE; private static final LogLevel LOG_LEVEL = LogLevel.TRACE;
private static EventLoopGroup executor; private static EventExecutorGroup executor;
@BeforeClass @BeforeClass
public static void createExecutor() { public static void createExecutor() {
executor = new DefaultEventLoopGroup(2); executor = new DefaultEventExecutorGroup(2);
} }
@AfterClass @AfterClass

View File

@ -34,7 +34,7 @@ public class AutobahnServer {
} }
public void run() throws Exception { public void run() throws Exception {
EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup();
try { try {
ServerBootstrap b = new ServerBootstrap(); ServerBootstrap b = new ServerBootstrap();

View File

@ -58,6 +58,8 @@ public class AutobahnServerHandler extends ChannelHandlerAdapter {
handleHttpRequest(ctx, (FullHttpRequest) msg); handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) { } else if (msg instanceof WebSocketFrame) {
handleWebSocketFrame(ctx, (WebSocketFrame) msg); handleWebSocketFrame(ctx, (WebSocketFrame) msg);
} else {
throw new IllegalStateException("unknown message: " + msg);
} }
} }

View File

@ -210,7 +210,7 @@ public abstract class AbstractBootstrap<B extends AbstractBootstrap<B, C>, C ext
/** /**
* Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making * Returns a deep clone of this bootstrap which has the identical configuration. This method is useful when making
* multiple {@link Channel}s with similar settings. Please note that this method does not clone the * multiple {@link Channel}s with similar settings. Please note that this method does not clone the
* {@link EventExecutorGroup} deeply but shallowly, making the group a shared resource. * {@link EventLoopGroup} deeply but shallowly, making the group a shared resource.
*/ */
@Override @Override
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2013 The Netty Project * Copyright 2014 The Netty Project
* *
* The Netty Project licenses this file to you under the Apache License, * The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance * version 2.0 (the "License"); you may not use this file except in compliance
@ -23,6 +23,8 @@ import io.netty.util.concurrent.AbstractEventExecutor;
*/ */
public abstract class AbstractEventLoop extends AbstractEventExecutor implements EventLoop { public abstract class AbstractEventLoop extends AbstractEventExecutor implements EventLoop {
protected AbstractEventLoop() { }
protected AbstractEventLoop(EventLoopGroup parent) { protected AbstractEventLoop(EventLoopGroup parent) {
super(parent); super(parent);
} }

View File

@ -162,7 +162,7 @@ public interface ChannelHandlerContext extends AttributeMap {
/** /**
* Return {@code true} if the {@link ChannelHandler} which belongs to this {@link ChannelHandler} was removed * Return {@code true} if the {@link ChannelHandler} which belongs to this {@link ChannelHandler} was removed
* from the {@link ChannelPipeline}. Note that this method is only meant to be called from with in the * from the {@link ChannelPipeline}. Note that this method is only meant to be called from with in the
* {@link EventExecutor}. * {@link EventLoop}.
*/ */
boolean isRemoved(); boolean isRemoved();

View File

@ -64,9 +64,8 @@ public final class ChannelHandlerInvokerUtil {
ctx.handler().exceptionCaught(ctx, cause); ctx.handler().exceptionCaught(ctx, cause);
} catch (Throwable t) { } catch (Throwable t) {
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn( logger.warn("An exception was thrown by a user handler's exceptionCaught() method:", t);
"An exception was thrown by a user handler's " + logger.warn(".. and the cause of the exceptionCaught() was:", cause);
"exceptionCaught() method while handling the following exception:", cause);
} }
} }
} }

View File

@ -90,8 +90,7 @@ public final class ChannelOption<T> extends AbstractConstant<ChannelOption<T>> {
valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION"); valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION");
/** /**
* Create a new {@link ChannelOption} with the given name. The name needs to be * Creates a new {@link ChannelOption} with the specified unique {@code name}.
* unique.
*/ */
private ChannelOption(int id, String name) { private ChannelOption(int id, String name) {
super(id, name); super(id, name);

View File

@ -16,7 +16,6 @@
package io.netty.channel; package io.netty.channel;
import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.concurrent.EventExecutorGroup;
import io.netty.util.concurrent.MultithreadEventExecutorGroup; import io.netty.util.concurrent.MultithreadEventExecutorGroup;
import io.netty.util.internal.SystemPropertyUtil; import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLogger;
@ -26,7 +25,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
/** /**
* Abstract base class for {@link EventExecutorGroup} implementations that handles their tasks with multiple threads at * Abstract base class for {@link EventLoopGroup} implementations that handles their tasks with multiple threads at
* the same time. * the same time.
*/ */
public abstract class MultithreadEventLoopGroup extends MultithreadEventExecutorGroup implements EventLoopGroup { public abstract class MultithreadEventLoopGroup extends MultithreadEventExecutorGroup implements EventLoopGroup {

View File

@ -235,7 +235,7 @@ public class EmbeddedChannel extends AbstractChannel {
} }
/** /**
* Run all tasks that are pending in the {@link io.netty.channel.EventLoop} for this {@link Channel} * Run all tasks that are pending in the {@link EventLoop} for this {@link Channel}
*/ */
public void runPendingTasks() { public void runPendingTasks() {
try { try {

View File

@ -35,10 +35,6 @@ final class EmbeddedEventLoop extends AbstractEventLoop implements ChannelHandle
private final Queue<Runnable> tasks = new ArrayDeque<Runnable>(2); private final Queue<Runnable> tasks = new ArrayDeque<Runnable>(2);
protected EmbeddedEventLoop() {
super(null);
}
@Override @Override
public void execute(Runnable command) { public void execute(Runnable command) {
if (command == null) { if (command == null) {

View File

@ -43,7 +43,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* {@link io.netty.channel.SingleThreadEventLoop} implementation which register the {@link Channel}'s to a * {@link SingleThreadEventLoop} implementation which register the {@link Channel}'s to a
* {@link Selector} and so does the multi-plexing of these in the event loop. * {@link Selector} and so does the multi-plexing of these in the event loop.
* *
*/ */

View File

@ -19,15 +19,15 @@ package io.netty.channel.oio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelException; import io.netty.channel.ChannelException;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ThreadPerChannelEventLoopGroup; import io.netty.channel.ThreadPerChannelEventLoopGroup;
import io.netty.util.concurrent.EventExecutorGroup;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
/** /**
* {@link EventExecutorGroup} which is used to handle OIO {@link Channel}'s. Each {@link Channel} will be handled by its * {@link EventLoopGroup} which is used to handle OIO {@link Channel}'s. Each {@link Channel} will be handled by its
* own {@link EventLoop} to not block others. * own {@link EventLoop} to not block others.
*/ */
public class OioEventLoopGroup extends ThreadPerChannelEventLoopGroup { public class OioEventLoopGroup extends ThreadPerChannelEventLoopGroup {

View File

@ -189,10 +189,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
clientChannel.write(createTestBuf(2000)).sync(); clientChannel.write(createTestBuf(2000)).sync();
clientChannel.closeFuture().sync(); clientChannel.closeFuture().sync();
assertLog( assertLog("WRITE\nFLUSH\nCLOSE\n");
"WRITE\n" +
"FLUSH\n" +
"CLOSE\n");
} }
@Test @Test
@ -232,9 +229,6 @@ public class ReentrantChannelTest extends BaseChannelTest {
clientChannel.closeFuture().sync(); clientChannel.closeFuture().sync();
assertLog( assertLog("WRITE\nCLOSE\n");
"WRITE\n" +
"CLOSE\n");
} }
} }

View File

@ -153,7 +153,7 @@ public class LocalChannelTest {
@Test @Test
public void testServerCloseChannelSameEventLoop() throws Exception { public void testServerCloseChannelSameEventLoop() throws Exception {
LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID); LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID);
LocalEventLoopGroup group = new LocalEventLoopGroup(1); EventLoopGroup group = new DefaultEventLoopGroup(1);
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
ServerBootstrap sb = new ServerBootstrap() ServerBootstrap sb = new ServerBootstrap()
.group(group) .group(group)

View File

@ -101,7 +101,7 @@ public class LocalTransportThreadModelTest2 {
public final AtomicInteger count = new AtomicInteger(0); public final AtomicInteger count = new AtomicInteger(0);
public LocalHander(String name) { LocalHander(String name) {
this.name = name; this.name = name;
} }