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:
parent
48f2e705d9
commit
d2614cfc01
@ -36,28 +36,6 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
|
||||
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
|
||||
public ByteBuf order(ByteOrder endianness) {
|
||||
leak.record();
|
||||
@ -704,6 +682,12 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
|
||||
return super.toString(index, length, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf capacity(int newCapacity) {
|
||||
leak.record();
|
||||
return super.capacity(newCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf retain() {
|
||||
leak.record();
|
||||
@ -729,8 +713,24 @@ final class AdvancedLeakAwareByteBuf extends WrappedByteBuf {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf capacity(int newCapacity) {
|
||||
public boolean release() {
|
||||
boolean deallocated = super.release();
|
||||
if (deallocated) {
|
||||
leak.close();
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import io.netty.buffer.Unpooled;
|
||||
public class DefaultFullHttpResponse extends DefaultHttpResponse implements FullHttpResponse {
|
||||
|
||||
private final ByteBuf content;
|
||||
|
||||
private final HttpHeaders trailingHeaders;
|
||||
private final boolean validateHeaders;
|
||||
|
||||
|
@ -92,6 +92,6 @@ public class DefaultHttpContent extends DefaultHttpObject implements HttpContent
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.simpleClassName(this) +
|
||||
"(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')';
|
||||
"(data: " + content() + ", decoderResult: " + getDecoderResult() + ')';
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
* @param httpVersion the HTTP version of the request
|
||||
* @param method the HTTP getMethod 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) {
|
||||
super(httpVersion, validateHeaders);
|
||||
@ -98,7 +98,7 @@ public class DefaultHttpRequest extends DefaultHttpMessage implements HttpReques
|
||||
buf.append(getDecoderResult());
|
||||
buf.append(')');
|
||||
buf.append(StringUtil.NEWLINE);
|
||||
buf.append(getMethod().toString());
|
||||
buf.append(getMethod());
|
||||
buf.append(' ');
|
||||
buf.append(getUri());
|
||||
buf.append(' ');
|
||||
|
@ -39,7 +39,7 @@ public class DefaultHttpResponse extends DefaultHttpMessage implements HttpRespo
|
||||
*
|
||||
* @param version the HTTP version 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) {
|
||||
super(version, validateHeaders);
|
||||
|
@ -17,8 +17,8 @@ package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.PrematureChannelClosureException;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@ -81,7 +81,8 @@ public final class HttpClientCodec extends ChannelHandlerAppender {
|
||||
public HttpClientCodec(
|
||||
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
|
||||
boolean validateHeaders) {
|
||||
add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
|
||||
add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders));
|
||||
add(new Encoder());
|
||||
this.failOnMissingResponse = failOnMissingResponse;
|
||||
}
|
||||
|
||||
|
@ -149,8 +149,8 @@ public class HttpMethod implements Comparable<HttpMethod> {
|
||||
}
|
||||
|
||||
for (int i = 0; i < name.length(); i ++) {
|
||||
if (Character.isISOControl(name.charAt(i)) ||
|
||||
Character.isWhitespace(name.charAt(i))) {
|
||||
char c = name.charAt(i);
|
||||
if (Character.isISOControl(c) || Character.isWhitespace(c)) {
|
||||
throw new IllegalArgumentException("invalid character in name");
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,7 @@ public class HttpVersion implements Comparable<HttpVersion> {
|
||||
this.minorVersion = minorVersion;
|
||||
text = protocolName + '/' + majorVersion + '.' + minorVersion;
|
||||
this.keepAliveDefault = keepAliveDefault;
|
||||
|
||||
if (bytes) {
|
||||
this.bytes = text.getBytes(CharsetUtil.US_ASCII);
|
||||
} else {
|
||||
|
@ -27,7 +27,6 @@ public interface HttpDataFactory {
|
||||
/**
|
||||
* To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException.
|
||||
* A value of -1 means no limitation (default).
|
||||
* @param max
|
||||
*/
|
||||
void setMaxLimit(long max);
|
||||
|
||||
|
@ -40,8 +40,7 @@ import java.net.URI;
|
||||
public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(WebSocketClientHandshaker08.class);
|
||||
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 MAGIC_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
|
@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
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.util.CharsetUtil;
|
||||
|
||||
@ -34,8 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
|
||||
*/
|
||||
public class WebSocketServerHandshaker07 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_07_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
|
@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
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.util.CharsetUtil;
|
||||
|
||||
@ -34,8 +35,7 @@ import static io.netty.handler.codec.http.HttpVersion.*;
|
||||
*/
|
||||
public class WebSocketServerHandshaker08 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_08_ACCEPT_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
|
@ -20,6 +20,7 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
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.util.CharsetUtil;
|
||||
|
||||
@ -32,8 +33,8 @@ import static io.netty.handler.codec.http.HttpVersion.*;
|
||||
* </p>
|
||||
*/
|
||||
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";
|
||||
|
||||
|
@ -19,10 +19,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class DefaultSpdyHeaders extends SpdyHeaders {
|
||||
|
@ -493,10 +493,10 @@ public class HttpResponseDecoderTest {
|
||||
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
|
||||
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.getStatus(), is(HttpResponseStatus.SWITCHING_PROTOCOLS));
|
||||
HttpContent content = (HttpContent) ch.readInbound();
|
||||
HttpContent content = ch.readInbound();
|
||||
assertThat(content.content().readableBytes(), is(16));
|
||||
content.release();
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.cors;
|
||||
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpRequest;
|
||||
import io.netty.handler.codec.http.DefaultHttpResponse;
|
||||
@ -239,12 +239,10 @@ public class CorsHandlerTest {
|
||||
return new DefaultFullHttpRequest(HTTP_1_1, method, "/info");
|
||||
}
|
||||
|
||||
private static class EchoHandler extends ChannelHandlerAdapter {
|
||||
|
||||
private static class EchoHandler extends SimpleChannelInboundHandler<Object> {
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
package io.netty.handler.codec.memcache.binary;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.PrematureChannelClosureException;
|
||||
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
|
||||
* will be passed up the pipeline and not queued up to the chunk size.
|
||||
*/
|
||||
public final class BinaryMemcacheClientCodec
|
||||
extends ChannelHandlerAppender {
|
||||
public final class BinaryMemcacheClientCodec extends ChannelHandlerAppender {
|
||||
|
||||
private final boolean failOnMissingResponse;
|
||||
private final AtomicLong requestResponseCounter = new AtomicLong();
|
||||
@ -65,7 +64,8 @@ public final class BinaryMemcacheClientCodec
|
||||
*/
|
||||
public BinaryMemcacheClientCodec(int decodeChunkSize, boolean failOnMissingResponse) {
|
||||
this.failOnMissingResponse = failOnMissingResponse;
|
||||
add(new Decoder(decodeChunkSize), new Encoder());
|
||||
add(new Decoder(decodeChunkSize));
|
||||
add(new Encoder());
|
||||
}
|
||||
|
||||
private final class Encoder extends BinaryMemcacheRequestEncoder {
|
||||
@ -82,7 +82,7 @@ public final class BinaryMemcacheClientCodec
|
||||
|
||||
private final class Decoder extends BinaryMemcacheResponseDecoder {
|
||||
|
||||
public Decoder(int chunkSize) {
|
||||
Decoder(int chunkSize) {
|
||||
super(chunkSize);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ public class BinaryMemcacheServerCodec extends ChannelHandlerAppender {
|
||||
}
|
||||
|
||||
public BinaryMemcacheServerCodec(int decodeChunkSize) {
|
||||
add(new BinaryMemcacheRequestDecoder(decodeChunkSize), new BinaryMemcacheResponseEncoder());
|
||||
add(new BinaryMemcacheRequestDecoder(decodeChunkSize));
|
||||
add(new BinaryMemcacheResponseEncoder());
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public abstract class Recycler<T> {
|
||||
// In the future, we might have different maxCapacity for different object types.
|
||||
// e.g. io.netty.recycler.maxCapacity.writeTask
|
||||
// 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) {
|
||||
// TODO: Some arbitrary large number - should adjust as we get more production experience.
|
||||
maxCapacity = 262144;
|
||||
@ -47,7 +47,7 @@ public abstract class Recycler<T> {
|
||||
|
||||
DEFAULT_MAX_CAPACITY = maxCapacity;
|
||||
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);
|
||||
|
@ -49,9 +49,7 @@ public final class Signal extends Error implements Constant<Signal> {
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
* @param name the name under which it is registered
|
||||
* Creates a new {@link Signal} with the specified {@code name}.
|
||||
*/
|
||||
private Signal(int id, String name) {
|
||||
this.id = id;
|
||||
|
@ -20,8 +20,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
|
||||
/**
|
||||
* Default {@link SingleThreadEventExecutor} implementation which just execute all submitted task in a
|
||||
* serial fashion
|
||||
*
|
||||
* serial fashion.
|
||||
*/
|
||||
public final class DefaultEventExecutor extends SingleThreadEventExecutor {
|
||||
|
||||
|
@ -41,8 +41,8 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class.getName() + ".SUCCESS");
|
||||
private static final Signal UNCANCELLABLE = Signal.valueOf(DefaultPromise.class.getName() + ".UNCANCELLABLE");
|
||||
private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class, "SUCCESS");
|
||||
private static final Signal UNCANCELLABLE = Signal.valueOf(DefaultPromise.class, "UNCANCELLABLE");
|
||||
private static final CauseHolder CANCELLATION_CAUSE_HOLDER = new CauseHolder(new CancellationException());
|
||||
|
||||
static {
|
||||
|
@ -16,8 +16,6 @@
|
||||
package io.netty.util.concurrent;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
<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);
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ public final class GlobalEventExecutor extends AbstractEventExecutor {
|
||||
try {
|
||||
task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
// Waken up.
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
@ -196,6 +196,7 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
|
||||
try {
|
||||
task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
// Waken up.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
|
||||
});
|
||||
|
||||
final Channel inboundChannel = ctx.channel();
|
||||
|
||||
b.group(inboundChannel.eventLoop())
|
||||
.channel(NioSocketChannel.class)
|
||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
|
||||
|
@ -41,4 +41,3 @@
|
||||
* mvn exec:exec -Pspdy-client
|
||||
*/
|
||||
package io.netty.example.spdy.client;
|
||||
|
||||
|
@ -38,7 +38,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
* <p>
|
||||
* 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
|
||||
* to https://localhost:8443/.
|
||||
* to to <a href="https://localhost:8443/">https://localhost:8443/</a>
|
||||
*/
|
||||
public class SpdyServer {
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -127,7 +127,7 @@ public class LoggingHandler extends ChannelHandlerAdapter {
|
||||
* Creates a new instance with the specified logger name and with hex dump
|
||||
* 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) {
|
||||
this(clazz, DEFAULT_LEVEL);
|
||||
@ -136,8 +136,8 @@ public class LoggingHandler extends ChannelHandlerAdapter {
|
||||
/**
|
||||
* Creates a new instance with the specified logger name.
|
||||
*
|
||||
* @param clazz the class type to generate the logger for.
|
||||
* @param level the log level.
|
||||
* @param clazz the class type to generate the logger for
|
||||
* @param level the log level
|
||||
*/
|
||||
public LoggingHandler(Class<?> clazz, LogLevel level) {
|
||||
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.
|
||||
*
|
||||
* @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) {
|
||||
this(name, DEFAULT_LEVEL);
|
||||
@ -164,8 +164,8 @@ public class LoggingHandler extends ChannelHandlerAdapter {
|
||||
/**
|
||||
* Creates a new instance with the specified logger name.
|
||||
*
|
||||
* @param name the name of the class to use for the logger.
|
||||
* @param level the log level.
|
||||
* @param name the name of the class to use for the logger
|
||||
* @param level the log level
|
||||
*/
|
||||
public LoggingHandler(String name, LogLevel level) {
|
||||
if (name == null) {
|
||||
|
@ -37,7 +37,7 @@
|
||||
* <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,
|
||||
* 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>
|
||||
*
|
||||
* <p>To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms
|
||||
|
@ -23,10 +23,10 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.DefaultEventLoopGroup;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
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.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -42,7 +42,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
private static final Random random = new Random();
|
||||
static final byte[] data = new byte[1048576];
|
||||
|
||||
private static EventLoopGroup group;
|
||||
private static EventExecutorGroup group;
|
||||
|
||||
static {
|
||||
random.nextBytes(data);
|
||||
@ -50,7 +50,7 @@ public class SocketEchoTest extends AbstractSocketTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void createGroup() {
|
||||
group = new DefaultEventLoopGroup(2);
|
||||
group = new DefaultEventExecutorGroup(2);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -21,8 +21,6 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.DefaultEventLoopGroup;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
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.ssl.SslHandler;
|
||||
import io.netty.testsuite.util.BogusSslContextFactory;
|
||||
import io.netty.util.concurrent.DefaultEventExecutorGroup;
|
||||
import io.netty.util.concurrent.EventExecutorGroup;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import org.junit.AfterClass;
|
||||
@ -47,11 +46,11 @@ import static org.junit.Assert.*;
|
||||
public class SocketStartTlsTest extends AbstractSocketTest {
|
||||
|
||||
private static final LogLevel LOG_LEVEL = LogLevel.TRACE;
|
||||
private static EventLoopGroup executor;
|
||||
private static EventExecutorGroup executor;
|
||||
|
||||
@BeforeClass
|
||||
public static void createExecutor() {
|
||||
executor = new DefaultEventLoopGroup(2);
|
||||
executor = new DefaultEventExecutorGroup(2);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -34,7 +34,7 @@ public class AutobahnServer {
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
try {
|
||||
ServerBootstrap b = new ServerBootstrap();
|
||||
|
@ -58,6 +58,8 @@ public class AutobahnServerHandler extends ChannelHandlerAdapter {
|
||||
handleHttpRequest(ctx, (FullHttpRequest) msg);
|
||||
} else if (msg instanceof WebSocketFrame) {
|
||||
handleWebSocketFrame(ctx, (WebSocketFrame) msg);
|
||||
} else {
|
||||
throw new IllegalStateException("unknown message: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* 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
|
||||
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
|
||||
|
@ -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,
|
||||
* 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 {
|
||||
|
||||
protected AbstractEventLoop() { }
|
||||
|
||||
protected AbstractEventLoop(EventLoopGroup parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public interface ChannelHandlerContext extends AttributeMap {
|
||||
/**
|
||||
* 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
|
||||
* {@link EventExecutor}.
|
||||
* {@link EventLoop}.
|
||||
*/
|
||||
boolean isRemoved();
|
||||
|
||||
|
@ -64,9 +64,8 @@ public final class ChannelHandlerInvokerUtil {
|
||||
ctx.handler().exceptionCaught(ctx, cause);
|
||||
} catch (Throwable t) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(
|
||||
"An exception was thrown by a user handler's " +
|
||||
"exceptionCaught() method while handling the following exception:", cause);
|
||||
logger.warn("An exception was thrown by a user handler's exceptionCaught() method:", t);
|
||||
logger.warn(".. and the cause of the exceptionCaught() was:", cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ public final class ChannelOption<T> extends AbstractConstant<ChannelOption<T>> {
|
||||
valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION");
|
||||
|
||||
/**
|
||||
* Create a new {@link ChannelOption} with the given name. The name needs to be
|
||||
* unique.
|
||||
* Creates a new {@link ChannelOption} with the specified unique {@code name}.
|
||||
*/
|
||||
private ChannelOption(int id, String name) {
|
||||
super(id, name);
|
||||
|
@ -16,7 +16,6 @@
|
||||
package io.netty.channel;
|
||||
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import io.netty.util.concurrent.EventExecutorGroup;
|
||||
import io.netty.util.concurrent.MultithreadEventExecutorGroup;
|
||||
import io.netty.util.internal.SystemPropertyUtil;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
@ -26,7 +25,7 @@ import java.util.concurrent.Executor;
|
||||
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.
|
||||
*/
|
||||
public abstract class MultithreadEventLoopGroup extends MultithreadEventExecutorGroup implements EventLoopGroup {
|
||||
|
@ -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() {
|
||||
try {
|
||||
|
@ -35,10 +35,6 @@ final class EmbeddedEventLoop extends AbstractEventLoop implements ChannelHandle
|
||||
|
||||
private final Queue<Runnable> tasks = new ArrayDeque<Runnable>(2);
|
||||
|
||||
protected EmbeddedEventLoop() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Runnable command) {
|
||||
if (command == null) {
|
||||
|
@ -43,7 +43,7 @@ import java.util.concurrent.Executor;
|
||||
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.
|
||||
*
|
||||
*/
|
||||
|
@ -19,15 +19,15 @@ package io.netty.channel.oio;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.ThreadPerChannelEventLoopGroup;
|
||||
import io.netty.util.concurrent.EventExecutorGroup;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
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.
|
||||
*/
|
||||
public class OioEventLoopGroup extends ThreadPerChannelEventLoopGroup {
|
||||
|
@ -189,10 +189,7 @@ public class ReentrantChannelTest extends BaseChannelTest {
|
||||
clientChannel.write(createTestBuf(2000)).sync();
|
||||
clientChannel.closeFuture().sync();
|
||||
|
||||
assertLog(
|
||||
"WRITE\n" +
|
||||
"FLUSH\n" +
|
||||
"CLOSE\n");
|
||||
assertLog("WRITE\nFLUSH\nCLOSE\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -232,9 +229,6 @@ public class ReentrantChannelTest extends BaseChannelTest {
|
||||
|
||||
clientChannel.closeFuture().sync();
|
||||
|
||||
assertLog(
|
||||
"WRITE\n" +
|
||||
"CLOSE\n");
|
||||
assertLog("WRITE\nCLOSE\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class LocalChannelTest {
|
||||
@Test
|
||||
public void testServerCloseChannelSameEventLoop() throws Exception {
|
||||
LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID);
|
||||
LocalEventLoopGroup group = new LocalEventLoopGroup(1);
|
||||
EventLoopGroup group = new DefaultEventLoopGroup(1);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
ServerBootstrap sb = new ServerBootstrap()
|
||||
.group(group)
|
||||
|
@ -101,7 +101,7 @@ public class LocalTransportThreadModelTest2 {
|
||||
|
||||
public final AtomicInteger count = new AtomicInteger(0);
|
||||
|
||||
public LocalHander(String name) {
|
||||
LocalHander(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user