Merge branch 'master' into suspend_feature
Conflicts: transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java
This commit is contained in:
commit
6a15f7f5ce
@ -87,7 +87,7 @@ public interface Cookie extends Comparable<Cookie> {
|
|||||||
void setComment(String comment);
|
void setComment(String comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum age of this {@link Cookie} in seconds.
|
* Returns the maximum age of this {@link Cookie} in seconds or {@link Long#MIN_VALUE} if unspecified
|
||||||
*
|
*
|
||||||
* @return The maximum age of this {@link Cookie}
|
* @return The maximum age of this {@link Cookie}
|
||||||
*/
|
*/
|
||||||
@ -97,7 +97,7 @@ public interface Cookie extends Comparable<Cookie> {
|
|||||||
* Sets the maximum age of this {@link Cookie} in seconds.
|
* Sets the maximum age of this {@link Cookie} in seconds.
|
||||||
* If an age of {@code 0} is specified, this {@link Cookie} will be
|
* If an age of {@code 0} is specified, this {@link Cookie} will be
|
||||||
* automatically removed by browser because it will expire immediately.
|
* automatically removed by browser because it will expire immediately.
|
||||||
* If {@code -1} is specified, this {@link Cookie} will be removed when the
|
* If {@link Long#MIN_VALUE} is specified, this {@link Cookie} will be removed when the
|
||||||
* browser is closed.
|
* browser is closed.
|
||||||
*
|
*
|
||||||
* @param maxAge The maximum age of this {@link Cookie} in seconds
|
* @param maxAge The maximum age of this {@link Cookie} in seconds
|
||||||
|
@ -35,7 +35,7 @@ public class DefaultCookie implements Cookie {
|
|||||||
private boolean discard;
|
private boolean discard;
|
||||||
private Set<Integer> ports = Collections.emptySet();
|
private Set<Integer> ports = Collections.emptySet();
|
||||||
private Set<Integer> unmodifiablePorts = ports;
|
private Set<Integer> unmodifiablePorts = ports;
|
||||||
private long maxAge = -1;
|
private long maxAge = Long.MIN_VALUE;
|
||||||
private int version;
|
private int version;
|
||||||
private boolean secure;
|
private boolean secure;
|
||||||
private boolean httpOnly;
|
private boolean httpOnly;
|
||||||
|
@ -54,7 +54,7 @@ public final class ServerCookieEncoder {
|
|||||||
|
|
||||||
add(buf, cookie.getName(), cookie.getValue());
|
add(buf, cookie.getName(), cookie.getValue());
|
||||||
|
|
||||||
if (cookie.getMaxAge() >= 0) {
|
if (cookie.getMaxAge() != Long.MIN_VALUE) {
|
||||||
if (cookie.getVersion() == 0) {
|
if (cookie.getVersion() == 0) {
|
||||||
addUnquoted(buf, CookieHeaderNames.EXPIRES,
|
addUnquoted(buf, CookieHeaderNames.EXPIRES,
|
||||||
new HttpHeaderDateFormat().format(
|
new HttpHeaderDateFormat().format(
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.codec.spdy;
|
package io.netty.handler.codec.spdy;
|
||||||
|
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
final class SpdySession {
|
final class SpdySession {
|
||||||
@ -177,7 +176,7 @@ final class SpdySession {
|
|||||||
private final AtomicInteger sendWindowSize;
|
private final AtomicInteger sendWindowSize;
|
||||||
private final AtomicInteger receiveWindowSize;
|
private final AtomicInteger receiveWindowSize;
|
||||||
private volatile int receiveWindowSizeLowerBound;
|
private volatile int receiveWindowSizeLowerBound;
|
||||||
private final BlockingQueue<Object> pendingWriteQueue = QueueFactory.createQueue();
|
private final Queue<Object> pendingWriteQueue = new ConcurrentLinkedQueue<Object>();
|
||||||
|
|
||||||
StreamState(
|
StreamState(
|
||||||
byte priority, boolean remoteSideClosed, boolean localSideClosed,
|
byte priority, boolean remoteSideClosed, boolean localSideClosed,
|
||||||
|
@ -31,6 +31,8 @@ public abstract class AbstractInternalLogger implements InternalLogger {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(InternalLogLevel level) {
|
public boolean isEnabled(InternalLogLevel level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case TRACE:
|
||||||
|
return isTraceEnabled();
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
return isDebugEnabled();
|
return isDebugEnabled();
|
||||||
case INFO:
|
case INFO:
|
||||||
@ -47,6 +49,9 @@ public abstract class AbstractInternalLogger implements InternalLogger {
|
|||||||
@Override
|
@Override
|
||||||
public void log(InternalLogLevel level, String msg, Throwable cause) {
|
public void log(InternalLogLevel level, String msg, Throwable cause) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case TRACE:
|
||||||
|
trace(msg, cause);
|
||||||
|
break;
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
debug(msg, cause);
|
debug(msg, cause);
|
||||||
break;
|
break;
|
||||||
@ -67,6 +72,9 @@ public abstract class AbstractInternalLogger implements InternalLogger {
|
|||||||
@Override
|
@Override
|
||||||
public void log(InternalLogLevel level, String msg) {
|
public void log(InternalLogLevel level, String msg) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case TRACE:
|
||||||
|
trace(msg);
|
||||||
|
break;
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
debug(msg);
|
debug(msg);
|
||||||
break;
|
break;
|
||||||
|
@ -31,6 +31,16 @@ class CommonsLogger extends AbstractInternalLogger {
|
|||||||
this.loggerName = loggerName;
|
this.loggerName = loggerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.trace(msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.debug(msg);
|
||||||
@ -61,6 +71,11 @@ class CommonsLogger extends AbstractInternalLogger {
|
|||||||
logger.info(msg, cause);
|
logger.info(msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return logger.isDebugEnabled();
|
return logger.isDebugEnabled();
|
||||||
|
@ -19,6 +19,10 @@ package io.netty.logging;
|
|||||||
* The log level that {@link InternalLogger} can log at.
|
* The log level that {@link InternalLogger} can log at.
|
||||||
*/
|
*/
|
||||||
public enum InternalLogLevel {
|
public enum InternalLogLevel {
|
||||||
|
/**
|
||||||
|
* 'TRACE' log level.
|
||||||
|
*/
|
||||||
|
TRACE,
|
||||||
/**
|
/**
|
||||||
* 'DEBUG' log level.
|
* 'DEBUG' log level.
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,11 @@ package io.netty.logging;
|
|||||||
* access this class outside of Netty.
|
* access this class outside of Netty.
|
||||||
*/
|
*/
|
||||||
public interface InternalLogger {
|
public interface InternalLogger {
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if a TRACE level message is logged.
|
||||||
|
*/
|
||||||
|
boolean isTraceEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if a DEBUG level message is logged.
|
* Returns {@code true} if a DEBUG level message is logged.
|
||||||
*/
|
*/
|
||||||
@ -45,6 +50,16 @@ public interface InternalLogger {
|
|||||||
*/
|
*/
|
||||||
boolean isEnabled(InternalLogLevel level);
|
boolean isEnabled(InternalLogLevel level);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a TRACE level message.
|
||||||
|
*/
|
||||||
|
void trace(String msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a TRACE level message.
|
||||||
|
*/
|
||||||
|
void trace(String msg, Throwable cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a DEBUG level message.
|
* Logs a DEBUG level message.
|
||||||
*/
|
*/
|
||||||
|
@ -66,6 +66,16 @@ public abstract class InternalLoggerFactory {
|
|||||||
final InternalLogger logger = getDefaultFactory().newInstance(name);
|
final InternalLogger logger = getDefaultFactory().newInstance(name);
|
||||||
return new InternalLogger() {
|
return new InternalLogger() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.trace(msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.debug(msg);
|
||||||
@ -96,6 +106,11 @@ public abstract class InternalLoggerFactory {
|
|||||||
logger.info(msg, cause);
|
logger.info(msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return logger.isDebugEnabled();
|
return logger.isDebugEnabled();
|
||||||
|
@ -29,6 +29,16 @@ class JBossLogger extends AbstractInternalLogger {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.trace(msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.debug(msg);
|
||||||
@ -59,6 +69,11 @@ class JBossLogger extends AbstractInternalLogger {
|
|||||||
logger.info(msg, cause);
|
logger.info(msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
|
@ -32,6 +32,16 @@ class JdkLogger extends AbstractInternalLogger {
|
|||||||
this.loggerName = loggerName;
|
this.loggerName = loggerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.logp(Level.FINEST, loggerName, null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.logp(Level.FINEST, loggerName, null, msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.logp(Level.FINE, loggerName, null, msg);
|
logger.logp(Level.FINE, loggerName, null, msg);
|
||||||
@ -62,6 +72,11 @@ class JdkLogger extends AbstractInternalLogger {
|
|||||||
logger.logp(Level.INFO, loggerName, null, msg, cause);
|
logger.logp(Level.INFO, loggerName, null, msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isLoggable(Level.FINEST);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return logger.isLoggable(Level.FINE);
|
return logger.isLoggable(Level.FINE);
|
||||||
|
@ -29,6 +29,16 @@ class Log4JLogger extends AbstractInternalLogger {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.trace(msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.debug(msg);
|
||||||
@ -59,6 +69,11 @@ class Log4JLogger extends AbstractInternalLogger {
|
|||||||
logger.info(msg, cause);
|
logger.info(msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return logger.isDebugEnabled();
|
return logger.isDebugEnabled();
|
||||||
|
@ -34,6 +34,16 @@ class OsgiLogger extends AbstractInternalLogger {
|
|||||||
prefix = "[" + name + "] ";
|
prefix = "[" + name + "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
// This logger doesn't have TRACE level
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
// This logger doesn't have TRACE level
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
LogService logService = parent.getLogService();
|
LogService logService = parent.getLogService();
|
||||||
@ -94,6 +104,11 @@ class OsgiLogger extends AbstractInternalLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,6 +28,16 @@ class Slf4JLogger extends AbstractInternalLogger {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg) {
|
||||||
|
logger.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trace(String msg, Throwable cause) {
|
||||||
|
logger.trace(msg, cause);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.debug(msg);
|
||||||
@ -58,6 +68,11 @@ class Slf4JLogger extends AbstractInternalLogger {
|
|||||||
logger.info(msg, cause);
|
logger.info(msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugEnabled() {
|
public boolean isDebugEnabled() {
|
||||||
return logger.isDebugEnabled();
|
return logger.isDebugEnabled();
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 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
|
|
||||||
* with the License. You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package io.netty.util.internal;
|
|
||||||
|
|
||||||
import io.netty.logging.InternalLogger;
|
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
|
||||||
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This factory should be used to create the "optimal" {@link BlockingQueue}
|
|
||||||
* instance for the running JVM.
|
|
||||||
*/
|
|
||||||
public final class QueueFactory {
|
|
||||||
|
|
||||||
private static final InternalLogger logger =
|
|
||||||
InternalLoggerFactory.getInstance(QueueFactory.class);
|
|
||||||
|
|
||||||
private static final boolean USE_LTQ;
|
|
||||||
|
|
||||||
static {
|
|
||||||
boolean useLTQ = false;
|
|
||||||
try {
|
|
||||||
if (DetectionUtil.hasUnsafe()) {
|
|
||||||
new LinkedTransferQueue<Object>();
|
|
||||||
useLTQ = true;
|
|
||||||
}
|
|
||||||
logger.debug(
|
|
||||||
"No access to the Unsafe - using " +
|
|
||||||
LegacyLinkedTransferQueue.class.getSimpleName() + " instead.");
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.debug(
|
|
||||||
"Failed to initialize a " + LinkedTransferQueue.class.getSimpleName() + " - " +
|
|
||||||
"using " + LegacyLinkedTransferQueue.class.getSimpleName() + " instead.", t);
|
|
||||||
}
|
|
||||||
|
|
||||||
USE_LTQ = useLTQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new unbound {@link BlockingQueue}
|
|
||||||
*
|
|
||||||
* @return queue the {@link BlockingQueue} implementation
|
|
||||||
*/
|
|
||||||
public static <T> BlockingQueue<T> createQueue() {
|
|
||||||
if (USE_LTQ) {
|
|
||||||
return new LinkedTransferQueue<T>();
|
|
||||||
} else {
|
|
||||||
return new LegacyLinkedTransferQueue<T>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private QueueFactory() {
|
|
||||||
// only use static methods!
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,6 +23,19 @@ import org.junit.Test;
|
|||||||
public class CommonsLoggerTest {
|
public class CommonsLoggerTest {
|
||||||
private static final Exception e = new Exception();
|
private static final Exception e = new Exception();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
org.apache.commons.logging.Log mock =
|
||||||
|
createStrictMock(org.apache.commons.logging.Log.class);
|
||||||
|
|
||||||
|
expect(mock.isTraceEnabled()).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new CommonsLogger(mock, "foo");
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
org.apache.commons.logging.Log mock =
|
org.apache.commons.logging.Log mock =
|
||||||
@ -75,6 +88,32 @@ public class CommonsLoggerTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
org.apache.commons.logging.Log mock =
|
||||||
|
createStrictMock(org.apache.commons.logging.Log.class);
|
||||||
|
|
||||||
|
mock.trace("a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new CommonsLogger(mock, "foo");
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
org.apache.commons.logging.Log mock =
|
||||||
|
createStrictMock(org.apache.commons.logging.Log.class);
|
||||||
|
|
||||||
|
mock.trace("a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new CommonsLogger(mock, "foo");
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
org.apache.commons.logging.Log mock =
|
org.apache.commons.logging.Log mock =
|
||||||
|
@ -54,6 +54,16 @@ public class InternalLoggerFactoryTest {
|
|||||||
assertNotSame(mock, InternalLoggerFactory.getInstance("mock"));
|
assertNotSame(mock, InternalLoggerFactory.getInstance("mock"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
expect(mock.isTraceEnabled()).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = InternalLoggerFactory.getInstance("mock");
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
expect(mock.isDebugEnabled()).andReturn(true);
|
expect(mock.isDebugEnabled()).andReturn(true);
|
||||||
@ -94,6 +104,26 @@ public class InternalLoggerFactoryTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
mock.trace("a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = InternalLoggerFactory.getInstance("mock");
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
mock.trace("a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = InternalLoggerFactory.getInstance("mock");
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
mock.debug("a");
|
mock.debug("a");
|
||||||
|
@ -23,6 +23,19 @@ import org.junit.Test;
|
|||||||
public class JBossLoggerTest {
|
public class JBossLoggerTest {
|
||||||
private static final Exception e = new Exception();
|
private static final Exception e = new Exception();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
org.jboss.logging.Logger mock =
|
||||||
|
createStrictMock(org.jboss.logging.Logger.class);
|
||||||
|
|
||||||
|
expect(mock.isTraceEnabled()).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JBossLogger(mock);
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
@ -73,6 +86,32 @@ public class JBossLoggerTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
org.jboss.logging.Logger mock =
|
||||||
|
createStrictMock(org.jboss.logging.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JBossLogger(mock);
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
org.jboss.logging.Logger mock =
|
||||||
|
createStrictMock(org.jboss.logging.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JBossLogger(mock);
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
org.jboss.logging.Logger mock =
|
org.jboss.logging.Logger mock =
|
||||||
|
@ -25,6 +25,20 @@ import org.junit.Test;
|
|||||||
public class JdkLoggerTest {
|
public class JdkLoggerTest {
|
||||||
private static final Exception e = new Exception();
|
private static final Exception e = new Exception();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
|
||||||
|
java.util.logging.Logger mock =
|
||||||
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
|
expect(mock.isLoggable(Level.FINEST)).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
|
|
||||||
@ -78,6 +92,32 @@ public class JdkLoggerTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
java.util.logging.Logger mock =
|
||||||
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
|
mock.logp(Level.FINEST, "foo", null, "a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
java.util.logging.Logger mock =
|
||||||
|
createStrictMock(java.util.logging.Logger.class);
|
||||||
|
|
||||||
|
mock.logp(Level.FINEST, "foo", null, "a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new JdkLogger(mock, "foo");
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
java.util.logging.Logger mock =
|
java.util.logging.Logger mock =
|
||||||
|
@ -23,6 +23,20 @@ import org.junit.Test;
|
|||||||
public class Log4JLoggerTest {
|
public class Log4JLoggerTest {
|
||||||
private static final Exception e = new Exception();
|
private static final Exception e = new Exception();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
|
||||||
|
org.apache.log4j.Logger mock =
|
||||||
|
createStrictMock(org.apache.log4j.Logger.class);
|
||||||
|
|
||||||
|
expect(mock.isTraceEnabled()).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Log4JLogger(mock);
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
|
|
||||||
@ -73,6 +87,32 @@ public class Log4JLoggerTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
org.apache.log4j.Logger mock =
|
||||||
|
createStrictMock(org.apache.log4j.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Log4JLogger(mock);
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
org.apache.log4j.Logger mock =
|
||||||
|
createStrictMock(org.apache.log4j.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Log4JLogger(mock);
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
org.apache.log4j.Logger mock =
|
org.apache.log4j.Logger mock =
|
||||||
|
@ -23,6 +23,19 @@ import org.junit.Test;
|
|||||||
public class Slf4JLoggerTest {
|
public class Slf4JLoggerTest {
|
||||||
private static final Exception e = new Exception();
|
private static final Exception e = new Exception();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsTraceEnabled() {
|
||||||
|
org.slf4j.Logger mock =
|
||||||
|
createStrictMock(org.slf4j.Logger.class);
|
||||||
|
|
||||||
|
expect(mock.isTraceEnabled()).andReturn(true);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Slf4JLogger(mock);
|
||||||
|
assertTrue(logger.isTraceEnabled());
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsDebugEnabled() {
|
public void testIsDebugEnabled() {
|
||||||
org.slf4j.Logger mock =
|
org.slf4j.Logger mock =
|
||||||
@ -75,6 +88,32 @@ public class Slf4JLoggerTest {
|
|||||||
verify(mock);
|
verify(mock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrace() {
|
||||||
|
org.slf4j.Logger mock =
|
||||||
|
createStrictMock(org.slf4j.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a");
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Slf4JLogger(mock);
|
||||||
|
logger.trace("a");
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTraceWithException() {
|
||||||
|
org.slf4j.Logger mock =
|
||||||
|
createStrictMock(org.slf4j.Logger.class);
|
||||||
|
|
||||||
|
mock.trace("a", e);
|
||||||
|
replay(mock);
|
||||||
|
|
||||||
|
InternalLogger logger = new Slf4JLogger(mock);
|
||||||
|
logger.trace("a", e);
|
||||||
|
verify(mock);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebug() {
|
public void testDebug() {
|
||||||
org.slf4j.Logger mock =
|
org.slf4j.Logger mock =
|
||||||
|
@ -18,6 +18,7 @@ package io.netty.handler.logging;
|
|||||||
import io.netty.logging.InternalLogLevel;
|
import io.netty.logging.InternalLogLevel;
|
||||||
|
|
||||||
public enum LogLevel {
|
public enum LogLevel {
|
||||||
|
TRACE(InternalLogLevel.TRACE),
|
||||||
DEBUG(InternalLogLevel.DEBUG),
|
DEBUG(InternalLogLevel.DEBUG),
|
||||||
INFO(InternalLogLevel.INFO),
|
INFO(InternalLogLevel.INFO),
|
||||||
WARN(InternalLogLevel.WARN),
|
WARN(InternalLogLevel.WARN),
|
||||||
|
@ -21,13 +21,14 @@ import io.netty.buffer.ChannelBuf;
|
|||||||
import io.netty.buffer.MessageBuf;
|
import io.netty.buffer.MessageBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.util.DefaultAttributeMap;
|
import io.netty.util.DefaultAttributeMap;
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@ -749,7 +750,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
|
|
||||||
static final class MessageBridge {
|
static final class MessageBridge {
|
||||||
final MessageBuf<Object> msgBuf = Unpooled.messageBuffer();
|
final MessageBuf<Object> msgBuf = Unpooled.messageBuffer();
|
||||||
final BlockingQueue<Object[]> exchangeBuf = QueueFactory.createQueue();
|
final Queue<Object[]> exchangeBuf = new ConcurrentLinkedQueue<Object[]>();
|
||||||
|
|
||||||
void fill() {
|
void fill() {
|
||||||
if (msgBuf.isEmpty()) {
|
if (msgBuf.isEmpty()) {
|
||||||
@ -774,7 +775,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
|
|
||||||
static final class ByteBridge {
|
static final class ByteBridge {
|
||||||
final ByteBuf byteBuf = Unpooled.buffer();
|
final ByteBuf byteBuf = Unpooled.buffer();
|
||||||
final BlockingQueue<ByteBuf> exchangeBuf = QueueFactory.createQueue();
|
final Queue<ByteBuf> exchangeBuf = new ConcurrentLinkedQueue<ByteBuf>();
|
||||||
|
|
||||||
void fill() {
|
void fill() {
|
||||||
if (!byteBuf.readable()) {
|
if (!byteBuf.readable()) {
|
||||||
|
@ -17,7 +17,6 @@ package io.netty.channel;
|
|||||||
|
|
||||||
import io.netty.logging.InternalLogger;
|
import io.netty.logging.InternalLogger;
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -32,6 +31,7 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.DelayQueue;
|
import java.util.concurrent.DelayQueue;
|
||||||
import java.util.concurrent.Delayed;
|
import java.util.concurrent.Delayed;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
@ -71,7 +71,7 @@ public abstract class SingleThreadEventExecutor extends AbstractExecutorService
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final BlockingQueue<Runnable> taskQueue = QueueFactory.createQueue();
|
private final BlockingQueue<Runnable> taskQueue = new LinkedBlockingQueue<Runnable>();
|
||||||
private final Thread thread;
|
private final Thread thread;
|
||||||
private final Object stateLock = new Object();
|
private final Object stateLock = new Object();
|
||||||
private final Semaphore threadLock = new Semaphore(0);
|
private final Semaphore threadLock = new Semaphore(0);
|
||||||
|
@ -22,7 +22,6 @@ import io.netty.channel.ChannelFuture;
|
|||||||
import io.netty.channel.EventExecutor;
|
import io.netty.channel.EventExecutor;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import io.netty.channel.SingleThreadEventExecutor;
|
import io.netty.channel.SingleThreadEventExecutor;
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -31,6 +30,7 @@ import java.util.Queue;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@ -45,7 +45,7 @@ public class OioEventLoop implements EventLoop {
|
|||||||
final ThreadFactory threadFactory;
|
final ThreadFactory threadFactory;
|
||||||
final Set<OioChildEventLoop> activeChildren = Collections.newSetFromMap(
|
final Set<OioChildEventLoop> activeChildren = Collections.newSetFromMap(
|
||||||
new ConcurrentHashMap<OioChildEventLoop, Boolean>());
|
new ConcurrentHashMap<OioChildEventLoop, Boolean>());
|
||||||
final Queue<OioChildEventLoop> idleChildren = QueueFactory.createQueue();
|
final Queue<OioChildEventLoop> idleChildren = new ConcurrentLinkedQueue<OioChildEventLoop>();
|
||||||
private final ChannelException tooManyChannels;
|
private final ChannelException tooManyChannels;
|
||||||
private final Unsafe unsafe = new Unsafe() {
|
private final Unsafe unsafe = new Unsafe() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,11 +32,11 @@ import io.netty.channel.ChannelOutboundMessageHandler;
|
|||||||
import io.netty.channel.DefaultEventExecutor;
|
import io.netty.channel.DefaultEventExecutor;
|
||||||
import io.netty.channel.EventExecutor;
|
import io.netty.channel.EventExecutor;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -337,8 +337,8 @@ public class LocalTransportThreadModelTest {
|
|||||||
|
|
||||||
private final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
|
private final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
|
||||||
|
|
||||||
private final Queue<String> inboundThreadNames = QueueFactory.createQueue();
|
private final Queue<String> inboundThreadNames = new ConcurrentLinkedQueue<String>();
|
||||||
private final Queue<String> outboundThreadNames = QueueFactory.createQueue();
|
private final Queue<String> outboundThreadNames = new ConcurrentLinkedQueue<String>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessageBuf<Object> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
|
public MessageBuf<Object> newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user