diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java index dcdec3bb689..853e7e70f4d 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/SelectConnector.java @@ -228,6 +228,10 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector @Override protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment) { + Timeout.Task connectTimeout = _connectingChannels.remove(channel); + if (connectTimeout != null) + connectTimeout.cancel(); + if (attachment instanceof HttpDestination) ((HttpDestination)attachment).onConnectionFailed(ex); else diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java index 87d8530205d..d2457c10f25 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java @@ -141,27 +141,44 @@ public class StdErrLog implements Logger } else { - if ("ALL".equalsIgnoreCase(levelStr.trim())) + int level = getLevelId(levelStr); + if (level != (-1)) { - return LEVEL_ALL; - } - else if ("DEBUG".equalsIgnoreCase(levelStr.trim())) - { - return LEVEL_DEBUG; - } - else if ("INFO".equalsIgnoreCase(levelStr.trim())) - { - return LEVEL_INFO; - } - else if ("WARN".equalsIgnoreCase(levelStr.trim())) - { - return LEVEL_WARN; + return level; } } } // Default Logging Level - return LEVEL_INFO; + return getLevelId(props.getProperty("log.LEVEL", "INFO")); + } + + protected static int getLevelId(String levelName) + { + if (levelName == null) + { + return -1; + } + String levelStr = levelName.trim(); + if ("ALL".equalsIgnoreCase(levelStr)) + { + return LEVEL_ALL; + } + else if ("DEBUG".equalsIgnoreCase(levelStr)) + { + return LEVEL_DEBUG; + } + else if ("INFO".equalsIgnoreCase(levelStr)) + { + return LEVEL_INFO; + } + else if ("WARN".equalsIgnoreCase(levelStr)) + { + return LEVEL_WARN; + } + + System.err.println("Unknown StdErrLog level [" + levelStr + "], expecting only [ALL, DEBUG, INFO, WARN] as values."); + return -1; } /** diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java index 913acb06820..12b15ca0b1b 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/log/StdErrLogTest.java @@ -78,6 +78,19 @@ public class StdErrLogTest Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,StdErrLogTest.class.getName())); } + @Test + public void testGetLoggingLevel_Root() + { + Properties props = new Properties(); + props.setProperty("log.LEVEL","DEBUG"); + + // Default Levels + Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,null)); + Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"")); + Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty")); + Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,StdErrLogTest.class.getName())); + } + @Test public void testGetLoggingLevel_FQCN() { @@ -117,20 +130,21 @@ public class StdErrLogTest public void testGetLoggingLevel_MixedLevels() { Properties props = new Properties(); - props.setProperty("org.eclipse.jetty.util.LEVEL","DEBUG"); + props.setProperty("log.LEVEL","DEBUG"); + props.setProperty("org.eclipse.jetty.util.LEVEL","WARN"); props.setProperty("org.eclipse.jetty.util.ConcurrentHashMap.LEVEL","ALL"); // Default Levels - Assert.assertEquals(StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,null)); - Assert.assertEquals(StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,"")); - Assert.assertEquals(StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty")); - Assert.assertEquals(StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.server.ServerObject")); + Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,null)); + Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"")); + Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty")); + Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.server.ServerObject")); // Configured Level - Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,StdErrLogTest.class.getName())); - Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util.MagicUtil")); - Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util")); - Assert.assertEquals(StdErrLog.LEVEL_DEBUG,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util.resource.FileResource")); + Assert.assertEquals(StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,StdErrLogTest.class.getName())); + Assert.assertEquals(StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util.MagicUtil")); + Assert.assertEquals(StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util")); + Assert.assertEquals(StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util.resource.FileResource")); Assert.assertEquals(StdErrLog.LEVEL_ALL,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util.ConcurrentHashMap")); }