From 67bd321bfcf62a32deb658fd7619245e774606fa Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 30 Apr 2020 14:51:42 -0500 Subject: [PATCH 01/77] Issue #4830 - Enabling JMX on jetty-slf4j-impl Signed-off-by: Joakim Erdfelt --- .../src/main/java/module-info.java | 2 + .../eclipse/jetty/logging/JettyLogger.java | 38 +------- .../logging/JettyLoggerConfiguration.java | 74 +++------------ .../jetty/logging/JettyLoggerFactory.java | 77 ++++++++++++++-- .../logging/JettyLoggerFactoryMBean.java | 31 +++++++ .../jetty/logging/JettyLoggingJmx.java | 50 +++++++++++ .../logging/JettyLoggingServiceProvider.java | 2 + .../org/eclipse/jetty/logging/LevelUtils.java | 90 +++++++++++++++++++ .../jetty/logging/JettyLoggerTest.java | 2 +- .../eclipse/jetty/logging/JmxExperiment.java | 46 ++++++++++ 10 files changed, 305 insertions(+), 107 deletions(-) create mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java create mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java create mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java create mode 100644 jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java diff --git a/jetty-slf4j-impl/src/main/java/module-info.java b/jetty-slf4j-impl/src/main/java/module-info.java index 0bfb99cd437..3cfbbf20391 100644 --- a/jetty-slf4j-impl/src/main/java/module-info.java +++ b/jetty-slf4j-impl/src/main/java/module-info.java @@ -25,5 +25,7 @@ module org.eclipse.jetty.logging requires transitive org.slf4j; + requires static java.management; + provides SLF4JServiceProvider with JettyLoggingServiceProvider; } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java index 90e1a639b5b..54ab43069e8 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java @@ -247,7 +247,7 @@ public class JettyLogger implements LocationAwareLogger, Logger { long timestamp = System.currentTimeMillis(); String threadName = Thread.currentThread().getName(); - getAppender().emit(this, intToLevel(levelInt), timestamp, threadName, throwable, message, argArray); + getAppender().emit(this, LevelUtils.intToLevel(levelInt), timestamp, threadName, throwable, message, argArray); } } @@ -636,43 +636,9 @@ public class JettyLogger implements LocationAwareLogger, Logger getAppender().emit(this, level, timestamp, threadName, throwable, msg); } - public static Level intToLevel(int level) - { - if (level >= JettyLogger.OFF) - return Level.ERROR; - if (level >= Level.ERROR.toInt()) - return Level.ERROR; - if (level >= Level.WARN.toInt()) - return Level.WARN; - if (level >= Level.INFO.toInt()) - return Level.INFO; - if (level >= Level.DEBUG.toInt()) - return Level.DEBUG; - if (level >= Level.TRACE.toInt()) - return Level.TRACE; - return Level.TRACE; // everything else - } - - public static String levelToString(int level) - { - if (level >= JettyLogger.OFF) - return "OFF"; - if (level >= Level.ERROR.toInt()) - return "ERROR"; - if (level >= Level.WARN.toInt()) - return "WARN"; - if (level >= Level.INFO.toInt()) - return "INFO"; - if (level >= Level.DEBUG.toInt()) - return "DEBUG"; - if (level >= Level.TRACE.toInt()) - return "TRACE"; - return "OFF"; // everything else - } - @Override public String toString() { - return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, levelToString(level)); + return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, LevelUtils.levelToString(level)); } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index 2864430fee2..547e54e82f3 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -26,7 +26,6 @@ import java.security.PrivilegedAction; import java.util.Locale; import java.util.Properties; import java.util.TimeZone; -import java.util.function.Function; import org.slf4j.event.Level; @@ -82,7 +81,7 @@ public class JettyLoggerConfiguration startName = startName.substring(0, startName.length() - SUFFIX_STACKS.length()); } - Boolean hideStacks = walkParentLoggerNames(startName, (key) -> + Boolean hideStacks = JettyLoggerFactory.walkParentLoggerNames(startName, (key) -> { String stacksBool = properties.getProperty(key + SUFFIX_STACKS); if (stacksBool != null) @@ -124,12 +123,12 @@ public class JettyLoggerConfiguration startName = startName.substring(0, startName.length() - SUFFIX_LEVEL.length()); } - Integer level = walkParentLoggerNames(startName, (key) -> + Integer level = JettyLoggerFactory.walkParentLoggerNames(startName, (key) -> { - String levelStr = properties.getProperty(key + SUFFIX_LEVEL); - if (levelStr != null) + String levelStr1 = properties.getProperty(key + SUFFIX_LEVEL); + if (levelStr1 != null) { - return getLevelInt(key, levelStr); + return LevelUtils.getLevelInt(key, levelStr1); } return null; }); @@ -140,7 +139,7 @@ public class JettyLoggerConfiguration String levelStr = properties.getProperty("log" + SUFFIX_LEVEL); if (levelStr != null) { - level = getLevelInt("log", levelStr); + level = LevelUtils.getLevelInt("log", levelStr); } } @@ -193,6 +192,11 @@ public class JettyLoggerConfiguration }); } + public String getString(String key, String defValue) + { + return properties.getProperty(key, defValue); + } + public boolean getBoolean(String key, boolean defValue) { String val = properties.getProperty(key, Boolean.toString(defValue)); @@ -216,36 +220,6 @@ public class JettyLoggerConfiguration } } - private Integer getLevelInt(String levelSegment, String levelStr) - { - if (levelStr == null) - { - return null; - } - - String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); - switch (levelName) - { - case "ALL": - return JettyLogger.ALL; - case "TRACE": - return Level.TRACE.toInt(); - case "DEBUG": - return Level.DEBUG.toInt(); - case "INFO": - return Level.INFO.toInt(); - case "WARN": - return Level.WARN.toInt(); - case "ERROR": - return Level.ERROR.toInt(); - case "OFF": - return JettyLogger.OFF; - default: - System.err.println("Unknown JettyLogger/Slf4J Level [" + levelSegment + "]=[" + levelName + "], expecting only [ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF] as values."); - return null; - } - } - private URL getResource(ClassLoader loader, String resourceName) { if (loader == null) @@ -303,30 +277,4 @@ public class JettyLoggerConfiguration } return null; } - - private T walkParentLoggerNames(String startName, Function nameFunction) - { - String nameSegment = startName; - - // Checking with FQCN first, then each package segment from longest to shortest. - while ((nameSegment != null) && (nameSegment.length() > 0)) - { - T ret = nameFunction.apply(nameSegment); - if (ret != null) - return ret; - - // Trim and try again. - int idx = nameSegment.lastIndexOf('.'); - if (idx >= 0) - { - nameSegment = nameSegment.substring(0, idx); - } - else - { - nameSegment = null; - } - } - - return null; - } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index 83d39cf71c1..f607ada4790 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -22,16 +22,16 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; +import java.util.function.Function; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; -public class JettyLoggerFactory implements ILoggerFactory +public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBean { - private static final String ROOT_LOGGER_NAME = ""; private final JettyLoggerConfiguration configuration; private final JettyLogger rootLogger; - private ConcurrentMap loggerMap; + private final ConcurrentMap loggerMap; public JettyLoggerFactory(JettyLoggerConfiguration config) { @@ -41,9 +41,9 @@ public class JettyLoggerFactory implements ILoggerFactory StdErrAppender appender = new StdErrAppender(configuration); - rootLogger = new JettyLogger(this, ROOT_LOGGER_NAME, appender); - loggerMap.put(ROOT_LOGGER_NAME, rootLogger); - rootLogger.setLevel(configuration.getLevel(ROOT_LOGGER_NAME)); + rootLogger = new JettyLogger(this, Logger.ROOT_LOGGER_NAME, appender); + loggerMap.put(Logger.ROOT_LOGGER_NAME, rootLogger); + rootLogger.setLevel(configuration.getLevel(Logger.ROOT_LOGGER_NAME)); } /** @@ -54,7 +54,7 @@ public class JettyLoggerFactory implements ILoggerFactory */ public JettyLogger getJettyLogger(String name) { - if (name.equals(ROOT_LOGGER_NAME)) + if (name.equals(Logger.ROOT_LOGGER_NAME)) { return getRootLogger(); } @@ -179,4 +179,67 @@ public class JettyLoggerFactory implements ILoggerFactory return dense.toString(); } + + public static T walkParentLoggerNames(String startName, Function nameFunction) + { + String nameSegment = startName; + + // Checking with FQCN first, then each package segment from longest to shortest. + while ((nameSegment != null) && (nameSegment.length() > 0)) + { + T ret = nameFunction.apply(nameSegment); + if (ret != null) + return ret; + + // Trim and try again. + int idx = nameSegment.lastIndexOf('.'); + if (idx >= 0) + { + nameSegment = nameSegment.substring(0, idx); + } + else + { + nameSegment = null; + } + } + + return null; + } + + @Override + public String[] getLoggerNames() + { + return loggerMap.keySet().toArray(new String[0]); + } + + @Override + public int getLoggerCount() + { + return loggerMap.size(); + } + + @Override + public String getLoggerLevel(String loggerName) + { + return walkParentLoggerNames(loggerName, (key) -> + { + JettyLogger logger = loggerMap.get(key); + if (key != null) + { + return LevelUtils.levelToString(logger.getLevel()); + } + return null; + }); + } + + @Override + public void setLoggerLevel(String loggerName, String levelName) + { + Integer levelInt = LevelUtils.getLevelInt(loggerName, levelName); + if (levelInt != null) + { + JettyLogger jettyLogger = getJettyLogger(loggerName); + jettyLogger.setLevel(levelInt); + } + } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java new file mode 100644 index 00000000000..59c2da9f0a2 --- /dev/null +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java @@ -0,0 +1,31 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +@SuppressWarnings("unused") +public interface JettyLoggerFactoryMBean +{ + int getLoggerCount(); + + String[] getLoggerNames(); + + void setLoggerLevel(String loggerName, String levelName); + + String getLoggerLevel(String loggerName); +} diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java new file mode 100644 index 00000000000..f7aeac3a80e --- /dev/null +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java @@ -0,0 +1,50 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +import java.lang.management.ManagementFactory; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +public class JettyLoggingJmx +{ + public static void initialize(JettyLoggerConfiguration config, JettyLoggerFactory loggerFactory) + { + if (!config.getBoolean("org.eclipse.jetty.logging.jmx", false)) + { + loggerFactory.getJettyLogger(JettyLoggingJmx.class.getName()).debug("JMX not enabled"); + return; + } + + try + { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + String contextName = config.getString("org.eclipse.jetty.logging.jmx.contextName", "default"); + + ObjectName objName = new ObjectName(JettyLoggerFactory.class.getName() + ":name=" + contextName); + mbs.registerMBean(loggerFactory, objName); + } + catch (Throwable cause) + { + JettyLogger logger = loggerFactory.getJettyLogger(JettyLoggingJmx.class.getName()); + logger.warn("java.management not available."); + logger.debug("java.management is not available", cause); + } + } +} diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java index 01ad473162a..61e7ec47f40 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java @@ -45,6 +45,8 @@ public class JettyLoggingServiceProvider implements SLF4JServiceProvider loggerFactory = new JettyLoggerFactory(config); markerFactory = new BasicMarkerFactory(); mdcAdapter = new NOPMDCAdapter(); // TODO: Provide Jetty Implementation? + + JettyLoggingJmx.initialize(config, loggerFactory); } public JettyLoggerFactory getJettyLoggerFactory() diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java new file mode 100644 index 00000000000..e78abf4817b --- /dev/null +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java @@ -0,0 +1,90 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +import java.util.Locale; + +import org.slf4j.event.Level; + +public class LevelUtils +{ + public static Integer getLevelInt(String loggerName, String levelStr) + { + if (levelStr == null) + { + return null; + } + + String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); + switch (levelName) + { + case "ALL": + return JettyLogger.ALL; + case "TRACE": + return Level.TRACE.toInt(); + case "DEBUG": + return Level.DEBUG.toInt(); + case "INFO": + return Level.INFO.toInt(); + case "WARN": + return Level.WARN.toInt(); + case "ERROR": + return Level.ERROR.toInt(); + case "OFF": + return JettyLogger.OFF; + default: + System.err.println("Unknown JettyLogger/Slf4J Level [" + loggerName + "]=[" + levelName + "], expecting only [ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF] as values."); + return null; + } + } + + public static Level intToLevel(int level) + { + if (level >= JettyLogger.OFF) + return Level.ERROR; + if (level >= Level.ERROR.toInt()) + return Level.ERROR; + if (level >= Level.WARN.toInt()) + return Level.WARN; + if (level >= Level.INFO.toInt()) + return Level.INFO; + if (level >= Level.DEBUG.toInt()) + return Level.DEBUG; + if (level >= Level.TRACE.toInt()) + return Level.TRACE; + return Level.TRACE; // everything else + } + + public static String levelToString(int level) + { + if (level >= JettyLogger.OFF) + return "OFF"; + if (level >= Level.ERROR.toInt()) + return "ERROR"; + if (level >= Level.WARN.toInt()) + return "WARN"; + if (level >= Level.INFO.toInt()) + return "INFO"; + if (level >= Level.DEBUG.toInt()) + return "DEBUG"; + if (level >= Level.TRACE.toInt()) + return "TRACE"; + return "OFF"; // everything else + } +} diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java index 86b6fd6db8d..58b0c660573 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java @@ -609,6 +609,6 @@ public class JettyLoggerTest private void assertLevel(JettyLogger log, Level expectedLevel) { assertThat("Log[" + log.getName() + "].level", - JettyLogger.levelToString(log.getLevel()), is(expectedLevel.toString())); + LevelUtils.levelToString(log.getLevel()), is(expectedLevel.toString())); } } diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java new file mode 100644 index 00000000000..26e12297d23 --- /dev/null +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java @@ -0,0 +1,46 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +import java.util.Properties; + +public class JmxExperiment +{ + public static void main(String[] args) + { + try + { + Properties props = new Properties(); + props.setProperty("org.eclipse.jetty.logging.jmx", "true"); + props.setProperty("org.eclipse.jetty.logging.jmx.contextName", "Main"); + props.setProperty("org.eclipse.jetty.logging.LEVEL", "DEBUG"); + JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); + JettyLoggerFactory loggerFactory = new JettyLoggerFactory(config); + + JettyLoggingJmx.initialize(config, loggerFactory); + + loggerFactory.getJettyLogger(JmxExperiment.class.getName()).info("Waiting for key-press"); + System.in.read(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} From c144358f421a774ab1f34fbae1a173ea453baa60 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 1 May 2020 08:34:13 -0500 Subject: [PATCH 02/77] Issue #4830 - Adding jmx entries for logging-jetty module Signed-off-by: Joakim Erdfelt --- .../modules/logging/jetty/resources/jetty-logging.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties b/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties index d0fdf6c5bd5..a9c6aeb60ab 100644 --- a/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties +++ b/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties @@ -4,5 +4,9 @@ org.eclipse.jetty.LEVEL=INFO #com.example.LEVEL=INFO ## Configure a level for specific logger #com.example.MyComponent.LEVEL=INFO +## Enable JMX management of Jetty Logging +# org.eclipse.jetty.logging.jmx=true +## Configure JMX Context Name +# org.eclipse.jetty.logging.jmx.contextName=JettyServer ## Hide stacks traces in an arbitrary logger tree #com.example.STACKS=false From d2399205ff7d7820c6757d0f9f4acec9bea79412 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 3 May 2020 10:06:41 +0200 Subject: [PATCH 03/77] Issue #4830 - Add JMX to new Jetty 10 jetty-slf4j-impl. Alternative implementation that adds JMX support for jetty-slf4j-impl. This version modifies MBeanContainer to be aware of @MXBean annotations and *MBean and *MXBean interfaces, so it does not require a dependency on jetty-jmx nor on java.management. Signed-off-by: Simone Bordet --- examples/embedded/pom.xml | 2 +- .../eclipse/jetty/embedded/Http2Server.java | 3 + .../jetty/resources/jetty-logging.properties | 4 +- .../org/eclipse/jetty/jmx/MBeanContainer.java | 55 ++++++- jetty-slf4j-impl/pom.xml | 31 +++- .../src/main/java/module-info.java | 2 - .../eclipse/jetty/logging/JettyLogger.java | 74 +++++++++- .../logging/JettyLoggerConfiguration.java | 52 ++----- .../jetty/logging/JettyLoggerFactory.java | 134 ++++-------------- .../logging/JettyLoggerFactoryMBean.java | 3 +- .../jetty/logging/JettyLoggingJmx.java | 50 ------- .../logging/JettyLoggingServiceProvider.java | 2 - .../org/eclipse/jetty/logging/LevelUtils.java | 73 +++------- .../org/eclipse/jetty/logging/JMXTest.java | 74 ++++++++++ .../jetty/logging/JettyLoggerTest.java | 6 +- .../eclipse/jetty/logging/JmxExperiment.java | 46 ------ 16 files changed, 289 insertions(+), 322 deletions(-) delete mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java create mode 100644 jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java delete mode 100644 jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index 22bc490c200..558be37b6e6 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -22,7 +22,7 @@ org.eclipse.jetty jetty-slf4j-impl - test + runtime org.eclipse.jetty diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java index 22dfd38702a..c18551268d1 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/Http2Server.java @@ -61,6 +61,7 @@ import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlets.PushCacheFilter; import org.eclipse.jetty.util.resource.PathResource; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.slf4j.LoggerFactory; public class Http2Server { @@ -74,6 +75,8 @@ public class Http2Server ManagementFactory.getPlatformMBeanServer()); server.addBean(mbContainer); + server.addBean(LoggerFactory.getILoggerFactory()); + ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); Path docroot = Paths.get("src/main/resources/docroot"); if (!Files.exists(docroot)) diff --git a/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties b/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties index a9c6aeb60ab..fba91898dc4 100644 --- a/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties +++ b/jetty-home/src/main/resources/modules/logging/jetty/resources/jetty-logging.properties @@ -4,9 +4,7 @@ org.eclipse.jetty.LEVEL=INFO #com.example.LEVEL=INFO ## Configure a level for specific logger #com.example.MyComponent.LEVEL=INFO -## Enable JMX management of Jetty Logging -# org.eclipse.jetty.logging.jmx=true ## Configure JMX Context Name -# org.eclipse.jetty.logging.jmx.contextName=JettyServer +# org.eclipse.jetty.logging.jmx.context=JettyServer ## Hide stacks traces in an arbitrary logger tree #com.example.STACKS=false diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java index f8db4c44bd2..b6ed4b2a90c 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java @@ -30,10 +30,12 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import javax.management.DynamicMBean; import javax.management.InstanceNotFoundException; import javax.management.MBeanInfo; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; +import javax.management.MXBean; import javax.management.ObjectName; import javax.management.modelmbean.ModelMBean; @@ -60,7 +62,7 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De private final MBeanServer _mbeanServer; private final boolean _useCacheForOtherClassLoaders; - private final ConcurrentMap _metaData = new ConcurrentHashMap<>(); + private final ConcurrentMap, MetaData> _metaData = new ConcurrentHashMap<>(); private final ConcurrentMap _beans = new ConcurrentHashMap<>(); private final ConcurrentMap _mbeans = new ConcurrentHashMap<>(); private String _domain = null; @@ -151,7 +153,26 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De { if (o == null) return null; - Object mbean = findMetaData(container, o.getClass()).newInstance(o); + if (o instanceof DynamicMBean) + return o; + Class klass = o.getClass(); + while (klass != Object.class) + { + MXBean mxbean = klass.getAnnotation(MXBean.class); + if (mxbean != null && mxbean.value()) + return o; + String mbeanName = klass.getName() + "MBean"; + String mxbeanName = klass.getName() + "MXBean"; + Class[] interfaces = klass.getInterfaces(); + for (Class type : interfaces) + { + String name = type.getName(); + if (name.equals(mbeanName) || name.equals(mxbeanName)) + return o; + } + klass = klass.getSuperclass(); + } + Object mbean = findMetaData(container, klass).newInstance(o); if (mbean instanceof ObjectMBean) ((ObjectMBean)mbean).setMBeanContainer(container); if (LOG.isDebugEnabled()) @@ -338,7 +359,9 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De StringBuilder buf = new StringBuilder(); - String context = (mbean instanceof ObjectMBean) ? makeName(((ObjectMBean)mbean).getObjectContextBasis()) : null; + String context = (mbean instanceof ObjectMBean) + ? makeName(((ObjectMBean)mbean).getObjectContextBasis()) + : makeName(reflectContextBasis(mbean)); if (context == null && parentObjectName != null) context = parentObjectName.getKeyProperty("context"); @@ -347,7 +370,9 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De buf.append("type=").append(type); - String name = (mbean instanceof ObjectMBean) ? makeName(((ObjectMBean)mbean).getObjectNameBasis()) : context; + String name = (mbean instanceof ObjectMBean) + ? makeName(((ObjectMBean)mbean).getObjectNameBasis()) + : makeName(reflectNameBasis(mbean)); if (name != null && name.length() > 1) buf.append(",").append("name=").append(name); @@ -394,6 +419,28 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De } } + private String reflectContextBasis(Object mbean) + { + return reflectBasis(mbean, "jmxContext"); + } + + private String reflectNameBasis(Object mbean) + { + return reflectBasis(mbean, "jmxName"); + } + + private String reflectBasis(Object mbean, String methodName) + { + try + { + return (String)mbean.getClass().getMethod(methodName).invoke(mbean); + } + catch (Throwable x) + { + return null; + } + } + /** * @param basis name to strip of special characters. * @return normalized name diff --git a/jetty-slf4j-impl/pom.xml b/jetty-slf4j-impl/pom.xml index be399ee79a2..61d8e2fb1ce 100644 --- a/jetty-slf4j-impl/pom.xml +++ b/jetty-slf4j-impl/pom.xml @@ -4,16 +4,35 @@ jetty-project 10.0.0-SNAPSHOT + 4.0.0 jetty-slf4j-impl Jetty :: Slf4j Implementation Slf4j Logging Implementation based on Jetty's older StdErrLog - http://www.eclipse.org/jetty + ${project.groupId}.logging + + + maven-compiler-plugin + + + --add-modules + java.management + + + + + maven-surefire-plugin + + + @{argLine} ${jetty.surefire.argLine} --add-reads org.eclipse.jetty.logging=java.management + + + org.apache.felix maven-bundle-plugin @@ -29,15 +48,17 @@ + + + org.slf4j + slf4j-api + + org.eclipse.jetty.toolchain jetty-test-helper test - - org.slf4j - slf4j-api - diff --git a/jetty-slf4j-impl/src/main/java/module-info.java b/jetty-slf4j-impl/src/main/java/module-info.java index 3cfbbf20391..0bfb99cd437 100644 --- a/jetty-slf4j-impl/src/main/java/module-info.java +++ b/jetty-slf4j-impl/src/main/java/module-info.java @@ -25,7 +25,5 @@ module org.eclipse.jetty.logging requires transitive org.slf4j; - requires static java.management; - provides SLF4JServiceProvider with JettyLoggingServiceProvider; } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java index 54ab43069e8..e7eaff98155 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java @@ -32,18 +32,18 @@ public class JettyLogger implements LocationAwareLogger, Logger /** * The Level to set if you want this logger to be "OFF" */ - public static final int OFF = 999; + static final int OFF = 999; /** * The Level to set if you want this logger to show all events from all levels. */ - public static final int ALL = -1; + static final int ALL = Level.TRACE.toInt(); private final JettyLoggerFactory factory; private final String name; private final String condensedName; private final JettyAppender appender; private int level; - private boolean hideStacks = false; + private boolean hideStacks; public JettyLogger(JettyLoggerFactory factory, String name, JettyAppender appender) { @@ -54,12 +54,72 @@ public class JettyLogger implements LocationAwareLogger, Logger { this.factory = factory; this.name = name; - this.condensedName = JettyLoggerFactory.condensePackageString(name); + this.condensedName = condensePackageString(name); this.appender = appender; this.level = level; this.hideStacks = hideStacks; } + /** + * Condenses a classname by stripping down the package name to just the first character of each package name + * segment.Configured + * + *
+     * Examples:
+     * "org.eclipse.jetty.test.FooTest"           = "oejt.FooTest"
+     * "org.eclipse.jetty.server.logging.LogTest" = "orjsl.LogTest"
+     * 
+ * + * @param classname the fully qualified class name + * @return the condensed name + */ + private static String condensePackageString(String classname) + { + if (classname == null || classname.isEmpty()) + return ""; + + int rawLen = classname.length(); + StringBuilder dense = new StringBuilder(rawLen); + boolean foundStart = false; + boolean hasPackage = false; + int startIdx = -1; + int endIdx = -1; + for (int i = 0; i < rawLen; i++) + { + char c = classname.charAt(i); + if (!foundStart) + { + foundStart = Character.isJavaIdentifierStart(c); + if (foundStart) + { + if (startIdx >= 0) + { + dense.append(classname.charAt(startIdx)); + hasPackage = true; + } + startIdx = i; + } + } + + if (foundStart) + { + if (Character.isJavaIdentifierPart(c)) + endIdx = i; + else + foundStart = false; + } + } + // append remaining from startIdx + if ((startIdx >= 0) && (endIdx >= startIdx)) + { + if (hasPackage) + dense.append('.'); + dense.append(classname, startIdx, endIdx + 1); + } + + return dense.toString(); + } + @Override public void debug(String msg) { @@ -285,7 +345,7 @@ public class JettyLogger implements LocationAwareLogger, Logger this.level = lvlInt; // apply setLevel to children too. - factory.walkChildLoggers(this.getName(), (logger) -> logger.setLevel(lvlInt)); + factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setLevel(lvlInt)); } @Override @@ -402,7 +462,7 @@ public class JettyLogger implements LocationAwareLogger, Logger this.hideStacks = hideStacks; // apply setHideStacks to children too. - factory.walkChildLoggers(this.getName(), (logger) -> logger.setHideStacks(hideStacks)); + factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setHideStacks(hideStacks)); } @Override @@ -639,6 +699,6 @@ public class JettyLogger implements LocationAwareLogger, Logger @Override public String toString() { - return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, LevelUtils.levelToString(level)); + return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, LevelUtils.intToLevel(level)); } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index 547e54e82f3..ba00a0abadf 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -77,29 +77,22 @@ public class JettyLoggerConfiguration // strip ".STACKS" suffix (if present) if (startName.endsWith(SUFFIX_STACKS)) - { startName = startName.substring(0, startName.length() - SUFFIX_STACKS.length()); - } - Boolean hideStacks = JettyLoggerFactory.walkParentLoggerNames(startName, (key) -> + Boolean hideStacks = JettyLoggerFactory.walkParentLoggerNames(startName, key -> { String stacksBool = properties.getProperty(key + SUFFIX_STACKS); if (stacksBool != null) - { return Boolean.parseBoolean(stacksBool); - } return null; }); - if (hideStacks != null) - return hideStacks; - - return DEFAULT_HIDE_STACKS; + return hideStacks != null ? hideStacks : DEFAULT_HIDE_STACKS; } /** - * Get the Logging Level for the provided log name. Using the FQCN first, then each package segment from longest to - * shortest. + *

Returns the Logging Level for the provided log name.

+ *

Uses the FQCN first, then each package segment from longest to shortest.

* * @param name the name to get log for * @return the logging level int @@ -111,42 +104,30 @@ public class JettyLoggerConfiguration String startName = name != null ? name : ""; - // strip trailing dot + // Strip trailing dot. while (startName.endsWith(".")) { startName = startName.substring(0, startName.length() - 1); } - // strip ".LEVEL" suffix (if present) + // Strip ".LEVEL" suffix (if present). if (startName.endsWith(SUFFIX_LEVEL)) - { startName = startName.substring(0, startName.length() - SUFFIX_LEVEL.length()); - } - Integer level = JettyLoggerFactory.walkParentLoggerNames(startName, (key) -> + Integer level = JettyLoggerFactory.walkParentLoggerNames(startName, key -> { - String levelStr1 = properties.getProperty(key + SUFFIX_LEVEL); - if (levelStr1 != null) - { - return LevelUtils.getLevelInt(key, levelStr1); - } - return null; + String levelStr = properties.getProperty(key + SUFFIX_LEVEL); + return LevelUtils.getLevelInt(levelStr); }); if (level == null) { - // try legacy root logging config + // Try legacy root logging config. String levelStr = properties.getProperty("log" + SUFFIX_LEVEL); - if (levelStr != null) - { - level = LevelUtils.getLevelInt("log", levelStr); - } + level = LevelUtils.getLevelInt(levelStr); } - if (level != null) - return level; - - return DEFAULT_LEVEL; + return level != null ? level : DEFAULT_LEVEL; } public TimeZone getTimeZone(String key) @@ -154,7 +135,6 @@ public class JettyLoggerConfiguration String zoneIdStr = properties.getProperty(key); if (zoneIdStr == null) return null; - return TimeZone.getTimeZone(zoneIdStr); } @@ -207,9 +187,7 @@ public class JettyLoggerConfiguration { String val = properties.getProperty(key, Integer.toString(defValue)); if (val == null) - { return defValue; - } try { return Integer.parseInt(val); @@ -223,13 +201,9 @@ public class JettyLoggerConfiguration private URL getResource(ClassLoader loader, String resourceName) { if (loader == null) - { return ClassLoader.getSystemResource(resourceName); - } else - { return loader.getResource(resourceName); - } } /** @@ -260,9 +234,7 @@ public class JettyLoggerConfiguration { URL propsUrl = getResource(loader, resourceName); if (propsUrl == null) - { return null; - } try (InputStream in = propsUrl.openStream()) { diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index f607ada4790..e313cbe83b5 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.logging; import java.util.Objects; +import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; @@ -46,6 +47,13 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe rootLogger.setLevel(configuration.getLevel(Logger.ROOT_LOGGER_NAME)); } + @SuppressWarnings("unused") + public String jmxContext() + { + // Used to build the ObjectName. + return configuration.getString("org.eclipse.jetty.logging.jmx.context", null); + } + /** * Get a {@link JettyLogger} instance, creating if not yet existing. * @@ -55,10 +63,7 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe public JettyLogger getJettyLogger(String name) { if (name.equals(Logger.ROOT_LOGGER_NAME)) - { return getRootLogger(); - } - return loggerMap.computeIfAbsent(name, this::createLogger); } @@ -74,118 +79,45 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe return getJettyLogger(name); } - protected void walkChildLoggers(String parentName, Consumer childConsumer) + void walkChildrenLoggers(String parentName, Consumer childConsumer) { String prefix = parentName; if (parentName.length() > 0 && !prefix.endsWith(".")) - { prefix += "."; - } for (JettyLogger logger : loggerMap.values()) { + // Skip self. if (logger.getName().equals(parentName)) - { - // skip self continue; - } - // is child, and is not itself + // It is a child, and is not itself. if (logger.getName().startsWith(prefix)) - { childConsumer.accept(logger); - } } } - public JettyLogger getRootLogger() + JettyLogger getRootLogger() { return rootLogger; } private JettyLogger createLogger(String name) { - // or is that handled by slf4j itself? JettyAppender appender = rootLogger.getAppender(); int level = this.configuration.getLevel(name); boolean hideStacks = this.configuration.getHideStacks(name); return new JettyLogger(this, name, appender, level, hideStacks); } - /** - * Condenses a classname by stripping down the package name to just the first character of each package name - * segment.Configured - * - *
-     * Examples:
-     * "org.eclipse.jetty.test.FooTest"           = "oejt.FooTest"
-     * "org.eclipse.jetty.server.logging.LogTest" = "orjsl.LogTest"
-     * 
- * - * @param classname the fully qualified class name - * @return the condensed name - */ - protected static String condensePackageString(String classname) + static T walkParentLoggerNames(String startName, Function nameFunction) { - if (classname == null || classname.isEmpty()) - { - return ""; - } - - int rawLen = classname.length(); - StringBuilder dense = new StringBuilder(rawLen); - boolean foundStart = false; - boolean hasPackage = false; - int startIdx = -1; - int endIdx = -1; - for (int i = 0; i < rawLen; i++) - { - char c = classname.charAt(i); - if (!foundStart) - { - foundStart = Character.isJavaIdentifierStart(c); - if (foundStart) - { - if (startIdx >= 0) - { - dense.append(classname.charAt(startIdx)); - hasPackage = true; - } - startIdx = i; - } - } - - if (foundStart) - { - if (!Character.isJavaIdentifierPart(c)) - { - foundStart = false; - } - else - { - endIdx = i; - } - } - } - // append remaining from startIdx - if ((startIdx >= 0) && (endIdx >= startIdx)) - { - if (hasPackage) - { - dense.append('.'); - } - dense.append(classname, startIdx, endIdx + 1); - } - - return dense.toString(); - } - - public static T walkParentLoggerNames(String startName, Function nameFunction) - { - String nameSegment = startName; + if (startName == null) + return null; // Checking with FQCN first, then each package segment from longest to shortest. - while ((nameSegment != null) && (nameSegment.length() > 0)) + String nameSegment = startName; + while (nameSegment.length() > 0) { T ret = nameFunction.apply(nameSegment); if (ret != null) @@ -194,22 +126,18 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe // Trim and try again. int idx = nameSegment.lastIndexOf('.'); if (idx >= 0) - { nameSegment = nameSegment.substring(0, idx); - } else - { - nameSegment = null; - } + break; } - return null; } @Override public String[] getLoggerNames() { - return loggerMap.keySet().toArray(new String[0]); + TreeSet names = new TreeSet<>(loggerMap.keySet()); + return names.toArray(new String[0]); } @Override @@ -221,25 +149,23 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe @Override public String getLoggerLevel(String loggerName) { - return walkParentLoggerNames(loggerName, (key) -> + return walkParentLoggerNames(loggerName, key -> { JettyLogger logger = loggerMap.get(key); - if (key != null) - { - return LevelUtils.levelToString(logger.getLevel()); - } + if (logger != null) + return LevelUtils.intToLevel(logger.getLevel()).toString(); return null; }); } @Override - public void setLoggerLevel(String loggerName, String levelName) + public boolean setLoggerLevel(String loggerName, String levelName) { - Integer levelInt = LevelUtils.getLevelInt(loggerName, levelName); - if (levelInt != null) - { - JettyLogger jettyLogger = getJettyLogger(loggerName); - jettyLogger.setLevel(levelInt); - } + Integer levelInt = LevelUtils.getLevelInt(levelName); + if (levelInt == null) + return false; + JettyLogger jettyLogger = getJettyLogger(loggerName); + jettyLogger.setLevel(levelInt); + return true; } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java index 59c2da9f0a2..304410df716 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactoryMBean.java @@ -18,14 +18,13 @@ package org.eclipse.jetty.logging; -@SuppressWarnings("unused") public interface JettyLoggerFactoryMBean { int getLoggerCount(); String[] getLoggerNames(); - void setLoggerLevel(String loggerName, String levelName); + boolean setLoggerLevel(String loggerName, String levelName); String getLoggerLevel(String loggerName); } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java deleted file mode 100644 index f7aeac3a80e..00000000000 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingJmx.java +++ /dev/null @@ -1,50 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.logging; - -import java.lang.management.ManagementFactory; -import javax.management.MBeanServer; -import javax.management.ObjectName; - -public class JettyLoggingJmx -{ - public static void initialize(JettyLoggerConfiguration config, JettyLoggerFactory loggerFactory) - { - if (!config.getBoolean("org.eclipse.jetty.logging.jmx", false)) - { - loggerFactory.getJettyLogger(JettyLoggingJmx.class.getName()).debug("JMX not enabled"); - return; - } - - try - { - MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - String contextName = config.getString("org.eclipse.jetty.logging.jmx.contextName", "default"); - - ObjectName objName = new ObjectName(JettyLoggerFactory.class.getName() + ":name=" + contextName); - mbs.registerMBean(loggerFactory, objName); - } - catch (Throwable cause) - { - JettyLogger logger = loggerFactory.getJettyLogger(JettyLoggingJmx.class.getName()); - logger.warn("java.management not available."); - logger.debug("java.management is not available", cause); - } - } -} diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java index 61e7ec47f40..01ad473162a 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingServiceProvider.java @@ -45,8 +45,6 @@ public class JettyLoggingServiceProvider implements SLF4JServiceProvider loggerFactory = new JettyLoggerFactory(config); markerFactory = new BasicMarkerFactory(); mdcAdapter = new NOPMDCAdapter(); // TODO: Provide Jetty Implementation? - - JettyLoggingJmx.initialize(config, loggerFactory); } public JettyLoggerFactory getJettyLoggerFactory() diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java index e78abf4817b..9f4cbfbac2a 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java @@ -24,67 +24,34 @@ import org.slf4j.event.Level; public class LevelUtils { - public static Integer getLevelInt(String loggerName, String levelStr) + public static Integer getLevelInt(String levelStr) { - if (levelStr == null) + try + { + if (levelStr == null) + return null; + String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); + if ("ALL".equals(levelName)) + return Level.TRACE.toInt(); + return Level.valueOf(levelName).toInt(); + } + catch (Throwable x) { return null; } - - String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); - switch (levelName) - { - case "ALL": - return JettyLogger.ALL; - case "TRACE": - return Level.TRACE.toInt(); - case "DEBUG": - return Level.DEBUG.toInt(); - case "INFO": - return Level.INFO.toInt(); - case "WARN": - return Level.WARN.toInt(); - case "ERROR": - return Level.ERROR.toInt(); - case "OFF": - return JettyLogger.OFF; - default: - System.err.println("Unknown JettyLogger/Slf4J Level [" + loggerName + "]=[" + levelName + "], expecting only [ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF] as values."); - return null; - } } public static Level intToLevel(int level) { - if (level >= JettyLogger.OFF) + try + { + if (level < JettyLogger.ALL) + return Level.TRACE; + return Level.intToLevel(level); + } + catch (Throwable x) + { return Level.ERROR; - if (level >= Level.ERROR.toInt()) - return Level.ERROR; - if (level >= Level.WARN.toInt()) - return Level.WARN; - if (level >= Level.INFO.toInt()) - return Level.INFO; - if (level >= Level.DEBUG.toInt()) - return Level.DEBUG; - if (level >= Level.TRACE.toInt()) - return Level.TRACE; - return Level.TRACE; // everything else - } - - public static String levelToString(int level) - { - if (level >= JettyLogger.OFF) - return "OFF"; - if (level >= Level.ERROR.toInt()) - return "ERROR"; - if (level >= Level.WARN.toInt()) - return "WARN"; - if (level >= Level.INFO.toInt()) - return "INFO"; - if (level >= Level.DEBUG.toInt()) - return "DEBUG"; - if (level >= Level.TRACE.toInt()) - return "TRACE"; - return "OFF"; // everything else + } } } diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java new file mode 100644 index 00000000000..70d6dbda114 --- /dev/null +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java @@ -0,0 +1,74 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import javax.management.JMX; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +import org.junit.jupiter.api.Test; +import org.slf4j.event.Level; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class JMXTest +{ + @Test + public void testJMX() throws Exception + { + MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); + + Properties props = new Properties(); + JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); + JettyLoggerFactory loggerFactory = new JettyLoggerFactory(config); + + ObjectName objectName = ObjectName.getInstance("org.eclipse.jetty.logging", "type", JettyLoggerFactory.class.getSimpleName().toLowerCase(Locale.ENGLISH)); + mbeanServer.registerMBean(loggerFactory, objectName); + + JettyLoggerFactoryMBean mbean = JMX.newMBeanProxy(mbeanServer, objectName, JettyLoggerFactoryMBean.class); + + // Only the root logger. + assertEquals(1, mbean.getLoggerCount()); + + JettyLogger child = loggerFactory.getJettyLogger("org.eclipse.jetty.logging"); + JettyLogger parent = loggerFactory.getJettyLogger("org.eclipse.jetty"); + assertEquals(3, mbean.getLoggerCount()); + + // Names are sorted. + List expected = new ArrayList<>(Arrays.asList(JettyLogger.ROOT_LOGGER_NAME, parent.getName(), child.getName())); + expected.sort(String::compareTo); + String[] loggerNames = mbean.getLoggerNames(); + assertEquals(expected, Arrays.asList(loggerNames)); + + // Setting the parent level should propagate to the children. + parent.setLevel(Level.DEBUG); + assertEquals(Level.intToLevel(parent.getLevel()).toString(), mbean.getLoggerLevel(child.getName())); + + // Setting the level via JMX affects the logger. + assertTrue(mbean.setLoggerLevel(child.getName(), "INFO")); + assertEquals(Level.INFO.toInt(), child.getLevel()); + } +} diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java index 58b0c660573..857afc19788 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java @@ -526,7 +526,7 @@ public class JettyLoggerTest assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=ERROR")); log.setLevel(JettyLogger.OFF); - assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=OFF")); + assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=ERROR")); } @Test @@ -556,7 +556,7 @@ public class JettyLoggerTest assertLevel(log, Level.DEBUG); // as stomped // Restore configured - factory.walkChildLoggers(root.getName(), (logger) -> + factory.walkChildrenLoggers(root.getName(), (logger) -> { int configuredLevel = config.getLevel(logger.getName()); logger.setLevel(configuredLevel); @@ -609,6 +609,6 @@ public class JettyLoggerTest private void assertLevel(JettyLogger log, Level expectedLevel) { assertThat("Log[" + log.getName() + "].level", - LevelUtils.levelToString(log.getLevel()), is(expectedLevel.toString())); + LevelUtils.intToLevel(log.getLevel()), is(expectedLevel)); } } diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java deleted file mode 100644 index 26e12297d23..00000000000 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JmxExperiment.java +++ /dev/null @@ -1,46 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.logging; - -import java.util.Properties; - -public class JmxExperiment -{ - public static void main(String[] args) - { - try - { - Properties props = new Properties(); - props.setProperty("org.eclipse.jetty.logging.jmx", "true"); - props.setProperty("org.eclipse.jetty.logging.jmx.contextName", "Main"); - props.setProperty("org.eclipse.jetty.logging.LEVEL", "DEBUG"); - JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); - JettyLoggerFactory loggerFactory = new JettyLoggerFactory(config); - - JettyLoggingJmx.initialize(config, loggerFactory); - - loggerFactory.getJettyLogger(JmxExperiment.class.getName()).info("Waiting for key-press"); - System.in.read(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } -} From f98e2f8e140a86aa469830bb2c8327ca7bcc6c82 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 3 May 2020 21:40:27 +0200 Subject: [PATCH 04/77] Issue #4830 - Add JMX to new Jetty 10 jetty-slf4j-impl. Updates after review. Fixed test failures. Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java | 2 +- .../java/org/eclipse/jetty/logging/JettyLoggerFactory.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java index b6ed4b2a90c..39564ac64c0 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/MBeanContainer.java @@ -172,7 +172,7 @@ public class MBeanContainer implements Container.InheritedListener, Dumpable, De } klass = klass.getSuperclass(); } - Object mbean = findMetaData(container, klass).newInstance(o); + Object mbean = findMetaData(container, o.getClass()).newInstance(o); if (mbean instanceof ObjectMBean) ((ObjectMBean)mbean).setMBeanContainer(container); if (LOG.isDebugEnabled()) diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index e313cbe83b5..849d2812e9b 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -130,7 +130,8 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe else break; } - return null; + + return nameFunction.apply(Logger.ROOT_LOGGER_NAME); } @Override From ed37a1e2fc2ed996327b4037e2569e635e131f2c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 6 May 2020 11:18:44 +0200 Subject: [PATCH 05/77] Minor cleanup Use existing method (which may cache value) rather than inlined code. Signed-off-by: Greg Wilkins --- .../src/main/java/org/eclipse/jetty/server/Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 1a8d0be7b8e..d5426fbfc14 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1711,7 +1711,7 @@ public class Request implements HttpServletRequest // TODO this is not really right for CONNECT path = _uri.isAbsolute() ? "/" : null; else if (encoded.startsWith("/")) - path = (encoded.length() == 1) ? "/" : URIUtil.canonicalPath(URIUtil.decodePath(encoded)); + path = (encoded.length() == 1) ? "/" : _uri.getDecodedPath(); else if ("*".equals(encoded) || HttpMethod.CONNECT.is(getMethod())) path = encoded; else From 1c4f05d2d8a6f6b02c7033576569525e88463759 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 8 May 2020 12:34:12 -0500 Subject: [PATCH 06/77] Issue #4830 - Cleaning up Level handling with JettyLevel enum Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/logging/JettyLevel.java | 114 ++++++++++++++++++ .../eclipse/jetty/logging/JettyLogger.java | 44 +++---- .../logging/JettyLoggerConfiguration.java | 19 +-- .../jetty/logging/JettyLoggerFactory.java | 16 ++- .../org/eclipse/jetty/logging/LevelUtils.java | 57 --------- .../org/eclipse/jetty/logging/JMXTest.java | 7 +- .../logging/JettyLoggerConfigurationTest.java | 81 ++++++------- .../jetty/logging/JettyLoggerTest.java | 92 +++++++------- .../jetty/xml/XmlConfigurationTest.java | 3 +- 9 files changed, 244 insertions(+), 189 deletions(-) create mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLevel.java delete mode 100644 jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLevel.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLevel.java new file mode 100644 index 00000000000..038ca466a99 --- /dev/null +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLevel.java @@ -0,0 +1,114 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.logging; + +import java.util.Locale; + +import org.slf4j.event.Level; + +public enum JettyLevel +{ + // Intentionally sorted incrementally by level int + ALL(Level.TRACE.toInt() - 10), + TRACE(Level.TRACE), + DEBUG(Level.DEBUG), + INFO(Level.INFO), + WARN(Level.WARN), + ERROR(Level.ERROR), + OFF(Level.ERROR.toInt() + 1); + + private final Level level; + private final int levelInt; + + JettyLevel(Level level) + { + this.level = level; + this.levelInt = level.toInt(); + } + + JettyLevel(int i) + { + this.level = null; + this.levelInt = i; + } + + public static JettyLevel fromLevel(Level slf4jLevel) + { + for (JettyLevel level : JettyLevel.values()) + { + if (slf4jLevel.toInt() == level.levelInt) + return level; + } + return OFF; + } + + public int toInt() + { + return levelInt; + } + + public Level toLevel() + { + return level; + } + + /** + * Tests that a provided level is included by the level value of this level. + * + * @param testLevel the level to test against. + * @return true if includes this includes the test level. + */ + public boolean includes(JettyLevel testLevel) + { + return (this.levelInt <= testLevel.levelInt); + } + + @Override + public String toString() + { + return name(); + } + + public static JettyLevel intToLevel(int levelInt) + { + for (JettyLevel level : JettyLevel.values()) + { + if (levelInt <= level.levelInt) + return level; + } + return OFF; + } + + public static JettyLevel strToLevel(String levelStr) + { + if (levelStr == null) + { + return null; + } + + String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); + for (JettyLevel level : JettyLevel.values()) + { + if (level.name().equals(levelName)) + return level; + } + + return null; + } +} diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java index e7eaff98155..7367a215911 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java @@ -18,8 +18,6 @@ package org.eclipse.jetty.logging; -import java.util.Objects; - import org.slf4j.Logger; import org.slf4j.Marker; import org.slf4j.event.Level; @@ -29,28 +27,19 @@ import org.slf4j.spi.LocationAwareLogger; public class JettyLogger implements LocationAwareLogger, Logger { - /** - * The Level to set if you want this logger to be "OFF" - */ - static final int OFF = 999; - /** - * The Level to set if you want this logger to show all events from all levels. - */ - static final int ALL = Level.TRACE.toInt(); - private final JettyLoggerFactory factory; private final String name; private final String condensedName; private final JettyAppender appender; - private int level; + private JettyLevel level; private boolean hideStacks; public JettyLogger(JettyLoggerFactory factory, String name, JettyAppender appender) { - this(factory, name, appender, Level.INFO.toInt(), false); + this(factory, name, appender, JettyLevel.INFO, false); } - public JettyLogger(JettyLoggerFactory factory, String name, JettyAppender appender, int level, boolean hideStacks) + public JettyLogger(JettyLoggerFactory factory, String name, JettyAppender appender, JettyLevel level, boolean hideStacks) { this.factory = factory; this.name = name; @@ -303,11 +292,11 @@ public class JettyLogger implements LocationAwareLogger, Logger @Override public void log(Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable throwable) { - if (this.level <= levelInt) + if (this.level.toInt() <= levelInt) { long timestamp = System.currentTimeMillis(); String threadName = Thread.currentThread().getName(); - getAppender().emit(this, LevelUtils.intToLevel(levelInt), timestamp, threadName, throwable, message, argArray); + getAppender().emit(this, JettyLevel.intToLevel(levelInt).toLevel(), timestamp, threadName, throwable, message, argArray); } } @@ -329,23 +318,22 @@ public class JettyLogger implements LocationAwareLogger, Logger return condensedName; } - public int getLevel() + public JettyLevel getLevel() { return level; } public void setLevel(Level level) { - Objects.requireNonNull(level, "Level"); - setLevel(level.toInt()); + setLevel(JettyLevel.fromLevel(level)); } - public void setLevel(int lvlInt) + public void setLevel(JettyLevel level) { - this.level = lvlInt; + this.level = level; // apply setLevel to children too. - factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setLevel(lvlInt)); + factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setLevel(level)); } @Override @@ -443,13 +431,13 @@ public class JettyLogger implements LocationAwareLogger, Logger @Override public boolean isDebugEnabled() { - return level <= Level.DEBUG.toInt(); + return level.includes(JettyLevel.DEBUG); } @Override public boolean isErrorEnabled() { - return level <= Level.ERROR.toInt(); + return level.includes(JettyLevel.ERROR); } public boolean isHideStacks() @@ -468,19 +456,19 @@ public class JettyLogger implements LocationAwareLogger, Logger @Override public boolean isInfoEnabled() { - return level <= Level.INFO.toInt(); + return level.includes(JettyLevel.INFO); } @Override public boolean isTraceEnabled() { - return level <= Level.TRACE.toInt(); + return level.includes(JettyLevel.TRACE); } @Override public boolean isWarnEnabled() { - return level <= Level.WARN.toInt(); + return level.includes(JettyLevel.WARN); } @Override @@ -699,6 +687,6 @@ public class JettyLogger implements LocationAwareLogger, Logger @Override public String toString() { - return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, LevelUtils.intToLevel(level)); + return String.format("%s:%s:LEVEL=%s", JettyLogger.class.getSimpleName(), name, level.name()); } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index ba00a0abadf..4096ab4f70e 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -27,8 +27,6 @@ import java.util.Locale; import java.util.Properties; import java.util.TimeZone; -import org.slf4j.event.Level; - /** * JettyLogger specific configuration: *
    @@ -38,7 +36,7 @@ import org.slf4j.event.Level; */ public class JettyLoggerConfiguration { - private static final int DEFAULT_LEVEL = Level.INFO.toInt(); + private static final JettyLevel DEFAULT_LEVEL = JettyLevel.INFO; private static final boolean DEFAULT_HIDE_STACKS = false; private static final String SUFFIX_LEVEL = ".LEVEL"; private static final String SUFFIX_STACKS = ".STACKS"; @@ -97,7 +95,7 @@ public class JettyLoggerConfiguration * @param name the name to get log for * @return the logging level int */ - public int getLevel(String name) + public JettyLevel getLevel(String name) { if (properties.isEmpty()) return DEFAULT_LEVEL; @@ -114,17 +112,24 @@ public class JettyLoggerConfiguration if (startName.endsWith(SUFFIX_LEVEL)) startName = startName.substring(0, startName.length() - SUFFIX_LEVEL.length()); - Integer level = JettyLoggerFactory.walkParentLoggerNames(startName, key -> + JettyLevel level = JettyLoggerFactory.walkParentLoggerNames(startName, key -> { String levelStr = properties.getProperty(key + SUFFIX_LEVEL); - return LevelUtils.getLevelInt(levelStr); + return JettyLevel.strToLevel(levelStr); }); + if (level == null) + { + // Try slf4j root logging config. + String levelStr = properties.getProperty(JettyLogger.ROOT_LOGGER_NAME + SUFFIX_LEVEL); + level = JettyLevel.strToLevel(levelStr); + } + if (level == null) { // Try legacy root logging config. String levelStr = properties.getProperty("log" + SUFFIX_LEVEL); - level = LevelUtils.getLevelInt(levelStr); + level = JettyLevel.strToLevel(levelStr); } return level != null ? level : DEFAULT_LEVEL; diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index 849d2812e9b..fd97bd771b5 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -24,6 +24,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; @@ -105,7 +107,7 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe private JettyLogger createLogger(String name) { JettyAppender appender = rootLogger.getAppender(); - int level = this.configuration.getLevel(name); + JettyLevel level = this.configuration.getLevel(name); boolean hideStacks = this.configuration.getHideStacks(name); return new JettyLogger(this, name, appender, level, hideStacks); } @@ -154,7 +156,7 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe { JettyLogger logger = loggerMap.get(key); if (logger != null) - return LevelUtils.intToLevel(logger.getLevel()).toString(); + return logger.getLevel().toString(); return null; }); } @@ -162,11 +164,15 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe @Override public boolean setLoggerLevel(String loggerName, String levelName) { - Integer levelInt = LevelUtils.getLevelInt(levelName); - if (levelInt == null) + JettyLevel level = JettyLevel.strToLevel(levelName); + if (level == null) + { + System.err.printf("Unknown JettyLogger/Slf4J Level [%s]=[%s], expecting only [%s] as values.", + loggerName, levelName, Stream.of(JettyLevel.values()).map(JettyLevel::toString).collect(Collectors.joining(", "))); return false; + } JettyLogger jettyLogger = getJettyLogger(loggerName); - jettyLogger.setLevel(levelInt); + jettyLogger.setLevel(level); return true; } } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java deleted file mode 100644 index 9f4cbfbac2a..00000000000 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/LevelUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.logging; - -import java.util.Locale; - -import org.slf4j.event.Level; - -public class LevelUtils -{ - public static Integer getLevelInt(String levelStr) - { - try - { - if (levelStr == null) - return null; - String levelName = levelStr.trim().toUpperCase(Locale.ENGLISH); - if ("ALL".equals(levelName)) - return Level.TRACE.toInt(); - return Level.valueOf(levelName).toInt(); - } - catch (Throwable x) - { - return null; - } - } - - public static Level intToLevel(int level) - { - try - { - if (level < JettyLogger.ALL) - return Level.TRACE; - return Level.intToLevel(level); - } - catch (Throwable x) - { - return Level.ERROR; - } - } -} diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java index 70d6dbda114..6719982f81c 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JMXTest.java @@ -29,7 +29,6 @@ import javax.management.MBeanServer; import javax.management.ObjectName; import org.junit.jupiter.api.Test; -import org.slf4j.event.Level; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -64,11 +63,11 @@ public class JMXTest assertEquals(expected, Arrays.asList(loggerNames)); // Setting the parent level should propagate to the children. - parent.setLevel(Level.DEBUG); - assertEquals(Level.intToLevel(parent.getLevel()).toString(), mbean.getLoggerLevel(child.getName())); + parent.setLevel(JettyLevel.DEBUG); + assertEquals(parent.getLevel().toString(), mbean.getLoggerLevel(child.getName())); // Setting the level via JMX affects the logger. assertTrue(mbean.setLoggerLevel(child.getName(), "INFO")); - assertEquals(Level.INFO.toInt(), child.getLevel()); + assertEquals(JettyLevel.INFO, child.getLevel()); } } diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java index bc3982c0c64..14def8a813c 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java @@ -21,7 +21,6 @@ package org.eclipse.jetty.logging; import java.util.Properties; import org.junit.jupiter.api.Test; -import org.slf4j.event.Level; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -46,8 +45,8 @@ public class JettyLoggerConfigurationTest assertFalse(appender.isCondensedNames()); assertEquals(appender.getThreadPadding(), 10); - int level = config.getLevel("com.mortbay"); - assertEquals(Level.WARN.toInt(), level); + JettyLevel level = config.getLevel("com.mortbay"); + assertEquals(JettyLevel.WARN, level); boolean stacks = config.getHideStacks("com.mortbay.Foo"); assertFalse(stacks); @@ -59,8 +58,8 @@ public class JettyLoggerConfigurationTest Properties props = new Properties(); props.setProperty("com.mortbay.LEVEL", "WARN"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); - int level = config.getLevel("com.mortbay"); - assertEquals(Level.WARN.toInt(), level); + JettyLevel level = config.getLevel("com.mortbay"); + assertEquals(JettyLevel.WARN, level); } @Test @@ -70,8 +69,8 @@ public class JettyLoggerConfigurationTest props.setProperty("com.mortbay.LEVEL", "WARN"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // extra trailing dot "." - int level = config.getLevel("com.mortbay."); - assertEquals(Level.WARN.toInt(), level); + JettyLevel level = config.getLevel("com.mortbay."); + assertEquals(JettyLevel.WARN, level); } @Test @@ -81,8 +80,8 @@ public class JettyLoggerConfigurationTest props.setProperty("com.mortbay.LEVEL", "WARN"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // asking for name with ".LEVEL" - int level = config.getLevel("com.mortbay.Bar.LEVEL"); - assertEquals(Level.WARN.toInt(), level); + JettyLevel level = config.getLevel("com.mortbay.Bar.LEVEL"); + assertEquals(JettyLevel.WARN, level); } @Test @@ -91,8 +90,8 @@ public class JettyLoggerConfigurationTest Properties props = new Properties(); props.setProperty("com.mortbay.LEVEL", "WARN"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); - int level = config.getLevel("com.mortbay.Foo"); - assertEquals(Level.WARN.toInt(), level); + JettyLevel level = config.getLevel("com.mortbay.Foo"); + assertEquals(JettyLevel.WARN, level); } @Test @@ -102,8 +101,8 @@ public class JettyLoggerConfigurationTest props.setProperty("com.mortbay.LEVEL", "WARN"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // asking for name that isn't configured, returns default value - int level = config.getLevel("org.eclipse.jetty"); - assertEquals(Level.INFO.toInt(), level); + JettyLevel level = config.getLevel("org.eclipse.jetty"); + assertEquals(JettyLevel.INFO, level); } @Test @@ -168,7 +167,7 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Level (because of bad level value) - assertEquals(Level.WARN.toInt(), config.getLevel("org.eclipse.jetty.bad")); + assertEquals(JettyLevel.WARN, config.getLevel("org.eclipse.jetty.bad")); } @Test @@ -180,9 +179,9 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Level - assertEquals(Level.WARN.toInt(), config.getLevel("org.eclipse.jetty")); + assertEquals(JettyLevel.WARN, config.getLevel("org.eclipse.jetty")); // Specific Level - assertEquals(Level.INFO.toInt(), config.getLevel("org.eclipse.jetty.util")); + assertEquals(JettyLevel.INFO, config.getLevel("org.eclipse.jetty.util")); } @Test @@ -193,11 +192,11 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Levels - assertEquals(Level.DEBUG.toInt(), config.getLevel(null)); - assertEquals(Level.DEBUG.toInt(), config.getLevel("")); - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty")); + assertEquals(JettyLevel.DEBUG, config.getLevel(null)); + assertEquals(JettyLevel.DEBUG, config.getLevel("")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty")); String name = JettyLoggerConfigurationTest.class.getName(); - assertEquals(Level.DEBUG.toInt(), config.getLevel(name), "Default Logging Level - " + name + " name"); + assertEquals(JettyLevel.DEBUG, config.getLevel(name), "Default Logging Level - " + name + " name"); } @Test @@ -209,12 +208,12 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Levels - assertEquals(Level.INFO.toInt(), config.getLevel(null)); - assertEquals(Level.INFO.toInt(), config.getLevel("")); - assertEquals(Level.INFO.toInt(), config.getLevel("org.eclipse.jetty")); + assertEquals(JettyLevel.INFO, config.getLevel(null)); + assertEquals(JettyLevel.INFO, config.getLevel("")); + assertEquals(JettyLevel.INFO, config.getLevel("org.eclipse.jetty")); // Specified Level - assertEquals(JettyLogger.ALL, config.getLevel(name)); + assertEquals(JettyLevel.ALL, config.getLevel(name)); } @Test @@ -225,16 +224,16 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Levels - assertEquals(Level.INFO.toInt(), config.getLevel(null)); - assertEquals(Level.INFO.toInt(), config.getLevel("")); - assertEquals(Level.INFO.toInt(), config.getLevel("org.eclipse.jetty")); - assertEquals(Level.INFO.toInt(), config.getLevel("org.eclipse.jetty.server.BogusObject")); - assertEquals(Level.INFO.toInt(), config.getLevel(JettyLoggerConfigurationTest.class.getName())); + assertEquals(JettyLevel.INFO, config.getLevel(null)); + assertEquals(JettyLevel.INFO, config.getLevel("")); + assertEquals(JettyLevel.INFO, config.getLevel("org.eclipse.jetty")); + assertEquals(JettyLevel.INFO, config.getLevel("org.eclipse.jetty.server.BogusObject")); + assertEquals(JettyLevel.INFO, config.getLevel(JettyLoggerConfigurationTest.class.getName())); // Configured Level - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty.util.Bogus")); - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty.util")); - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty.util.resource.PathResource")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty.util.Bogus")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty.util")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty.util.resource.PathResource")); } @Test @@ -248,17 +247,17 @@ public class JettyLoggerConfigurationTest JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Levels - assertEquals(Level.DEBUG.toInt(), config.getLevel(null)); - assertEquals(Level.DEBUG.toInt(), config.getLevel("")); - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty")); - assertEquals(Level.DEBUG.toInt(), config.getLevel("org.eclipse.jetty.server.BogusObject")); - assertEquals(Level.DEBUG.toInt(), config.getLevel(JettyLoggerConfigurationTest.class.getName())); + assertEquals(JettyLevel.DEBUG, config.getLevel(null)); + assertEquals(JettyLevel.DEBUG, config.getLevel("")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty")); + assertEquals(JettyLevel.DEBUG, config.getLevel("org.eclipse.jetty.server.BogusObject")); + assertEquals(JettyLevel.DEBUG, config.getLevel(JettyLoggerConfigurationTest.class.getName())); // Configured Level - assertEquals(Level.WARN.toInt(), config.getLevel("org.eclipse.jetty.util.MagicUtil")); - assertEquals(Level.WARN.toInt(), config.getLevel("org.eclipse.jetty.util")); - assertEquals(Level.WARN.toInt(), config.getLevel("org.eclipse.jetty.util.resource.PathResource")); + assertEquals(JettyLevel.WARN, config.getLevel("org.eclipse.jetty.util.MagicUtil")); + assertEquals(JettyLevel.WARN, config.getLevel("org.eclipse.jetty.util")); + assertEquals(JettyLevel.WARN, config.getLevel("org.eclipse.jetty.util.resource.PathResource")); - assertEquals(JettyLogger.ALL, config.getLevel("org.eclipse.jetty.util.ConcurrentHashMap")); + assertEquals(JettyLevel.ALL, config.getLevel("org.eclipse.jetty.util.ConcurrentHashMap")); } } diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java index 857afc19788..02a0167f45c 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerTest.java @@ -91,11 +91,11 @@ public class JettyLoggerTest JettyLogger log = factory.getJettyLogger("xxx"); - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); log.debug("testing {} {}", "test", "debug"); log.info("testing {} {}", "test", "info"); log.warn("testing {} {}", "test", "warn"); - log.setLevel(Level.INFO); + log.setLevel(JettyLevel.INFO); log.debug("YOU SHOULD NOT SEE THIS!"); output.assertContains("DEBUG:xxx:tname: testing test debug"); @@ -177,7 +177,7 @@ public class JettyLoggerTest appender.setStream(output); JettyLogger log = factory.getJettyLogger(JettyLoggerTest.class.getName()); - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); String nullMsg = null; try (StacklessLogging ignored = new StacklessLogging(log)) @@ -234,11 +234,11 @@ public class JettyLoggerTest log.warn("See Me"); // Set to debug level - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); log.warn("Hear Me"); // Set to warn level - log.setLevel(Level.WARN); + log.setLevel(JettyLevel.WARN); log.warn("Cheer Me"); log.warn("", new Throwable("out of focus")); @@ -279,18 +279,18 @@ public class JettyLoggerTest log.info("I will not buy"); // Level Debug - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); log.info("this record"); // Level All - log.setLevel(Level.TRACE); + log.setLevel(JettyLevel.TRACE); log.info("it is scratched."); log.info("", new Throwable("out of focus")); log.info("shot issue", new Throwable("scene lost")); // Level Warn - log.setLevel(Level.WARN); + log.setLevel(JettyLevel.WARN); log.info("sorry?"); log.info("", new Throwable("on editing room floor")); @@ -326,7 +326,7 @@ public class JettyLoggerTest JettyLogger log = factory.getJettyLogger(JettyLoggerTest.class.getName()); try (StacklessLogging ignored = new StacklessLogging(log)) { - log.setLevel(Level.ERROR); + log.setLevel(JettyLevel.ERROR); // Various logging events log.debug("Squelch"); @@ -359,7 +359,7 @@ public class JettyLoggerTest try (StacklessLogging ignored = new StacklessLogging(log)) { - log.setLevel(JettyLogger.OFF); + log.setLevel(JettyLevel.OFF); // Various logging events log.debug("Squelch"); @@ -399,18 +399,18 @@ public class JettyLoggerTest log.debug("", new Throwable("on editing room floor")); // Level Debug - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); log.debug("my hovercraft is"); log.debug("", new Throwable("out of focus")); log.debug("shot issue", new Throwable("scene lost")); // Level All - log.setLevel(Level.TRACE); + log.setLevel(JettyLevel.TRACE); log.debug("full of eels."); // Level Warn - log.setLevel(Level.WARN); + log.setLevel(JettyLevel.WARN); log.debug("what?"); // Validate Output @@ -444,22 +444,22 @@ public class JettyLoggerTest try (StacklessLogging ignored = new StacklessLogging(log)) { - log.setLevel(Level.TRACE); + log.setLevel(JettyLevel.TRACE); assertThat("log.level(trace).isDebugEnabled", log.isDebugEnabled(), is(true)); - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); assertThat("log.level(debug).isDebugEnabled", log.isDebugEnabled(), is(true)); - log.setLevel(Level.INFO); + log.setLevel(JettyLevel.INFO); assertThat("log.level(info).isDebugEnabled", log.isDebugEnabled(), is(false)); - log.setLevel(Level.WARN); + log.setLevel(JettyLevel.WARN); assertThat("log.level(warn).isDebugEnabled", log.isDebugEnabled(), is(false)); - log.setLevel(Level.ERROR); + log.setLevel(JettyLevel.ERROR); assertThat("log.level(error).isDebugEnabled", log.isDebugEnabled(), is(false)); - log.setLevel(JettyLogger.OFF); + log.setLevel(JettyLevel.OFF); assertThat("log.level(null).isDebugEnabled", log.isDebugEnabled(), is(false)); } } @@ -478,23 +478,23 @@ public class JettyLoggerTest try (StacklessLogging ignored = new StacklessLogging(log)) { - log.setLevel(Level.TRACE); - assertThat("log.level(trace).getLevel()", log.getLevel(), is(Level.TRACE.toInt())); + log.setLevel(JettyLevel.TRACE); + assertThat("log.level(trace).getLevel()", log.getLevel(), is(JettyLevel.TRACE)); - log.setLevel(Level.DEBUG); - assertThat("log.level(debug).getLevel()", log.getLevel(), is(Level.DEBUG.toInt())); + log.setLevel(JettyLevel.DEBUG); + assertThat("log.level(debug).getLevel()", log.getLevel(), is(JettyLevel.DEBUG)); - log.setLevel(Level.INFO); - assertThat("log.level(info).getLevel()", log.getLevel(), is(Level.INFO.toInt())); + log.setLevel(JettyLevel.INFO); + assertThat("log.level(info).getLevel()", log.getLevel(), is(JettyLevel.INFO)); - log.setLevel(Level.WARN); - assertThat("log.level(warn).getLevel()", log.getLevel(), is(Level.WARN.toInt())); + log.setLevel(JettyLevel.WARN); + assertThat("log.level(warn).getLevel()", log.getLevel(), is(JettyLevel.WARN)); - log.setLevel(Level.ERROR); - assertThat("log.level(error).getLevel()", log.getLevel(), is(Level.ERROR.toInt())); + log.setLevel(JettyLevel.ERROR); + assertThat("log.level(error).getLevel()", log.getLevel(), is(JettyLevel.ERROR)); - log.setLevel(888); - assertThat("log.level(888).getLevel()", log.getLevel(), is(888)); + log.setLevel(JettyLevel.OFF); + assertThat("log.level(off).getLevel()", log.getLevel(), is(JettyLevel.OFF)); } } @@ -510,23 +510,23 @@ public class JettyLoggerTest JettyLogger log = factory.getJettyLogger("xxx"); - log.setLevel(Level.TRACE); + log.setLevel(JettyLevel.TRACE); assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=TRACE")); - log.setLevel(Level.DEBUG); + log.setLevel(JettyLevel.DEBUG); assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=DEBUG")); - log.setLevel(Level.INFO); + log.setLevel(JettyLevel.INFO); assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=INFO")); - log.setLevel(Level.WARN); + log.setLevel(JettyLevel.WARN); assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=WARN")); - log.setLevel(Level.ERROR); + log.setLevel(JettyLevel.ERROR); assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=ERROR")); - log.setLevel(JettyLogger.OFF); - assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=ERROR")); + log.setLevel(JettyLevel.OFF); + assertThat("Logger.toString", log.toString(), is("JettyLogger:xxx:LEVEL=OFF")); } @Test @@ -544,25 +544,25 @@ public class JettyLoggerTest appender.setStream(output); JettyLogger root = factory.getJettyLogger(""); - assertLevel(root, Level.INFO); // default + assertLevel(root, JettyLevel.INFO); // default JettyLogger log = factory.getJettyLogger("org.eclipse.jetty.util.Foo"); assertThat("Log.isDebugEnabled()", log.isDebugEnabled(), is(false)); - assertLevel(log, Level.WARN); // as configured + assertLevel(log, JettyLevel.WARN); // as configured // Boot stomp it all to debug - root.setLevel(Level.DEBUG); + root.setLevel(JettyLevel.DEBUG); assertThat("Log.isDebugEnabled()", log.isDebugEnabled(), is(true)); - assertLevel(log, Level.DEBUG); // as stomped + assertLevel(log, JettyLevel.DEBUG); // as stomped // Restore configured factory.walkChildrenLoggers(root.getName(), (logger) -> { - int configuredLevel = config.getLevel(logger.getName()); + JettyLevel configuredLevel = config.getLevel(logger.getName()); logger.setLevel(configuredLevel); }); assertThat("Log.isDebugEnabled()", log.isDebugEnabled(), is(false)); - assertLevel(log, Level.WARN); // as configured + assertLevel(log, JettyLevel.WARN); // as configured } @Test @@ -606,9 +606,9 @@ public class JettyLoggerTest output.assertContains("\t|\t|java.lang.Exception: branch0"); } - private void assertLevel(JettyLogger log, Level expectedLevel) + private void assertLevel(JettyLogger log, JettyLevel expectedLevel) { assertThat("Log[" + log.getName() + "].level", - LevelUtils.intToLevel(log.getLevel()), is(expectedLevel)); + log.getLevel(), is(expectedLevel)); } } diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index 8838a0797dd..823aeba8b8d 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import org.eclipse.jetty.logging.JettyLevel; import org.eclipse.jetty.logging.JettyLogger; import org.eclipse.jetty.logging.StdErrAppender; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -1595,7 +1596,7 @@ public class XmlConfigurationTest JettyLogger jettyLogger = (JettyLogger)slf4jLogger; StdErrAppender appender = (StdErrAppender)jettyLogger.getAppender(); PrintStream oldStream = appender.getStream(); - int oldLevel = jettyLogger.getLevel(); + JettyLevel oldLevel = jettyLogger.getLevel(); try { // capture events From 1c2c3892f17c12db2a59411b467d803303a7e9f7 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 8 May 2020 12:42:57 -0500 Subject: [PATCH 07/77] Issue #4830 - Ensuring we have Logger ROOT configuration ability Signed-off-by: Joakim Erdfelt --- .../jetty/logging/JettyLoggerConfigurationTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java index 14def8a813c..cdbdd5ebede 100644 --- a/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java +++ b/jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/JettyLoggerConfigurationTest.java @@ -162,7 +162,7 @@ public class JettyLoggerConfigurationTest public void testGetLoggingLevelBad() { Properties props = new Properties(); - props.setProperty("log.LEVEL", "WARN"); + props.setProperty("ROOT.LEVEL", "WARN"); props.setProperty("org.eclipse.jetty.bad.LEVEL", "EXPECTED_BAD_LEVEL"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); @@ -174,7 +174,7 @@ public class JettyLoggerConfigurationTest public void testGetLoggingLevelLowercase() { Properties props = new Properties(); - props.setProperty("log.LEVEL", "warn"); + props.setProperty("ROOT.LEVEL", "warn"); props.setProperty("org.eclipse.jetty.util.LEVEL", "info"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); @@ -188,7 +188,7 @@ public class JettyLoggerConfigurationTest public void testGetLoggingLevelRoot() { Properties props = new Properties(); - props.setProperty("log.LEVEL", "DEBUG"); + props.setProperty("ROOT.LEVEL", "DEBUG"); JettyLoggerConfiguration config = new JettyLoggerConfiguration(props); // Default Levels @@ -240,7 +240,7 @@ public class JettyLoggerConfigurationTest public void testGetLoggingLevelMixedLevels() { Properties props = new Properties(); - props.setProperty("log.LEVEL", "DEBUG"); + props.setProperty("ROOT.LEVEL", "DEBUG"); props.setProperty("org.eclipse.jetty.util.LEVEL", "WARN"); props.setProperty("org.eclipse.jetty.util.ConcurrentHashMap.LEVEL", "ALL"); From 69e1d119fe3b26e8371d98b1419a987d802c96db Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 8 May 2020 12:48:46 -0500 Subject: [PATCH 08/77] Issue #4830 - Improved notification of configuration mistakes on level names Signed-off-by: Joakim Erdfelt --- .../logging/JettyLoggerConfiguration.java | 21 ++++++++++++++++--- .../jetty/logging/JettyLoggerFactory.java | 6 +----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index 4096ab4f70e..2f4662aeb34 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -26,6 +26,8 @@ import java.security.PrivilegedAction; import java.util.Locale; import java.util.Properties; import java.util.TimeZone; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * JettyLogger specific configuration: @@ -115,26 +117,39 @@ public class JettyLoggerConfiguration JettyLevel level = JettyLoggerFactory.walkParentLoggerNames(startName, key -> { String levelStr = properties.getProperty(key + SUFFIX_LEVEL); - return JettyLevel.strToLevel(levelStr); + return toJettyLevel(key, levelStr); }); if (level == null) { // Try slf4j root logging config. String levelStr = properties.getProperty(JettyLogger.ROOT_LOGGER_NAME + SUFFIX_LEVEL); - level = JettyLevel.strToLevel(levelStr); + level = toJettyLevel(JettyLogger.ROOT_LOGGER_NAME, levelStr); } if (level == null) { // Try legacy root logging config. String levelStr = properties.getProperty("log" + SUFFIX_LEVEL); - level = JettyLevel.strToLevel(levelStr); + level = toJettyLevel("log", levelStr); } return level != null ? level : DEFAULT_LEVEL; } + protected static JettyLevel toJettyLevel(String loggerName, String levelStr) + { + if (levelStr == null) + return null; + JettyLevel level = JettyLevel.strToLevel(levelStr); + if (level == null) + { + System.err.printf("Unknown JettyLogger/Slf4J Level [%s]=[%s], expecting only [%s] as values.", + loggerName, levelStr, Stream.of(JettyLevel.values()).map(JettyLevel::toString).collect(Collectors.joining(", "))); + } + return level; + } + public TimeZone getTimeZone(String key) { String zoneIdStr = properties.getProperty(key); diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index fd97bd771b5..389a25dbfd3 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -24,8 +24,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; @@ -164,11 +162,9 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe @Override public boolean setLoggerLevel(String loggerName, String levelName) { - JettyLevel level = JettyLevel.strToLevel(levelName); + JettyLevel level = JettyLoggerConfiguration.toJettyLevel(loggerName, levelName); if (level == null) { - System.err.printf("Unknown JettyLogger/Slf4J Level [%s]=[%s], expecting only [%s] as values.", - loggerName, levelName, Stream.of(JettyLevel.values()).map(JettyLevel::toString).collect(Collectors.joining(", "))); return false; } JettyLogger jettyLogger = getJettyLogger(loggerName); From d6d994db5c7a82c03b47270d62681d25dd841ede Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 8 May 2020 22:03:03 +0200 Subject: [PATCH 09/77] Issue #4830 - Add JMX to new Jetty 10 jetty-slf4j-impl. Updates after review. Signed-off-by: Simone Bordet --- .../eclipse/jetty/logging/JettyLogger.java | 227 +++++++++--------- .../logging/JettyLoggerConfiguration.java | 2 +- .../jetty/logging/JettyLoggerFactory.java | 2 +- .../jetty/xml/XmlConfigurationTest.java | 3 +- 4 files changed, 114 insertions(+), 120 deletions(-) diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java index 7367a215911..08c65e7a7a0 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java @@ -109,6 +109,48 @@ public class JettyLogger implements LocationAwareLogger, Logger return dense.toString(); } + public JettyAppender getAppender() + { + return appender; + } + + String getCondensedName() + { + return condensedName; + } + + public JettyLevel getLevel() + { + return level; + } + + public void setLevel(JettyLevel level) + { + this.level = level; + + // apply setLevel to children too. + factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setLevel(level)); + } + + @Override + public String getName() + { + return name; + } + + public boolean isHideStacks() + { + return hideStacks; + } + + public void setHideStacks(boolean hideStacks) + { + this.hideStacks = hideStacks; + + // apply setHideStacks to children too. + factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setHideStacks(hideStacks)); + } + @Override public void debug(String msg) { @@ -154,12 +196,6 @@ public class JettyLogger implements LocationAwareLogger, Logger } } - @Override - public boolean isDebugEnabled(Marker marker) - { - return isDebugEnabled(); - } - @Override public void debug(Marker marker, String msg) { @@ -195,6 +231,18 @@ public class JettyLogger implements LocationAwareLogger, Logger debug(msg, t); } + @Override + public boolean isDebugEnabled() + { + return level.includes(JettyLevel.DEBUG); + } + + @Override + public boolean isDebugEnabled(Marker marker) + { + return isDebugEnabled(); + } + @Override public void error(String msg) { @@ -240,12 +288,6 @@ public class JettyLogger implements LocationAwareLogger, Logger } } - @Override - public boolean isErrorEnabled(Marker marker) - { - return isErrorEnabled(); - } - @Override public void error(Marker marker, String msg) { @@ -281,65 +323,16 @@ public class JettyLogger implements LocationAwareLogger, Logger error(msg, t); } - public JettyAppender getAppender() - { - return appender; - } - - /** - * Entry point for {@link LocationAwareLogger} - */ @Override - public void log(Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable throwable) + public boolean isErrorEnabled() { - if (this.level.toInt() <= levelInt) - { - long timestamp = System.currentTimeMillis(); - String threadName = Thread.currentThread().getName(); - getAppender().emit(this, JettyLevel.intToLevel(levelInt).toLevel(), timestamp, threadName, throwable, message, argArray); - } - } - - /** - * Dynamic (via Reflection) entry point for {@link SubstituteLogger} usage. - * - * @param event the logging event - */ - @SuppressWarnings("unused") - public void log(LoggingEvent event) - { - // TODO: do we want to support org.sfl4j.Marker? - // TODO: do we want to support org.sfl4j.even.KeyValuePair? - getAppender().emit(this, event.getLevel(), event.getTimeStamp(), event.getThreadName(), event.getThrowable(), event.getMessage(), event.getArgumentArray()); - } - - public String getCondensedName() - { - return condensedName; - } - - public JettyLevel getLevel() - { - return level; - } - - public void setLevel(Level level) - { - setLevel(JettyLevel.fromLevel(level)); - } - - public void setLevel(JettyLevel level) - { - this.level = level; - - // apply setLevel to children too. - factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setLevel(level)); + return level.includes(JettyLevel.ERROR); } @Override - public String getName() + public boolean isErrorEnabled(Marker marker) { - return name; + return isErrorEnabled(); } @Override @@ -387,12 +380,6 @@ public class JettyLogger implements LocationAwareLogger, Logger } } - @Override - public boolean isInfoEnabled(Marker marker) - { - return isInfoEnabled(); - } - @Override public void info(Marker marker, String msg) { @@ -428,31 +415,6 @@ public class JettyLogger implements LocationAwareLogger, Logger info(msg, t); } - @Override - public boolean isDebugEnabled() - { - return level.includes(JettyLevel.DEBUG); - } - - @Override - public boolean isErrorEnabled() - { - return level.includes(JettyLevel.ERROR); - } - - public boolean isHideStacks() - { - return hideStacks; - } - - public void setHideStacks(boolean hideStacks) - { - this.hideStacks = hideStacks; - - // apply setHideStacks to children too. - factory.walkChildrenLoggers(this.getName(), (logger) -> logger.setHideStacks(hideStacks)); - } - @Override public boolean isInfoEnabled() { @@ -460,15 +422,9 @@ public class JettyLogger implements LocationAwareLogger, Logger } @Override - public boolean isTraceEnabled() + public boolean isInfoEnabled(Marker marker) { - return level.includes(JettyLevel.TRACE); - } - - @Override - public boolean isWarnEnabled() - { - return level.includes(JettyLevel.WARN); + return isInfoEnabled(); } @Override @@ -516,12 +472,6 @@ public class JettyLogger implements LocationAwareLogger, Logger } } - @Override - public boolean isTraceEnabled(Marker marker) - { - return isTraceEnabled(); - } - @Override public void trace(Marker marker, String msg) { @@ -557,6 +507,18 @@ public class JettyLogger implements LocationAwareLogger, Logger trace(msg, t); } + @Override + public boolean isTraceEnabled() + { + return level.includes(JettyLevel.TRACE); + } + + @Override + public boolean isTraceEnabled(Marker marker) + { + return isTraceEnabled(); + } + @Override public void warn(String msg) { @@ -602,12 +564,6 @@ public class JettyLogger implements LocationAwareLogger, Logger } } - @Override - public boolean isWarnEnabled(Marker marker) - { - return isWarnEnabled(); - } - @Override public void warn(Marker marker, String msg) { @@ -643,6 +599,18 @@ public class JettyLogger implements LocationAwareLogger, Logger warn(msg, t); } + @Override + public boolean isWarnEnabled() + { + return level.includes(JettyLevel.WARN); + } + + @Override + public boolean isWarnEnabled(Marker marker) + { + return isWarnEnabled(); + } + private void emit(Level level, String msg) { long timestamp = System.currentTimeMillis(); @@ -684,6 +652,33 @@ public class JettyLogger implements LocationAwareLogger, Logger getAppender().emit(this, level, timestamp, threadName, throwable, msg); } + /** + * Entry point for {@link LocationAwareLogger} + */ + @Override + public void log(Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable throwable) + { + if (this.level.toInt() <= levelInt) + { + long timestamp = System.currentTimeMillis(); + String threadName = Thread.currentThread().getName(); + getAppender().emit(this, JettyLevel.intToLevel(levelInt).toLevel(), timestamp, threadName, throwable, message, argArray); + } + } + + /** + * Dynamic (via Reflection) entry point for {@link SubstituteLogger} usage. + * + * @param event the logging event + */ + @SuppressWarnings("unused") + public void log(LoggingEvent event) + { + // TODO: do we want to support org.sfl4j.Marker? + // TODO: do we want to support org.sfl4j.even.KeyValuePair? + getAppender().emit(this, event.getLevel(), event.getTimeStamp(), event.getThreadName(), event.getThrowable(), event.getMessage(), event.getArgumentArray()); + } + @Override public String toString() { diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index 2f4662aeb34..1f9f28b985d 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -145,7 +145,7 @@ public class JettyLoggerConfiguration if (level == null) { System.err.printf("Unknown JettyLogger/Slf4J Level [%s]=[%s], expecting only [%s] as values.", - loggerName, levelStr, Stream.of(JettyLevel.values()).map(JettyLevel::toString).collect(Collectors.joining(", "))); + loggerName, levelStr, Stream.of(JettyLevel.values()).map(JettyLevel::name).collect(Collectors.joining(", "))); } return level; } diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java index 389a25dbfd3..aa0bda76539 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java @@ -154,7 +154,7 @@ public class JettyLoggerFactory implements ILoggerFactory, JettyLoggerFactoryMBe { JettyLogger logger = loggerMap.get(key); if (logger != null) - return logger.getLevel().toString(); + return logger.getLevel().name(); return null; }); } diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index 823aeba8b8d..6cd7e3fb95a 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -55,7 +55,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.event.Level; import org.xml.sax.SAXException; import static java.nio.charset.StandardCharsets.UTF_8; @@ -1602,7 +1601,7 @@ public class XmlConfigurationTest // capture events appender.setStream(new PrintStream(logBytes, true)); // make sure we are seeing WARN level events - jettyLogger.setLevel(Level.WARN); + jettyLogger.setLevel(JettyLevel.WARN); action.run(); } From 41f6e3df5127c3ac01efa8202b3465b2cfa0be88 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 8 May 2020 22:16:24 +0200 Subject: [PATCH 10/77] Issue #4830 - Add JMX to new Jetty 10 jetty-slf4j-impl. Updates after review, take 2. Signed-off-by: Simone Bordet --- .../eclipse/jetty/logging/JettyLoggerConfiguration.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java index 1f9f28b985d..27097b2bd2f 100644 --- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java +++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java @@ -23,11 +23,10 @@ import java.io.InputStream; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import java.util.Locale; import java.util.Properties; import java.util.TimeZone; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * JettyLogger specific configuration: @@ -137,15 +136,15 @@ public class JettyLoggerConfiguration return level != null ? level : DEFAULT_LEVEL; } - protected static JettyLevel toJettyLevel(String loggerName, String levelStr) + static JettyLevel toJettyLevel(String loggerName, String levelStr) { if (levelStr == null) return null; JettyLevel level = JettyLevel.strToLevel(levelStr); if (level == null) { - System.err.printf("Unknown JettyLogger/Slf4J Level [%s]=[%s], expecting only [%s] as values.", - loggerName, levelStr, Stream.of(JettyLevel.values()).map(JettyLevel::name).collect(Collectors.joining(", "))); + System.err.printf("Unknown JettyLogger/SLF4J Level [%s]=[%s], expecting only %s as values.%n", + loggerName, levelStr, Arrays.toString(JettyLevel.values())); } return level; } From 933ab641ee3f042200e73855a419f1aa33a21f92 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 11 May 2020 15:38:15 +1000 Subject: [PATCH 11/77] test helper 5.4 Signed-off-by: olivier lamy --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b3715f08d7..ada9444a5af 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ false - 5.3 + 5.4 2.1.1.RELEASE 1.0 1.3 From c497b61917a4e4fd09bb098bd264bf06e62db317 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 11 May 2020 13:57:17 +0200 Subject: [PATCH 12/77] Issue #4860 NPE from HttpFields Paranoid catch if sending and exception page throws an exception. Signed-off-by: Greg Wilkins --- .../java/org/eclipse/jetty/server/HttpChannel.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index de21a050398..a1a14623f6e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -432,8 +432,17 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor abort(x); else { - _response.resetContent(); - sendResponseAndComplete(); + try + { + _response.resetContent(); + sendResponseAndComplete(); + } + catch (Throwable t) + { + if (x != t) + x.addSuppressed(t); + abort(x); + } } } finally From 6af6af6419b43fce0c7c291579677681f901b676 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 11 May 2020 13:58:27 +0200 Subject: [PATCH 13/77] Issue #4860 NPE from HttpFields Improved test coverage Signed-off-by: Greg Wilkins --- .../eclipse/jetty/http/HttpFieldsTest.java | 235 ++++++++++++------ 1 file changed, 163 insertions(+), 72 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index 7175f00dc16..2ce6124642e 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -19,13 +19,13 @@ package org.eclipse.jetty.http; import java.nio.ByteBuffer; -import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Locale; import java.util.NoSuchElementException; +import java.util.stream.Collectors; import org.eclipse.jetty.util.BufferUtil; import org.hamcrest.Matchers; @@ -34,6 +34,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -49,30 +50,25 @@ public class HttpFieldsTest { HttpFields header = new HttpFields(); - header.put("name0", "value:0"); - header.put("name1", "value1"); + header.add("name0", "wrong"); + header.add(HttpHeader.ACCEPT, "nothing"); + header.add("name0", "still wrong"); + header.add(HttpHeader.ACCEPT, "money"); + + header.put("name0", "value0"); + header.put(HttpHeader.ACCEPT, "praise"); assertEquals(2, header.size()); - assertEquals("value:0", header.get("name0")); - assertEquals("value1", header.get("name1")); + assertEquals("value0", header.get("name0")); + assertEquals("praise", header.get("accept")); assertNull(header.get("name2")); - int matches = 0; - Enumeration e = header.getFieldNames(); - while (e.hasMoreElements()) - { - Object o = e.nextElement(); - if ("name0".equals(o)) - matches++; - if ("name1".equals(o)) - matches++; - } - assertEquals(2, matches); + header.add("name0", "wrong"); + header.add(HttpHeader.ACCEPT, "nothing"); - e = header.getValues("name0"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value:0"); - assertEquals(false, e.hasMoreElements()); + header.put("name0", (String)null); + header.put(HttpHeader.ACCEPT, (String)null); + assertEquals(0, header.size()); } @Test @@ -124,6 +120,29 @@ public class HttpFieldsTest }); } + @Test + public void testGetValuesList() throws Exception + { + HttpFields header = new HttpFields(); + + header.add("name0", "value0"); + header.add("name1", "value1a"); + header.add(HttpHeader.ACCEPT, "something"); + header.add("name2", "value2"); + header.add("name1", "value1b"); + header.add(HttpHeader.ACCEPT, "everything"); + + assertThat(header.getValuesList("unknown").size(), is(0)); + assertThat(header.getValuesList(HttpHeader.CONNECTION).size(), is(0)); + assertThat(header.getValuesList("name0"), contains("value0")); + assertThat(header.getValuesList("name1"), contains("value1a", "value1b")); + assertThat(header.getValuesList(HttpHeader.ACCEPT), contains("something", "everything")); + + assertThat(header.getFields(HttpHeader.CONNECTION).size(), is(0)); + assertThat(header.getFields(HttpHeader.ACCEPT).stream().map(HttpField::getValue).collect(Collectors.toList()), + contains("something", "everything")); + } + @Test public void testGetKnown() throws Exception { @@ -266,39 +285,47 @@ public class HttpFieldsTest fields.add("name0", "value0"); fields.add("name1", "valueA"); - fields.add("name2", "value2"); + fields.add(HttpHeader.ACCEPT, "everything"); assertEquals("value0", fields.get("name0")); assertEquals("valueA", fields.get("name1")); - assertEquals("value2", fields.get("name2")); + assertEquals("everything", fields.get("accept")); fields.add("name1", "valueB"); + fields.add(HttpHeader.ACCEPT, "nothing"); + fields.add("name1", null); + // fields.add(HttpHeader.ACCEPT, (String)null); TODO this one throws IAE. Should make the same as the others. + + fields.add("name2", "value2"); assertEquals("value0", fields.get("name0")); assertEquals("valueA", fields.get("name1")); assertEquals("value2", fields.get("name2")); assertNull(fields.get("name3")); - int matches = 0; - Enumeration e = fields.getFieldNames(); - while (e.hasMoreElements()) - { - Object o = e.nextElement(); - if ("name0".equals(o)) - matches++; - if ("name1".equals(o)) - matches++; - if ("name2".equals(o)) - matches++; - } - assertEquals(3, matches); + assertThat(fields.getValuesList("name1"), contains("valueA", "valueB")); + assertThat(fields.getValuesList(HttpHeader.ACCEPT), contains("everything", "nothing")); - e = fields.getValues("name1"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "valueA"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "valueB"); - assertEquals(false, e.hasMoreElements()); + fields.add(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE); + fields.add(HttpHeader.CONNECTION, (HttpHeaderValue)null); + assertThat(fields.getValuesList("Connection"), contains("close")); + } + + @Test + public void testAddAll() throws Exception + { + HttpFields fields0 = new HttpFields(); + assertThat(fields0.size(), is(0)); + HttpFields fields1 = new HttpFields(fields0); + assertThat(fields1.size(), is(0)); + + fields0.add("name0", "value0"); + fields0.add("name1", "valueA"); + fields0.add("name2", "value2"); + + fields1.addAll(fields0); + assertThat(fields1.size(), is(3)); + assertThat(fields0, is(fields1)); } @Test @@ -381,44 +408,44 @@ public class HttpFieldsTest assertEquals(false, e.hasMoreElements()); } + @Test + public void testAddCSV() throws Exception + { + HttpFields fields = new HttpFields(); + fields.addCSV(HttpHeader.CONNECTION); + fields.addCSV("name"); + assertThat(fields.size(), is(0)); + + fields.addCSV(HttpHeader.CONNECTION, "one"); + fields.addCSV("name", "one"); + assertThat(fields.getValuesList("name"), contains("one")); + assertThat(fields.getValuesList(HttpHeader.CONNECTION), contains("one")); + + fields.addCSV(HttpHeader.CONNECTION, "two"); + fields.addCSV("name", "two"); + assertThat(fields.getValuesList("name"), contains("one", "two")); + assertThat(fields.getValuesList(HttpHeader.CONNECTION), contains("one", "two")); + + fields.addCSV(HttpHeader.CONNECTION, "one", "three", "four"); + fields.addCSV("name", "one", "three", "four"); + assertThat(fields.getValuesList("name"), contains("one", "two", "three, four")); + assertThat(fields.getValuesList(HttpHeader.CONNECTION), contains("one", "two", "three, four")); + } + @Test public void testGetCSV() throws Exception { HttpFields fields = new HttpFields(); - fields.put("name0", "value0A,value0B"); - fields.add("name0", "value0C,value0D"); + fields.put(HttpHeader.ACCEPT, "valueA, \"value, B\""); + fields.add(HttpHeader.ACCEPT, "\"valueC\",valueD"); fields.put("name1", "value1A, \"value\t, 1B\" "); fields.add("name1", "\"value1C\",\tvalue1D"); - Enumeration e = fields.getValues("name0"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0A,value0B"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0C,value0D"); - assertEquals(false, e.hasMoreElements()); - - e = Collections.enumeration(fields.getCSV("name0", false)); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0A"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0B"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0C"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value0D"); - assertEquals(false, e.hasMoreElements()); - - e = Collections.enumeration(fields.getCSV("name1", false)); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value1A"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value\t, 1B"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value1C"); - assertEquals(true, e.hasMoreElements()); - assertEquals(e.nextElement(), "value1D"); - assertEquals(false, e.hasMoreElements()); + assertThat(fields.getCSV(HttpHeader.ACCEPT, false), contains("valueA", "value, B", "valueC", "valueD")); + assertThat(fields.getCSV(HttpHeader.ACCEPT, true), contains("valueA", "\"value, B\"", "\"valueC\"", "valueD")); + assertThat(fields.getCSV("name1", false), contains("value1A", "value\t, 1B", "value1C", "value1D")); + assertThat(fields.getCSV("name1", true), contains("value1A", "\"value\t, 1B\"", "\"value1C\"", "value1D")); } @Test @@ -659,10 +686,12 @@ public class HttpFieldsTest assertTrue(header.contains(new HttpField("N5", "def"))); assertTrue(header.contains(new HttpField("accept", "abc"))); + assertTrue(header.contains(HttpHeader.ACCEPT)); assertTrue(header.contains(HttpHeader.ACCEPT, "abc")); assertFalse(header.contains(new HttpField("N5", "xyz"))); assertFalse(header.contains(new HttpField("N8", "def"))); assertFalse(header.contains(HttpHeader.ACCEPT, "def")); + assertFalse(header.contains(HttpHeader.AGE)); assertFalse(header.contains(HttpHeader.AGE, "abc")); assertFalse(header.containsKey("n11")); @@ -693,7 +722,7 @@ public class HttpFieldsTest } @Test - public void testPreventNullField() + public void testPreventNullFieldName() { HttpFields fields = new HttpFields(); assertThrows(NullPointerException.class, () -> @@ -703,6 +732,27 @@ public class HttpFieldsTest }); } + @Test + public void testPreventNullField() + { + // Attempt various ways that may have put a null field in the array that + // previously caused a NPE in put. If this test doesn't throw then it passes. + HttpFields fields = new HttpFields(); + fields.add((HttpField)null); + fields.put((HttpField)null); + fields.put("something", "else"); + ListIterator iter = fields.listIterator(); + iter.next(); + iter.set(null); + iter.add(null); + fields.put("something", "other"); + iter = fields.listIterator(); + iter.next(); + iter.remove(); + fields.put("something", "other"); + fields.clear(); + } + @Test public void testIteration() throws Exception { @@ -730,29 +780,58 @@ public class HttpFieldsTest ListIterator l = header.listIterator(); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(0)); + assertThat(l.previousIndex(), is(-1)); + l.add(new HttpField("name0", "value")); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(1)); + assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(0)); + assertThat(l.next().getName(), is("name1")); + assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(2)); + assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(1)); + l.set(new HttpField("NAME1", "value")); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(2)); assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(1)); + assertThat(l.previous().getName(), is("NAME1")); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(1)); assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(0)); + assertThat(l.previous().getName(), is("name0")); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(0)); assertThat(l.hasPrevious(), is(false)); + assertThat(l.previousIndex(), is(-1)); + assertThat(l.next().getName(), is("name0")); assertThat(l.hasNext(), is(true)); + assertThat(l.nextIndex(), is(1)); assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(0)); + assertThat(l.next().getName(), is("NAME1")); l.add(new HttpField("name2", "value")); assertThat(l.next().getName(), is("name3")); assertThat(l.hasNext(), is(false)); + assertThat(l.nextIndex(), is(4)); assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(3)); + l.add(new HttpField("name4", "value")); assertThat(l.hasNext(), is(false)); + assertThat(l.nextIndex(), is(5)); assertThat(l.hasPrevious(), is(true)); + assertThat(l.previousIndex(), is(4)); assertThat(l.previous().getName(), is("name4")); i = header.iterator(); @@ -764,4 +843,16 @@ public class HttpFieldsTest assertThat(i.next().getName(), is("name4")); assertThat(i.hasNext(), is(false)); } + + @Test + public void testStream() throws Exception + { + HttpFields header = new HttpFields(); + assertThat(header.stream().count(), is(0L)); + header.put("name1", "valueA"); + header.put("name2", "valueB"); + header.add("name3", "valueC"); + assertThat(header.stream().count(), is(3L)); + assertThat(header.stream().map(HttpField::getName).filter("name2"::equalsIgnoreCase).count(), is(1L)); + } } From 1ac7fe4f9c0726c70102e83fe4e3a93901d9872c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 11 May 2020 14:00:04 +0200 Subject: [PATCH 14/77] Issue #4860 NPE from HttpFields + Fix bug with list iterator nextIndex + List iterator cannot inject null fields + minor cleanups Signed-off-by: Greg Wilkins --- .../org/eclipse/jetty/http/HttpFields.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 316ea07245a..3787fc627f8 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -303,14 +303,18 @@ public class HttpFields implements Iterable */ public List getValuesList(String name) { - final List list = new ArrayList<>(); + List list = null; for (int i = 0; i < _size; i++) { HttpField f = _fields[i]; if (f.getName().equalsIgnoreCase(name)) + { + if (list == null) + list = new ArrayList<>(size() - i); list.add(f.getValue()); + } } - return list; + return list == null ? Collections.emptyList() : list; } /** @@ -711,7 +715,8 @@ public class HttpFields implements Iterable public void add(HttpHeader header, HttpHeaderValue value) { - add(header, value.toString()); + if (value != null) + add(header, value.toString()); } /** @@ -966,8 +971,11 @@ public class HttpFields implements Iterable * * @param fields the fields to add */ + @Deprecated public void add(HttpFields fields) { + // TODO this implementation doesn't do what the javadoc says and is really the same + // as addAll, which is renamed to add anyway in 10. if (fields == null) return; @@ -1185,7 +1193,7 @@ public class HttpFields implements Iterable @Override public int nextIndex() { - return _cursor + 1; + return _cursor; } @Override @@ -1199,16 +1207,22 @@ public class HttpFields implements Iterable { if (_current < 0) throw new IllegalStateException(); - _fields[_current] = field; + if (field == null) + remove(); + else + _fields[_current] = field; } @Override public void add(HttpField field) { - _fields = Arrays.copyOf(_fields, _fields.length + 1); - System.arraycopy(_fields, _cursor, _fields, _cursor + 1, _size++); - _fields[_cursor++] = field; - _current = -1; + if (field != null) + { + _fields = Arrays.copyOf(_fields, _fields.length + 1); + System.arraycopy(_fields, _cursor, _fields, _cursor + 1, _size++); + _fields[_cursor++] = field; + _current = -1; + } } } } From 2c7c98f4690d2db399005b48dd42e9d2f5131edd Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 11 May 2020 10:03:12 -0500 Subject: [PATCH 15/77] Eliminate warnings Signed-off-by: Joakim Erdfelt --- .../eclipse/jetty/http/HttpFieldsTest.java | 138 +++++++----------- 1 file changed, 51 insertions(+), 87 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index 2ce6124642e..e4bf4781d78 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -46,7 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class HttpFieldsTest { @Test - public void testPut() throws Exception + public void testPut() { HttpFields header = new HttpFields(); @@ -72,7 +72,7 @@ public class HttpFieldsTest } @Test - public void testPutTo() throws Exception + public void testPutTo() { HttpFields header = new HttpFields(); @@ -93,7 +93,7 @@ public class HttpFieldsTest } @Test - public void testGet() throws Exception + public void testGet() { HttpFields header = new HttpFields(); @@ -104,24 +104,21 @@ public class HttpFieldsTest assertEquals("value0", header.get("Name0")); assertEquals("value1", header.get("name1")); assertEquals("value1", header.get("Name1")); - assertEquals(null, header.get("Name2")); + assertNull(header.get("Name2")); assertEquals("value0", header.getField("name0").getValue()); assertEquals("value0", header.getField("Name0").getValue()); assertEquals("value1", header.getField("name1").getValue()); assertEquals("value1", header.getField("Name1").getValue()); - assertEquals(null, header.getField("Name2")); + assertNull(header.getField("Name2")); assertEquals("value0", header.getField(0).getValue()); assertEquals("value1", header.getField(1).getValue()); - assertThrows(NoSuchElementException.class, () -> - { - header.getField(2); - }); + assertThrows(NoSuchElementException.class, () -> header.getField(2)); } @Test - public void testGetValuesList() throws Exception + public void testGetValuesList() { HttpFields header = new HttpFields(); @@ -144,7 +141,7 @@ public class HttpFieldsTest } @Test - public void testGetKnown() throws Exception + public void testGetKnown() { HttpFields header = new HttpFields(); @@ -157,12 +154,12 @@ public class HttpFieldsTest assertEquals("value0", header.getField(HttpHeader.CONNECTION).getValue()); assertEquals("value1", header.getField(HttpHeader.ACCEPT).getValue()); - assertEquals(null, header.getField(HttpHeader.AGE)); - assertEquals(null, header.get(HttpHeader.AGE)); + assertNull(header.getField(HttpHeader.AGE)); + assertNull(header.get(HttpHeader.AGE)); } @Test - public void testCRLF() throws Exception + public void testCRLF() { HttpFields header = new HttpFields(); @@ -181,7 +178,7 @@ public class HttpFieldsTest } @Test - public void testCachedPut() throws Exception + public void testCachedPut() { HttpFields header = new HttpFields(); @@ -201,7 +198,7 @@ public class HttpFieldsTest } @Test - public void testRePut() throws Exception + public void testRePut() { HttpFields header = new HttpFields(); @@ -235,13 +232,13 @@ public class HttpFieldsTest assertEquals(3, matches); e = header.getValues("name1"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value1"); - assertEquals(false, e.hasMoreElements()); + assertFalse(e.hasMoreElements()); } @Test - public void testRemovePut() throws Exception + public void testRemovePut() { HttpFields header = new HttpFields(1); @@ -275,11 +272,11 @@ public class HttpFieldsTest assertEquals(2, matches); e = header.getValues("name1"); - assertEquals(false, e.hasMoreElements()); + assertFalse(e.hasMoreElements()); } @Test - public void testAdd() throws Exception + public void testAdd() { HttpFields fields = new HttpFields(); @@ -312,7 +309,7 @@ public class HttpFieldsTest } @Test - public void testAddAll() throws Exception + public void testAddAll() { HttpFields fields0 = new HttpFields(); assertThat(fields0.size(), is(0)); @@ -369,7 +366,7 @@ public class HttpFieldsTest } @Test - public void testGetValues() throws Exception + public void testGetValues() { HttpFields fields = new HttpFields(); @@ -379,37 +376,39 @@ public class HttpFieldsTest fields.add("name1", "\"value1C\",\tvalue1D"); Enumeration e = fields.getValues("name0"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0A,value0B"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0C,value0D"); - assertEquals(false, e.hasMoreElements()); + assertFalse(e.hasMoreElements()); + //noinspection deprecation e = fields.getValues("name0", ","); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0A"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0B"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0C"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value0D"); - assertEquals(false, e.hasMoreElements()); + assertFalse(e.hasMoreElements()); + //noinspection deprecation e = fields.getValues("name1", ","); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value1A"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value\t, 1B"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value1C"); - assertEquals(true, e.hasMoreElements()); + assertTrue(e.hasMoreElements()); assertEquals(e.nextElement(), "value1D"); - assertEquals(false, e.hasMoreElements()); + assertFalse(e.hasMoreElements()); } @Test - public void testAddCSV() throws Exception + public void testAddCSV() { HttpFields fields = new HttpFields(); fields.addCSV(HttpHeader.CONNECTION); @@ -433,7 +432,7 @@ public class HttpFieldsTest } @Test - public void testGetCSV() throws Exception + public void testGetCSV() { HttpFields fields = new HttpFields(); @@ -449,7 +448,7 @@ public class HttpFieldsTest } @Test - public void testAddQuotedCSV() throws Exception + public void testAddQuotedCSV() { HttpFields fields = new HttpFields(); @@ -491,7 +490,7 @@ public class HttpFieldsTest } @Test - public void testGetQualityCSV() throws Exception + public void testGetQualityCSV() { HttpFields fields = new HttpFields(); @@ -513,7 +512,7 @@ public class HttpFieldsTest } @Test - public void testGetQualityCSVHeader() throws Exception + public void testGetQualityCSVHeader() { HttpFields fields = new HttpFields(); @@ -535,7 +534,7 @@ public class HttpFieldsTest } @Test - public void testDateFields() throws Exception + public void testDateFields() { HttpFields fields = new HttpFields(); @@ -577,7 +576,7 @@ public class HttpFieldsTest } @Test - public void testNegDateFields() throws Exception + public void testNegDateFields() { HttpFields fields = new HttpFields(); @@ -595,7 +594,7 @@ public class HttpFieldsTest } @Test - public void testLongFields() throws Exception + public void testLongFields() { HttpFields header = new HttpFields(); @@ -607,47 +606,12 @@ public class HttpFieldsTest header.put("N2", "xx"); long i1 = header.getLongField("I1"); - try - { - header.getLongField("I2"); - assertTrue(false); - } - catch (NumberFormatException e) - { - assertTrue(true); - } + assertThrows(NumberFormatException.class, () -> header.getLongField("I2")); long i3 = header.getLongField("I3"); - - try - { - header.getLongField("I4"); - assertTrue(false); - } - catch (NumberFormatException e) - { - assertTrue(true); - } - - try - { - header.getLongField("N1"); - assertTrue(false); - } - catch (NumberFormatException e) - { - assertTrue(true); - } - - try - { - header.getLongField("N2"); - assertTrue(false); - } - catch (NumberFormatException e) - { - assertTrue(true); - } + assertThrows(NumberFormatException.class, () -> header.getLongField("I4")); + assertThrows(NumberFormatException.class, () -> header.getLongField("N1")); + assertThrows(NumberFormatException.class, () -> header.getLongField("N2")); assertEquals(42, i1); assertEquals(-44, i3); @@ -659,7 +623,7 @@ public class HttpFieldsTest } @Test - public void testContains() throws Exception + public void testContains() { HttpFields header = new HttpFields(); @@ -739,7 +703,7 @@ public class HttpFieldsTest // previously caused a NPE in put. If this test doesn't throw then it passes. HttpFields fields = new HttpFields(); fields.add((HttpField)null); - fields.put((HttpField)null); + fields.put(null); fields.put("something", "else"); ListIterator iter = fields.listIterator(); iter.next(); @@ -754,7 +718,7 @@ public class HttpFieldsTest } @Test - public void testIteration() throws Exception + public void testIteration() { HttpFields header = new HttpFields(); Iterator i = header.iterator(); @@ -845,7 +809,7 @@ public class HttpFieldsTest } @Test - public void testStream() throws Exception + public void testStream() { HttpFields header = new HttpFields(); assertThat(header.stream().count(), is(0L)); From 90da10dac57c9a4cf5bea85176077e5862c9589b Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 11 May 2020 10:05:56 -0500 Subject: [PATCH 16/77] Issue #4860 - Improving testPreventNullField testcase Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/http/HttpFieldsTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index e4bf4781d78..d42638e58e6 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -700,20 +700,28 @@ public class HttpFieldsTest public void testPreventNullField() { // Attempt various ways that may have put a null field in the array that - // previously caused a NPE in put. If this test doesn't throw then it passes. + // previously caused a NPE in put. HttpFields fields = new HttpFields(); - fields.add((HttpField)null); - fields.put(null); + fields.add((HttpField)null); // should not result in field being added + assertThat(fields.size(), is(0)); + fields.put(null); // should not result in field being added + assertThat(fields.size(), is(0)); fields.put("something", "else"); + assertThat(fields.size(), is(1)); ListIterator iter = fields.listIterator(); iter.next(); iter.set(null); + assertThat(fields.size(), is(0)); iter.add(null); + assertThat(fields.size(), is(0)); fields.put("something", "other"); + assertThat(fields.size(), is(1)); iter = fields.listIterator(); iter.next(); iter.remove(); + assertThat(fields.size(), is(0)); fields.put("something", "other"); + assertThat(fields.size(), is(1)); fields.clear(); } From 6ae75be9bcb7e2059804f1bffcfd18dad44c68d6 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 11 May 2020 10:34:52 -0500 Subject: [PATCH 17/77] Issue #4860 - Consistency to HttpFields API If a null name (or HttpHeader or HttpField) is used it should throw an ISE + .add() should remain consistent + .put() should remain consistent Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/http/HttpField.java | 2 +- .../org/eclipse/jetty/http/HttpFields.java | 10 +++++ .../org/eclipse/jetty/http/HttpFieldTest.java | 7 +++ .../eclipse/jetty/http/HttpFieldsTest.java | 45 +++++++++++++++++-- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java index 0d3853e19fe..e04d7e2345e 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpField.java @@ -40,7 +40,7 @@ public class HttpField if (_header != null && name == null) _name = _header.asString(); else - _name = Objects.requireNonNull(name); + _name = Objects.requireNonNull(name, "name"); _value = value; } diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 3787fc627f8..bd3171a7591 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.Set; import java.util.StringTokenizer; import java.util.function.ToIntFunction; @@ -675,6 +676,8 @@ public class HttpFields implements Iterable */ public void put(HttpHeader header, String value) { + Objects.requireNonNull(header, "header"); + if (value == null) remove(header); else @@ -689,7 +692,12 @@ public class HttpFields implements Iterable */ public void put(String name, List list) { + Objects.requireNonNull(name, "name"); + remove(name); + if (list == null) + return; + for (String v : list) { if (v != null) @@ -728,6 +736,8 @@ public class HttpFields implements Iterable */ public void add(HttpHeader header, String value) { + Objects.requireNonNull(header, "header"); + if (value == null) throw new IllegalArgumentException("null value"); diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldTest.java index ccffa9ca85d..787295a129c 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldTest.java @@ -28,6 +28,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; public class HttpFieldTest @@ -165,6 +166,12 @@ public class HttpFieldTest assertEquals("c", values[2]); } + @Test + public void testFieldNameNull() + { + assertThrows(NullPointerException.class, () -> new HttpField((String)null, null)); + } + @Test public void testCachedField() { diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index d42638e58e6..8d10cbd6e67 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.http; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -696,6 +697,44 @@ public class HttpFieldsTest }); } + @Test + public void testAddNullName() + { + HttpFields fields = new HttpFields(); + assertThrows(NullPointerException.class, () -> fields.add((String)null, "bogus")); + assertThat(fields.size(), is(0)); + + assertThrows(NullPointerException.class, () -> fields.add((HttpHeader)null, "bogus")); + assertThat(fields.size(), is(0)); + } + + @Test + public void testPutNullName() + { + HttpFields fields = new HttpFields(); + assertThrows(NullPointerException.class, () -> fields.put((String)null, "bogus")); + assertThat(fields.size(), is(0)); + + assertThrows(NullPointerException.class, () -> fields.put(null, (List)null)); + assertThat(fields.size(), is(0)); + + List emptyList = new ArrayList<>(); + assertThrows(NullPointerException.class, () -> fields.put(null, emptyList)); + assertThat(fields.size(), is(0)); + + assertThrows(NullPointerException.class, () -> fields.put((HttpHeader)null, "bogus")); + assertThat(fields.size(), is(0)); + } + + @Test + public void testPutNullValueList() + { + HttpFields fields = new HttpFields(); + + fields.put("name", (List)null); + assertThat(fields.size(), is(0)); + } + @Test public void testPreventNullField() { @@ -710,15 +749,15 @@ public class HttpFieldsTest assertThat(fields.size(), is(1)); ListIterator iter = fields.listIterator(); iter.next(); - iter.set(null); + iter.set(null); // set field to null - null entry in list now assertThat(fields.size(), is(0)); - iter.add(null); + iter.add(null); // attempt to add null entry assertThat(fields.size(), is(0)); fields.put("something", "other"); assertThat(fields.size(), is(1)); iter = fields.listIterator(); iter.next(); - iter.remove(); + iter.remove(); // remove only entry assertThat(fields.size(), is(0)); fields.put("something", "other"); assertThat(fields.size(), is(1)); From e86977394e78691807cbd8858b9f9d0632194b44 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 11 May 2020 21:48:06 +0200 Subject: [PATCH 18/77] Issue #4828 Buffer Corruption (#4864) + improve synchronization around releaseBuffer + improve synchronization around acquireBuffer + made acquireBuffer private. Signed-off-by: Greg Wilkins --- .../org/eclipse/jetty/server/HttpOutput.java | 20 ++++++++++++------- .../jetty/server/handler/ErrorHandler.java | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index 6102f535b60..a21fd36c53d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -487,8 +487,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable synchronized (_channelState) { _state = State.CLOSED; + releaseBuffer(); } - releaseBuffer(); } @Override @@ -613,10 +613,13 @@ public class HttpOutput extends ServletOutputStream implements Runnable public ByteBuffer getBuffer() { - return _aggregate; + synchronized (_channelState) + { + return acquireBuffer(); + } } - public ByteBuffer acquireBuffer() + private ByteBuffer acquireBuffer() { if (_aggregate == null) _aggregate = _channel.getByteBufferPool().acquire(getBufferSize(), _interceptor.isOptimizedForDirectBuffers()); @@ -1410,10 +1413,13 @@ public class HttpOutput extends ServletOutputStream implements Runnable public void resetBuffer() { - _interceptor.resetBuffer(); - if (BufferUtil.hasContent(_aggregate)) - BufferUtil.clear(_aggregate); - _written = 0; + synchronized (_channelState) + { + _interceptor.resetBuffer(); + if (BufferUtil.hasContent(_aggregate)) + BufferUtil.clear(_aggregate); + _written = 0; + } } @Override diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java index 7d11d60bdd4..174d84670f6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java @@ -305,7 +305,7 @@ public class ErrorHandler extends AbstractHandler // TODO error page may cause a BufferOverflow. In which case we try // TODO again with stacks disabled. If it still overflows, it is // TODO written without a body. - ByteBuffer buffer = baseRequest.getResponse().getHttpOutput().acquireBuffer(); + ByteBuffer buffer = baseRequest.getResponse().getHttpOutput().getBuffer(); ByteBufferOutputStream out = new ByteBufferOutputStream(buffer); PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, charset)); From 59a66158ed0c12dd10cec842b0ccf595cbe2e4eb Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Mon, 11 May 2020 22:09:19 +0200 Subject: [PATCH 19/77] Issue #4860 NPE HttpFields Fixes from review. Fixed iterator overflow bug clearer updates of size better nonNull messages Signed-off-by: Greg Wilkins --- .../org/eclipse/jetty/http/HttpFields.java | 18 +++++++++++------- .../org/eclipse/jetty/http/HttpFieldsTest.java | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index bd3171a7591..019b8601fc8 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -636,7 +636,8 @@ public class HttpFields implements Iterable { if (put) { - System.arraycopy(_fields, i + 1, _fields, i, --_size - i); + _size--; + System.arraycopy(_fields, i + 1, _fields, i, _size - i); } else { @@ -676,7 +677,7 @@ public class HttpFields implements Iterable */ public void put(HttpHeader header, String value) { - Objects.requireNonNull(header, "header"); + Objects.requireNonNull(header, "header must not be null"); if (value == null) remove(header); @@ -692,7 +693,7 @@ public class HttpFields implements Iterable */ public void put(String name, List list) { - Objects.requireNonNull(name, "name"); + Objects.requireNonNull(name, "name must not be null"); remove(name); if (list == null) @@ -736,7 +737,7 @@ public class HttpFields implements Iterable */ public void add(HttpHeader header, String value) { - Objects.requireNonNull(header, "header"); + Objects.requireNonNull(header, "header must not be null"); if (value == null) throw new IllegalArgumentException("null value"); @@ -760,7 +761,8 @@ public class HttpFields implements Iterable if (f.getHeader() == name) { removed = f; - System.arraycopy(_fields, i + 1, _fields, i, --_size - i); + _size--; + System.arraycopy(_fields, i + 1, _fields, i, _size - i); } } return removed; @@ -781,7 +783,8 @@ public class HttpFields implements Iterable if (f.getName().equalsIgnoreCase(name)) { removed = f; - System.arraycopy(_fields, i + 1, _fields, i, --_size - i); + _size--; + System.arraycopy(_fields, i + 1, _fields, i, _size - i); } } return removed; @@ -1229,8 +1232,9 @@ public class HttpFields implements Iterable if (field != null) { _fields = Arrays.copyOf(_fields, _fields.length + 1); - System.arraycopy(_fields, _cursor, _fields, _cursor + 1, _size++); + System.arraycopy(_fields, _cursor, _fields, _cursor + 1, _size - _cursor); _fields[_cursor++] = field; + _size++; _current = -1; } } diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index 8d10cbd6e67..b24b623a3ba 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -767,7 +767,7 @@ public class HttpFieldsTest @Test public void testIteration() { - HttpFields header = new HttpFields(); + HttpFields header = new HttpFields(5); Iterator i = header.iterator(); assertThat(i.hasNext(), is(false)); From 4dc024b2b1b4d84493675403df77e2724bed831f Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 11 May 2020 17:25:49 -0500 Subject: [PATCH 20/77] Issue #4860 - Fixing test comment Signed-off-by: Joakim Erdfelt --- .../src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index 8d10cbd6e67..9becdd06e1f 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -749,7 +749,7 @@ public class HttpFieldsTest assertThat(fields.size(), is(1)); ListIterator iter = fields.listIterator(); iter.next(); - iter.set(null); // set field to null - null entry in list now + iter.set(null); // set field to null - should result in noop assertThat(fields.size(), is(0)); iter.add(null); // attempt to add null entry assertThat(fields.size(), is(0)); From 11d14a65b44877c69eaefb86bd1fac7bebe86d1b Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 12 May 2020 15:10:44 +1000 Subject: [PATCH 21/77] Issue #2173 & #2174 - Split websocket-core into client/server/common modules Signed-off-by: Lachlan Roberts --- jetty-bom/pom.xml | 12 ++- .../eclipse/jetty/osgi/test/TestOSGiUtil.java | 18 +--- jetty-websocket/pom.xml | 11 ++- jetty-websocket/websocket-core-client/pom.xml | 82 ++++++++++++++++++ .../src/main/config/modules/websocket.mod | 0 .../src/main/java/module-info.java | 29 +++++++ .../core/client/ClientUpgradeRequest.java | 4 +- .../core/client/HttpClientProvider.java | 0 .../core/client/HttpUpgraderOverHTTP.java | 0 .../core/client/HttpUpgraderOverHTTP2.java | 0 .../core/client/UpgradeListener.java | 0 .../core/client/WebSocketCoreClient.java | 2 +- .../core/client/XmlHttpClientProvider.java | 0 jetty-websocket/websocket-core-common/pom.xml | 80 +++++++++++++++++ .../src/main/config/modules/websocket.mod | 11 +++ .../src/main/java/module-info.java | 14 +-- .../websocket/core/AbstractExtension.java | 0 .../jetty/websocket/core/Behavior.java | 0 .../jetty/websocket/core/CloseStatus.java | 11 +-- .../jetty/websocket/core/Configuration.java | 0 .../jetty/websocket/core/CoreSession.java | 0 .../jetty/websocket/core/Extension.java | 0 .../jetty/websocket/core/ExtensionConfig.java | 4 +- .../eclipse/jetty/websocket/core/Frame.java | 6 +- .../jetty/websocket/core/FrameHandler.java | 10 +-- .../jetty/websocket/core/IncomingFrames.java | 0 .../jetty/websocket/core/MessageHandler.java | 0 .../eclipse/jetty/websocket/core/OpCode.java | 0 .../jetty/websocket/core/OutgoingFrames.java | 0 .../websocket/core/WebSocketComponents.java | 29 ++----- .../websocket/core/WebSocketConstants.java | 0 .../core/WebSocketExtensionRegistry.java | 2 +- .../core/exception/BadPayloadException.java | 0 .../core/exception/CloseException.java | 2 +- .../exception/MessageTooLargeException.java | 0 .../core/exception/ProtocolException.java | 0 .../core/exception/UpgradeException.java | 0 .../core/exception/WebSocketException.java | 0 .../exception/WebSocketTimeoutException.java | 0 .../WebSocketWriteTimeoutException.java | 0 .../core/internal/ExtensionStack.java | 2 +- .../core/internal/FragmentExtension.java | 0 .../core/internal/FragmentingFlusher.java | 0 .../core/internal/FrameCaptureExtension.java | 4 +- .../websocket/core/internal/FrameEntry.java | 0 .../websocket/core/internal/FrameFlusher.java | 2 +- .../core/internal/FrameSequence.java | 0 .../websocket/core/internal/Generator.java | 0 .../core/internal/IdentityExtension.java | 0 .../websocket/core/internal/Negotiated.java | 0 .../core/internal/NullAppendable.java | 0 .../jetty/websocket/core/internal/Parser.java | 0 .../internal/PerMessageDeflateExtension.java | 0 .../core/internal/TransformingFlusher.java | 0 .../core/internal/ValidationExtension.java | 0 .../core/internal/WebSocketConnection.java | 4 +- .../core/internal/WebSocketCore.java | 0 .../core/internal/WebSocketCoreSession.java | 24 ++--- .../core/internal/WebSocketSessionState.java | 0 ...org.eclipse.jetty.websocket.core.Extension | 0 jetty-websocket/websocket-core-server/pom.xml | 76 ++++++++++++++++ .../src/main/config/modules/websocket.mod | 11 +++ .../src/main/java/module-info.java | 26 ++++++ .../websocket/core/server/Handshaker.java | 0 .../websocket/core/server/Negotiation.java | 0 .../core/server/WebSocketNegotiator.java | 0 .../server/WebSocketServerComponents.java | 51 +++++++++++ .../core/server/WebSocketUpgradeHandler.java | 0 .../server/internal/AbstractHandshaker.java | 18 +++- .../server/internal/HandshakerSelector.java | 0 .../server/internal/RFC6455Handshaker.java | 0 .../server/internal/RFC6455Negotiation.java | 0 .../server/internal/RFC8441Handshaker.java | 0 .../server/internal/RFC8441Negotiation.java | 0 .../fuzzingclient.json | 0 .../fuzzingserver.json | 0 .../pom.xml | 44 ++-------- .../jetty/websocket/core/AcceptHashTest.java | 0 .../websocket/core/AutoFragmentTest.java | 0 .../websocket/core/CapturedHexPayloads.java | 2 +- .../jetty/websocket/core/CloseStatusTest.java | 0 .../websocket/core/EchoFrameHandler.java | 0 .../jetty/websocket/core/FlushTest.java | 4 +- .../jetty/websocket/core/FrameBufferTest.java | 4 +- .../core/GeneratorFrameFlagsTest.java | 2 +- .../core/GeneratorParserRoundTripTest.java | 2 +- .../jetty/websocket/core/GeneratorTest.java | 6 +- .../websocket/core/IncomingFramesCapture.java | 0 .../websocket/core/MessageHandlerTest.java | 2 +- .../jetty/websocket/core/OpCodeTest.java | 0 .../websocket/core/OutgoingFramesCapture.java | 0 .../core/OutgoingNetworkBytesCapture.java | 2 +- .../core/ParsePayloadLengthTest.java | 0 .../core/ParserBadCloseStatusCodesTest.java | 2 +- .../websocket/core/ParserBadOpCodesTest.java | 2 +- .../jetty/websocket/core/ParserCapture.java | 0 .../core/ParserGoodCloseStatusCodesTest.java | 0 .../websocket/core/ParserReservedBitTest.java | 0 .../jetty/websocket/core/ParserTest.java | 0 .../jetty/websocket/core/RawFrameBuilder.java | 0 .../core/SynchronousFrameHandler.java | 0 .../websocket/core/TestAsyncFrameHandler.java | 0 .../websocket/core/TestFrameHandler.java | 0 .../websocket/core/TestMessageHandler.java | 0 .../websocket/core/TestUpgradeHandler.java | 0 .../core/TestWebSocketNegotiator.java | 0 .../core/TestWebSocketUpgradeHandler.java | 0 .../jetty/websocket/core/Timeouts.java | 0 .../websocket/core/WebSocketCloseTest.java | 2 +- .../websocket/core/WebSocketFrameTest.java | 2 +- .../core/WebSocketNegotiationTest.java | 2 +- .../websocket/core/WebSocketOpenTest.java | 4 +- .../jetty/websocket/core/WebSocketServer.java | 0 .../jetty/websocket/core/WebSocketTester.java | 2 +- .../core/autobahn/AutobahnFrameHandler.java | 0 .../core/autobahn/CoreAutobahnClient.java | 6 +- .../core/autobahn/CoreAutobahnServer.java | 0 .../core/chat/ChatWebSocketClient.java | 8 +- .../core/chat/ChatWebSocketServer.java | 2 +- .../client/WebSocketClientServerTest.java | 2 +- .../extensions/AbstractExtensionTest.java | 0 .../core/extensions/ExtensionConfigTest.java | 0 .../core/extensions/ExtensionStackTest.java | 0 .../core/extensions/ExtensionTool.java | 8 +- .../extensions/FragmentExtensionTest.java | 0 .../extensions/IdentityExtensionTest.java | 0 .../PerMessageDeflateExtensionTest.java | 0 .../PerMessageDeflaterBufferSizeTest.java | 4 +- .../extensions/ValidationExtensionTest.java | 0 .../core/internal/FrameFlusherTest.java | 2 +- .../websocket/core/internal/MockEndpoint.java | 0 .../websocket/core/proxy/WebSocketProxy.java | 4 +- .../core/proxy/WebSocketProxyTest.java | 0 .../core/server/WebSocketServerTest.java | 2 +- .../test/resources/jetty-logging.properties | 0 .../src/test/resources/keystore.p12 | Bin .../websocket-javax-client/pom.xml | 20 ++--- .../src/main/java/module-info.java | 5 +- .../websocket-javax-common/pom.xml | 15 ++-- .../src/main/java/module-info.java | 8 +- .../websocket-javax-server/pom.xml | 5 -- .../main/config/modules/websocket-javax.mod | 4 +- .../src/main/java/module-info.java | 4 +- ...xWebSocketServletContainerInitializer.java | 13 +-- .../JavaxWebSocketServerContainer.java | 3 +- jetty-websocket/websocket-jetty-api/pom.xml | 8 -- .../websocket-jetty-client/pom.xml | 10 +-- .../src/main/java/module-info.java | 6 +- .../websocket-jetty-common/pom.xml | 29 ------- .../src/main/java/module-info.java | 5 +- .../websocket-jetty-server/pom.xml | 42 ++++----- .../main/config/modules/websocket-jetty.mod | 4 +- .../server/JettyWebSocketServerContainer.java | 3 +- .../server/JettyWebSocketServlet.java | 5 +- ...yWebSocketServletContainerInitializer.java | 3 +- jetty-websocket/websocket-util-server/pom.xml | 2 +- .../src/main/java/module-info.java | 2 +- .../util/server/WebSocketUpgradeFilter.java | 4 +- .../server/internal/WebSocketMapping.java | 5 +- jetty-websocket/websocket-util/pom.xml | 7 +- .../src/main/java/module-info.java | 4 +- 161 files changed, 568 insertions(+), 315 deletions(-) create mode 100644 jetty-websocket/websocket-core-client/pom.xml rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/config/modules/websocket.mod (100%) create mode 100644 jetty-websocket/websocket-core-client/src/main/java/module-info.java rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java (100%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java (100%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java (100%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java (100%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java (98%) rename jetty-websocket/{websocket-core => websocket-core-client}/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java (100%) create mode 100644 jetty-websocket/websocket-core-common/pom.xml create mode 100644 jetty-websocket/websocket-core-common/src/main/config/modules/websocket.mod rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/module-info.java (78%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/Behavior.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java (96%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/Extension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java (98%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/Frame.java (99%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java (93%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/IncomingFrames.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/OpCode.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/OutgoingFrames.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java (71%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/WebSocketConstants.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java (96%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java (97%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java (99%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java (97%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameEntry.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java (99%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/Generator.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/IdentityExtension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/Negotiated.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/TransformingFlusher.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java (99%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCore.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java (97%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java (100%) rename jetty-websocket/{websocket-core => websocket-core-common}/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.core.Extension (100%) create mode 100644 jetty-websocket/websocket-core-server/pom.xml create mode 100644 jetty-websocket/websocket-core-server/src/main/config/modules/websocket.mod create mode 100644 jetty-websocket/websocket-core-server/src/main/java/module-info.java rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java (100%) create mode 100644 jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java (93%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java (100%) rename jetty-websocket/{websocket-core => websocket-core-server}/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/fuzzingclient.json (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/fuzzingserver.json (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/pom.xml (77%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/AcceptHashTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java (95%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/CloseStatusTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java (97%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java (96%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java (97%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java (97%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/IncomingFramesCapture.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/OutgoingFramesCapture.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParsePayloadLengthTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserCapture.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserGoodCloseStatusCodesTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/RawFrameBuilder.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/SynchronousFrameHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestAsyncFrameHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestFrameHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/Timeouts.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java (95%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/AbstractExtensionTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionConfigTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionStackTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java (97%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/FragmentExtensionTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/IdentityExtensionTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java (98%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java (99%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/resources/jetty-logging.properties (100%) rename jetty-websocket/{websocket-core => websocket-core-tests}/src/test/resources/keystore.p12 (100%) diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index 0a9c50a7b59..29eb56448e4 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -381,7 +381,17 @@ org.eclipse.jetty.websocket - websocket-core + websocket-core-common + 10.0.0-SNAPSHOT + + + org.eclipse.jetty.websocket + websocket-core-client + 10.0.0-SNAPSHOT + + + org.eclipse.jetty.websocket + websocket-core-server 10.0.0-SNAPSHOT diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java index 15aaaa512e5..961ff63ec53 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java @@ -19,21 +19,11 @@ package org.eclipse.jetty.osgi.test; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; -import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.osgi.boot.OSGiServerConstants; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.util.StringUtil; @@ -43,16 +33,12 @@ import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.options.WrappedUrlProvisionOption.OverwriteMode; import org.ops4j.pax.tinybundles.core.TinyBundle; import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.ops4j.pax.url.mvn.internal.AetherBasedResolver; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; -import org.osgi.service.http.HttpService; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; @@ -195,7 +181,9 @@ public class TestOSGiUtil res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-jndi").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-plus").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty").artifactId("jetty-annotations").versionAsInProject().start()); - res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core").versionAsInProject().start()); + res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-server").versionAsInProject().start()); + res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-client").versionAsInProject().start()); + res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-common").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-util").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-util-server").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-api").versionAsInProject().start()); diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 3d74b9c9e91..b30945be593 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -14,9 +14,11 @@ http://www.eclipse.org/jetty - websocket-core - websocket-util - websocket-util-server + + websocket-core-common + websocket-core-client + websocket-core-server + websocket-core-tests websocket-jetty-api websocket-jetty-common @@ -28,6 +30,9 @@ websocket-javax-client websocket-javax-server websocket-javax-tests + + websocket-util + websocket-util-server diff --git a/jetty-websocket/websocket-core-client/pom.xml b/jetty-websocket/websocket-core-client/pom.xml new file mode 100644 index 00000000000..5924b661527 --- /dev/null +++ b/jetty-websocket/websocket-core-client/pom.xml @@ -0,0 +1,82 @@ + + + + org.eclipse.jetty.websocket + websocket-parent + 10.0.0-SNAPSHOT + + + 4.0.0 + websocket-core-client + Jetty :: Websocket :: Core :: Client + + + ${project.groupId}.core.client + + + + + org.eclipse.jetty.websocket + websocket-core-common + ${project.version} + + + org.eclipse.jetty + jetty-client + ${project.version} + + + org.eclipse.jetty + jetty-xml + ${project.version} + true + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + ban-ws-apis + + enforce + + + + + + org.eclipse.jetty.websocket:websocket-jetty-api + javax.websocket + + + + + + + ban-java-servlet-api + + enforce + + + + + + javax.servlet + servletapi + org.eclipse.jetty.orbit:javax.servlet + org.mortbay.jetty:servlet-api + jetty:servlet-api + jetty-servlet-api + + + + + + + + + + diff --git a/jetty-websocket/websocket-core/src/main/config/modules/websocket.mod b/jetty-websocket/websocket-core-client/src/main/config/modules/websocket.mod similarity index 100% rename from jetty-websocket/websocket-core/src/main/config/modules/websocket.mod rename to jetty-websocket/websocket-core-client/src/main/config/modules/websocket.mod diff --git a/jetty-websocket/websocket-core-client/src/main/java/module-info.java b/jetty-websocket/websocket-core-client/src/main/java/module-info.java new file mode 100644 index 00000000000..0e8dbf89111 --- /dev/null +++ b/jetty-websocket/websocket-core-client/src/main/java/module-info.java @@ -0,0 +1,29 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +module org.eclipse.jetty.websocket.core.client +{ + exports org.eclipse.jetty.websocket.core.client; + + requires org.slf4j; + requires transitive org.eclipse.jetty.client; + requires transitive org.eclipse.jetty.websocket.core.common; + + // Only required if using XmlHttpClientProvider. + requires static org.eclipse.jetty.xml; +} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java similarity index 98% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java index fec8515b2f7..ab74b874ec1 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/ClientUpgradeRequest.java @@ -80,8 +80,8 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon protected final CompletableFuture futureCoreSession; private final WebSocketCoreClient wsClient; private FrameHandler frameHandler; - private Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); - private List upgradeListeners = new ArrayList<>(); + private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); + private final List upgradeListeners = new ArrayList<>(); private List requestedExtensions = new ArrayList<>(); public ClientUpgradeRequest(WebSocketCoreClient webSocketClient, URI requestURI) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/UpgradeListener.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java similarity index 98% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index e4aa450d181..7795e5460c2 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -40,7 +40,7 @@ public class WebSocketCoreClient extends ContainerLifeCycle private static final Logger LOG = LoggerFactory.getLogger(WebSocketCoreClient.class); private final HttpClient httpClient; - private WebSocketComponents components; + private final WebSocketComponents components; // TODO: Things to consider for inclusion in this class (or removal if they can be set elsewhere, like HttpClient) // - AsyncWrite Idle Timeout diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java diff --git a/jetty-websocket/websocket-core-common/pom.xml b/jetty-websocket/websocket-core-common/pom.xml new file mode 100644 index 00000000000..4290b2ffb5d --- /dev/null +++ b/jetty-websocket/websocket-core-common/pom.xml @@ -0,0 +1,80 @@ + + + + org.eclipse.jetty.websocket + websocket-parent + 10.0.0-SNAPSHOT + + + 4.0.0 + websocket-core-common + Jetty :: Websocket :: Core :: Common + + + ${project.groupId}.core.common + + + + + org.eclipse.jetty + jetty-io + ${project.version} + + + org.eclipse.jetty + jetty-http + ${project.version} + + + org.slf4j + slf4j-api + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + ban-ws-apis + + enforce + + + + + + org.eclipse.jetty.websocket:websocket-jetty-api + javax.websocket + + + + + + + ban-java-servlet-api + + enforce + + + + + + javax.servlet + servletapi + org.eclipse.jetty.orbit:javax.servlet + org.mortbay.jetty:servlet-api + jetty:servlet-api + jetty-servlet-api + + + + + + + + + + diff --git a/jetty-websocket/websocket-core-common/src/main/config/modules/websocket.mod b/jetty-websocket/websocket-core-common/src/main/config/modules/websocket.mod new file mode 100644 index 00000000000..da53af6d2e2 --- /dev/null +++ b/jetty-websocket/websocket-core-common/src/main/config/modules/websocket.mod @@ -0,0 +1,11 @@ +DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html + +[description] +Enable both jetty and javax websocket modules for deployed web applications. + +[tags] +websocket + +[depend] +websocket-jetty +websocket-javax diff --git a/jetty-websocket/websocket-core/src/main/java/module-info.java b/jetty-websocket/websocket-core-common/src/main/java/module-info.java similarity index 78% rename from jetty-websocket/websocket-core/src/main/java/module-info.java rename to jetty-websocket/websocket-core-common/src/main/java/module-info.java index c2fa64dda77..c2fb2c5276c 100644 --- a/jetty-websocket/websocket-core/src/main/java/module-info.java +++ b/jetty-websocket/websocket-core-common/src/main/java/module-info.java @@ -22,22 +22,16 @@ import org.eclipse.jetty.websocket.core.internal.IdentityExtension; import org.eclipse.jetty.websocket.core.internal.PerMessageDeflateExtension; import org.eclipse.jetty.websocket.core.internal.ValidationExtension; -module org.eclipse.jetty.websocket.core +module org.eclipse.jetty.websocket.core.common { exports org.eclipse.jetty.websocket.core; - exports org.eclipse.jetty.websocket.core.client; - exports org.eclipse.jetty.websocket.core.server; exports org.eclipse.jetty.websocket.core.exception; - exports org.eclipse.jetty.websocket.core.internal to org.eclipse.jetty.util; + exports org.eclipse.jetty.websocket.core.internal to org.eclipse.jetty.websocket.core.client, org.eclipse.jetty.websocket.core.server, org.eclipse.jetty.util; - requires jetty.servlet.api; - requires transitive org.eclipse.jetty.client; - requires transitive org.eclipse.jetty.server; + requires org.eclipse.jetty.http; + requires org.eclipse.jetty.io; requires org.slf4j; - // Only required if using XmlHttpClientProvider. - requires static org.eclipse.jetty.xml; - uses Extension; provides Extension with diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Behavior.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Behavior.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Behavior.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Behavior.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java index cdbed64f7a6..e324d2c866e 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/CloseStatus.java @@ -306,15 +306,12 @@ public class CloseStatus } // Reserved / not yet allocated - if ((statusCode == 1004) || // Reserved in RFC6455 (might be defined in the future) - ((statusCode >= 1016) && (statusCode <= 2999)) || // Reserved in RFC6455 (for future revisions, and extensions) - (statusCode >= 5000)) // RFC6455 Not allowed to be used for any purpose - { - return false; - } + // RFC6455 Not allowed to be used for any purpose + return (statusCode != 1004) && // Reserved in RFC6455 (might be defined in the future) + ((statusCode < 1016) || (statusCode > 2999)) && // Reserved in RFC6455 (for future revisions, and extensions) + (statusCode < 5000); // All others are allowed - return true; } public Frame toFrame() diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Configuration.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/CoreSession.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Extension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Extension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java similarity index 98% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java index 28be0a3e4f6..10a6fbb0eb6 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/ExtensionConfig.java @@ -38,7 +38,7 @@ import org.eclipse.jetty.util.Trie; */ public class ExtensionConfig { - private static Trie CACHE = new ArrayTrie<>(512); + private static final Trie CACHE = new ArrayTrie<>(512); static { @@ -315,7 +315,7 @@ public class ExtensionConfig { private final String parameterizedName; private String name; - private Map params = new HashMap<>(); + private final Map params = new HashMap<>(); public ParamParser(String parameterizedName) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Frame.java similarity index 99% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Frame.java index 5c44d9c4e77..9f7c1a74435 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Frame.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/Frame.java @@ -193,11 +193,7 @@ public class Frame { return false; } - if (!Arrays.equals(mask, other.mask)) - { - return false; - } - return true; + return Arrays.equals(mask, other.mask); } public byte[] getMask() diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java similarity index 93% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java index 2e16bee68a2..265103b1324 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/FrameHandler.java @@ -19,8 +19,6 @@ package org.eclipse.jetty.websocket.core; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.client.ClientUpgradeRequest; -import org.eclipse.jetty.websocket.core.server.Negotiation; /** * Interface for local WebSocket Endpoint Frame handling. @@ -31,11 +29,11 @@ import org.eclipse.jetty.websocket.core.server.Negotiation; * is instantiated by the application, either: *

    *
      - *
    • On the server, the application layer must provide a {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator} instance + *
    • On the server, the application layer must provide a {@code org.eclipse.jetty.websocket.core.server.WebSocketNegotiator} instance * to negotiate and accept websocket connections, which will return the FrameHandler instance to use from - * {@link org.eclipse.jetty.websocket.core.server.WebSocketNegotiator#negotiate(Negotiation)}.
    • - *
    • On the client, the application returns the FrameHandler instance to user from the {@link ClientUpgradeRequest} - * instance that it passes to the {@link org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(ClientUpgradeRequest)} method/
    • + * {@code org.eclipse.jetty.websocket.core.server.WebSocketNegotiator#negotiate(Negotiation)}. + *
    • On the client, the application returns the FrameHandler instance to user from the {@code ClientUpgradeRequest} + * instance that it passes to the {@code org.eclipse.jetty.websocket.core.client.WebSocketCoreClient#connect(ClientUpgradeRequest)} method/
    • *
    *

    * Once instantiated the FrameHandler follows is used as follows: diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/IncomingFrames.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/IncomingFrames.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/IncomingFrames.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/IncomingFrames.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/OpCode.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/OpCode.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/OpCode.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/OpCode.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/OutgoingFrames.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/OutgoingFrames.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/OutgoingFrames.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/OutgoingFrames.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java similarity index 71% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java index 1f5d593f7fd..325132b097b 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketComponents.java @@ -19,7 +19,6 @@ package org.eclipse.jetty.websocket.core; import java.util.zip.Deflater; -import javax.servlet.ServletContext; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool; @@ -31,26 +30,14 @@ import org.eclipse.jetty.util.compression.InflaterPool; /** * A collection of components which are the resources needed for websockets such as * {@link ByteBufferPool}, {@link WebSocketExtensionRegistry}, and {@link DecoratedObjectFactory}. - * - * These components should be accessed through {@link WebSocketComponents#ensureWebSocketComponents} so that - * the instance can be shared by being stored as a bean on the ContextHandler. */ public class WebSocketComponents { - public static final String WEBSOCKET_COMPONENTS_ATTRIBUTE = WebSocketComponents.class.getName(); - - public static WebSocketComponents ensureWebSocketComponents(ServletContext servletContext) - { - // Ensure a mapping exists - WebSocketComponents components = (WebSocketComponents)servletContext.getAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE); - if (components == null) - { - components = new WebSocketComponents(); - servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, components); - } - - return components; - } + private final DecoratedObjectFactory objectFactory; + private final WebSocketExtensionRegistry extensionRegistry; + private final ByteBufferPool bufferPool; + private final InflaterPool inflaterPool; + private final DeflaterPool deflaterPool; public WebSocketComponents() { @@ -69,12 +56,6 @@ public class WebSocketComponents this.inflaterPool = inflaterPool; } - private DecoratedObjectFactory objectFactory; - private WebSocketExtensionRegistry extensionRegistry; - private ByteBufferPool bufferPool; - private InflaterPool inflaterPool; - private DeflaterPool deflaterPool; - public ByteBufferPool getBufferPool() { return bufferPool; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketConstants.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketConstants.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketConstants.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketConstants.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java similarity index 96% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java index a6b55884f68..09b6d51754a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketExtensionRegistry.java @@ -30,7 +30,7 @@ import org.eclipse.jetty.util.TypeUtil; public class WebSocketExtensionRegistry implements Iterable> { - private Map> availableExtensions = new HashMap<>(); + private final Map> availableExtensions = new HashMap<>(); public WebSocketExtensionRegistry() { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/BadPayloadException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java similarity index 97% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java index 6243d216de8..150700ec616 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/CloseException.java @@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.core.exception; @SuppressWarnings("serial") public class CloseException extends WebSocketException { - private int statusCode; + private final int statusCode; public CloseException(int closeCode, String message) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/MessageTooLargeException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/ProtocolException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/UpgradeException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketTimeoutException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/WebSocketWriteTimeoutException.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java similarity index 99% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java index 28f3232c816..ccde09f3361 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java @@ -54,7 +54,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable private List extensions; private IncomingFrames incoming; private OutgoingFrames outgoing; - private Extension[] rsvClaims = new Extension[3]; + private final Extension[] rsvClaims = new Extension[3]; public ExtensionStack(WebSocketComponents components, Behavior behavior) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentExtension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FragmentingFlusher.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java similarity index 97% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java index a4b7ccb73f4..9612f744651 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameCaptureExtension.java @@ -51,8 +51,8 @@ public class FrameCaptureExtension extends AbstractExtension private Path incomingFramesPath; private Path outgoingFramesPath; - private AtomicInteger incomingCount = new AtomicInteger(0); - private AtomicInteger outgoingCount = new AtomicInteger(0); + private final AtomicInteger incomingCount = new AtomicInteger(0); + private final AtomicInteger outgoingCount = new AtomicInteger(0); private SeekableByteChannel incomingChannel; private SeekableByteChannel outgoingChannel; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameEntry.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameEntry.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameEntry.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameEntry.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java similarity index 99% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java index c7633d291e5..e4483f6e719 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameFlusher.java @@ -511,7 +511,7 @@ public class FrameFlusher extends IteratingCallback private class Entry extends FrameEntry { private ByteBuffer headerBuffer; - private long timeOfCreation = System.currentTimeMillis(); + private final long timeOfCreation = System.currentTimeMillis(); private Entry(Frame frame, Callback callback, boolean batch) { diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/FrameSequence.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Generator.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Generator.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Generator.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Generator.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/IdentityExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/IdentityExtension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/IdentityExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/IdentityExtension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Negotiated.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Negotiated.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Negotiated.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Negotiated.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/NullAppendable.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/Parser.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/PerMessageDeflateExtension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/TransformingFlusher.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/TransformingFlusher.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/TransformingFlusher.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/TransformingFlusher.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java similarity index 99% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java index e83759e7285..0d61d603659 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketConnection.java @@ -63,8 +63,8 @@ public class WebSocketConnection extends AbstractConnection implements Connectio private long demand; private boolean fillingAndParsing; - private LongAdder messagesIn = new LongAdder(); - private LongAdder bytesIn = new LongAdder(); + private final LongAdder messagesIn = new LongAdder(); + private final LongAdder bytesIn = new LongAdder(); // Read / Parse variables private RetainableByteBuffer networkBuffer; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCore.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCore.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCore.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCore.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java similarity index 97% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java index 53de09e2191..148d2fcf0ed 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketCoreSession.java @@ -29,7 +29,6 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeoutException; import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.util.component.Dumpable; @@ -81,7 +80,6 @@ public class WebSocketCoreSession implements IncomingFrames, CoreSession, Dumpab private long maxTextMessageSize = WebSocketConstants.DEFAULT_MAX_TEXT_MESSAGE_SIZE; private Duration idleTimeout = WebSocketConstants.DEFAULT_IDLE_TIMEOUT; private Duration writeTimeout = WebSocketConstants.DEFAULT_WRITE_TIMEOUT; - private final ContextHandler contextHandler; public WebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated, WebSocketComponents components) { @@ -90,26 +88,16 @@ public class WebSocketCoreSession implements IncomingFrames, CoreSession, Dumpab this.behavior = behavior; this.negotiated = negotiated; this.demanding = handler.isDemanding(); - - if (behavior == Behavior.SERVER) - { - ContextHandler.Context context = ContextHandler.getCurrentContext(); - this.contextHandler = (context != null) ? context.getContextHandler() : null; - } - else - { - this.contextHandler = null; - } - negotiated.getExtensions().initialize(new IncomingAdaptor(), new OutgoingAdaptor(), this); } - private void handle(Runnable runnable) + /** + * Can be overridden to scope into the correct classloader before calling application code. + * @param runnable the runnable to execute. + */ + protected void handle(Runnable runnable) { - if (contextHandler != null) - contextHandler.handle(runnable); - else - runnable.run(); + runnable.run(); } /** diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketSessionState.java diff --git a/jetty-websocket/websocket-core/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.core.Extension b/jetty-websocket/websocket-core-common/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.core.Extension similarity index 100% rename from jetty-websocket/websocket-core/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.core.Extension rename to jetty-websocket/websocket-core-common/src/main/resources/META-INF/services/org.eclipse.jetty.websocket.core.Extension diff --git a/jetty-websocket/websocket-core-server/pom.xml b/jetty-websocket/websocket-core-server/pom.xml new file mode 100644 index 00000000000..ab55a54ecb0 --- /dev/null +++ b/jetty-websocket/websocket-core-server/pom.xml @@ -0,0 +1,76 @@ + + + + org.eclipse.jetty.websocket + websocket-parent + 10.0.0-SNAPSHOT + + + 4.0.0 + websocket-core-server + Jetty :: Websocket :: Core :: Server + + + ${project.groupId}.core.server + + + + + org.eclipse.jetty.websocket + websocket-core-common + ${project.version} + + + org.eclipse.jetty + jetty-server + ${project.version} + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + ban-ws-apis + + enforce + + + + + + org.eclipse.jetty.websocket:websocket-jetty-api + javax.websocket + + + + + + + ban-java-servlet-api + + enforce + + + + + + javax.servlet + servletapi + org.eclipse.jetty.orbit:javax.servlet + org.mortbay.jetty:servlet-api + jetty:servlet-api + jetty-servlet-api + + + + + + + + + + diff --git a/jetty-websocket/websocket-core-server/src/main/config/modules/websocket.mod b/jetty-websocket/websocket-core-server/src/main/config/modules/websocket.mod new file mode 100644 index 00000000000..da53af6d2e2 --- /dev/null +++ b/jetty-websocket/websocket-core-server/src/main/config/modules/websocket.mod @@ -0,0 +1,11 @@ +DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html + +[description] +Enable both jetty and javax websocket modules for deployed web applications. + +[tags] +websocket + +[depend] +websocket-jetty +websocket-javax diff --git a/jetty-websocket/websocket-core-server/src/main/java/module-info.java b/jetty-websocket/websocket-core-server/src/main/java/module-info.java new file mode 100644 index 00000000000..fa7c47d2610 --- /dev/null +++ b/jetty-websocket/websocket-core-server/src/main/java/module-info.java @@ -0,0 +1,26 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +module org.eclipse.jetty.websocket.core.server +{ + exports org.eclipse.jetty.websocket.core.server; + + requires org.slf4j; + requires transitive org.eclipse.jetty.server; + requires transitive org.eclipse.jetty.websocket.core.common; +} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java new file mode 100644 index 00000000000..2fefc439d09 --- /dev/null +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketServerComponents.java @@ -0,0 +1,51 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.websocket.core.server; + +import javax.servlet.ServletContext; + +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.util.DecoratedObjectFactory; +import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; + +/** + * A collection of components which are the resources needed for websockets such as + * {@link ByteBufferPool}, {@link WebSocketExtensionRegistry}, and {@link DecoratedObjectFactory}. + * + * These components should be accessed through {@link WebSocketServerComponents#ensureWebSocketComponents} so that + * the instance can be shared by being stored as a bean on the ContextHandler. + */ +public class WebSocketServerComponents extends WebSocketComponents +{ + public static final String WEBSOCKET_COMPONENTS_ATTRIBUTE = WebSocketComponents.class.getName(); + + public static WebSocketComponents ensureWebSocketComponents(ServletContext servletContext) + { + // Ensure a mapping exists + WebSocketComponents components = (WebSocketComponents)servletContext.getAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE); + if (components == null) + { + components = new WebSocketServerComponents(); + servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, components); + } + + return components; + } +} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java similarity index 93% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java index 1a0d84c1c5b..77259143103 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpTransport; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; +import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.websocket.core.Behavior; import org.eclipse.jetty.websocket.core.Configuration; @@ -132,7 +133,7 @@ public abstract class AbstractHandshaker implements Handshaker Negotiated negotiated = new Negotiated(baseRequest.getHttpURI().toURI(), protocol, baseRequest.isSecure(), extensionStack, WebSocketConstants.SPEC_VERSION_STRING); // Create the Session - WebSocketCoreSession coreSession = newWebSocketCoreSession(handler, negotiated, components); + WebSocketCoreSession coreSession = newWebSocketCoreSession(request, handler, negotiated, components); if (defaultCustomizer != null) defaultCustomizer.customize(coreSession); negotiator.customize(coreSession); @@ -195,9 +196,20 @@ public abstract class AbstractHandshaker implements Handshaker return true; } - protected WebSocketCoreSession newWebSocketCoreSession(FrameHandler handler, Negotiated negotiated, WebSocketComponents components) + protected WebSocketCoreSession newWebSocketCoreSession(HttpServletRequest request, FrameHandler handler, Negotiated negotiated, WebSocketComponents components) { - return new WebSocketCoreSession(handler, Behavior.SERVER, negotiated, components); + final ContextHandler contextHandler = ContextHandler.getContextHandler(request.getServletContext()); + return new WebSocketCoreSession(handler, Behavior.SERVER, negotiated, components) + { + @Override + protected void handle(Runnable runnable) + { + if (contextHandler != null) + contextHandler.handle(runnable); + else + runnable.run(); + } + }; } protected abstract WebSocketConnection createWebSocketConnection(Request baseRequest, WebSocketCoreSession coreSession); diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java similarity index 100% rename from jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java diff --git a/jetty-websocket/websocket-core/fuzzingclient.json b/jetty-websocket/websocket-core-tests/fuzzingclient.json similarity index 100% rename from jetty-websocket/websocket-core/fuzzingclient.json rename to jetty-websocket/websocket-core-tests/fuzzingclient.json diff --git a/jetty-websocket/websocket-core/fuzzingserver.json b/jetty-websocket/websocket-core-tests/fuzzingserver.json similarity index 100% rename from jetty-websocket/websocket-core/fuzzingserver.json rename to jetty-websocket/websocket-core-tests/fuzzingserver.json diff --git a/jetty-websocket/websocket-core/pom.xml b/jetty-websocket/websocket-core-tests/pom.xml similarity index 77% rename from jetty-websocket/websocket-core/pom.xml rename to jetty-websocket/websocket-core-tests/pom.xml index 2e976948002..bc20aa11c92 100644 --- a/jetty-websocket/websocket-core/pom.xml +++ b/jetty-websocket/websocket-core-tests/pom.xml @@ -7,60 +7,34 @@ 4.0.0 - websocket-core - Jetty :: Websocket :: Core + websocket-core-tests + Jetty :: Websocket :: Core :: Tests - ${project.groupId}.core + ${project.groupId}.core.tests - org.eclipse.jetty - jetty-util + org.eclipse.jetty.websocket + websocket-core-client ${project.version} - org.eclipse.jetty - jetty-io + org.eclipse.jetty.websocket + websocket-core-server ${project.version} - org.eclipse.jetty - jetty-http + org.eclipse.jetty.websocket + websocket-core-common ${project.version} - - org.slf4j - slf4j-api - - - org.eclipse.jetty - jetty-xml - ${project.version} - true - - - org.eclipse.jetty - jetty-client - ${project.version} - - - org.eclipse.jetty - jetty-server - ${project.version} - - org.eclipse.jetty jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AcceptHashTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/AcceptHashTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AcceptHashTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/AcceptHashTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/AutoFragmentTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java similarity index 95% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java index 14a641f1cd7..da005f5ad69 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/CapturedHexPayloads.java @@ -26,7 +26,7 @@ import org.eclipse.jetty.util.Callback; public class CapturedHexPayloads implements OutgoingFrames { - private List captured = new ArrayList<>(); + private final List captured = new ArrayList<>(); @Override public void sendFrame(Frame frame, Callback callback, boolean batch) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/CloseStatusTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/CloseStatusTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/CloseStatusTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/CloseStatusTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java similarity index 97% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java index f787ae8fd89..e17524caaf9 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java @@ -41,9 +41,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class FlushTest { private WebSocketServer server; - private TestFrameHandler serverHandler = new TestFrameHandler(); + private final TestFrameHandler serverHandler = new TestFrameHandler(); private WebSocketCoreClient client; - private WebSocketComponents components = new WebSocketComponents(); + private final WebSocketComponents components = new WebSocketComponents(); @BeforeEach public void startup() throws Exception diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java similarity index 96% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java index a891d6d932f..9acce6884bd 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java @@ -40,9 +40,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class FrameBufferTest extends WebSocketTester { private WebSocketServer server; - private TestFrameHandler serverHandler = new TestFrameHandler(); + private final TestFrameHandler serverHandler = new TestFrameHandler(); private WebSocketCoreClient client; - private WebSocketComponents components = new WebSocketComponents(); + private final WebSocketComponents components = new WebSocketComponents(); @BeforeEach public void startup() throws Exception diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java similarity index 97% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java index af413ce7ea7..5d18c8027c9 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorFrameFlagsTest.java @@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; */ public class GeneratorFrameFlagsTest { - private static WebSocketComponents components = new WebSocketComponents(); + private static final WebSocketComponents components = new WebSocketComponents(); private WebSocketCoreSession coreSession; public static Stream data() diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java similarity index 97% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java index 449afdd7fd6..3e8b523c881 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorParserRoundTripTest.java @@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class GeneratorParserRoundTripTest { - private ByteBufferPool bufferPool = new MappedByteBufferPool(); + private final ByteBufferPool bufferPool = new MappedByteBufferPool(); @Test public void testParserAndGenerator() throws Exception diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java index 5456640b22e..d03da52f3e4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/GeneratorTest.java @@ -47,9 +47,9 @@ public class GeneratorTest { private static final Logger LOG = LoggerFactory.getLogger(Helper.class); - private static Generator generator = new Generator(); - private static WebSocketCoreSession coreSession = newWebSocketCoreSession(Behavior.SERVER); - private static WebSocketComponents components = new WebSocketComponents(); + private static final Generator generator = new Generator(); + private static final WebSocketCoreSession coreSession = newWebSocketCoreSession(Behavior.SERVER); + private static final WebSocketComponents components = new WebSocketComponents(); private static WebSocketCoreSession newWebSocketCoreSession(Behavior behavior) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/IncomingFramesCapture.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/IncomingFramesCapture.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/IncomingFramesCapture.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/IncomingFramesCapture.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java index e48d38d58a7..fc14e360b83 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java @@ -65,7 +65,7 @@ public class MessageHandlerTest coreSession = new CoreSession.Empty() { - private ByteBufferPool byteBufferPool = new MappedByteBufferPool(); + private final ByteBufferPool byteBufferPool = new MappedByteBufferPool(); @Override public void sendFrame(Frame frame, Callback callback, boolean batch) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OpCodeTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OutgoingFramesCapture.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OutgoingFramesCapture.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OutgoingFramesCapture.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OutgoingFramesCapture.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java index 1c067d2a157..33561dda1f1 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/OutgoingNetworkBytesCapture.java @@ -38,7 +38,7 @@ import static org.hamcrest.Matchers.lessThan; public class OutgoingNetworkBytesCapture implements OutgoingFrames { private final Generator generator; - private List captured; + private final List captured; public OutgoingNetworkBytesCapture(Generator generator) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParsePayloadLengthTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParsePayloadLengthTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParsePayloadLengthTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParsePayloadLengthTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java index 6fe3e60b6c5..4dfc798e772 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadCloseStatusCodesTest.java @@ -65,7 +65,7 @@ public class ParserBadCloseStatusCodesTest ); } - private ByteBufferPool bufferPool = new MappedByteBufferPool(); + private final ByteBufferPool bufferPool = new MappedByteBufferPool(); @ParameterizedTest(name = "closeCode={0} {1}") @MethodSource("data") diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java index a0dfcd2167a..f06c8960e24 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserBadOpCodesTest.java @@ -57,7 +57,7 @@ public class ParserBadOpCodesTest ); } - private ByteBufferPool bufferPool = new MappedByteBufferPool(); + private final ByteBufferPool bufferPool = new MappedByteBufferPool(); @ParameterizedTest(name = "opcode={0} {1}") @MethodSource("data") diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserCapture.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserCapture.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserCapture.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserCapture.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserGoodCloseStatusCodesTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserGoodCloseStatusCodesTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserGoodCloseStatusCodesTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserGoodCloseStatusCodesTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserReservedBitTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/ParserTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/RawFrameBuilder.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/RawFrameBuilder.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/RawFrameBuilder.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/RawFrameBuilder.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/SynchronousFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/SynchronousFrameHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/SynchronousFrameHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/SynchronousFrameHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestAsyncFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestAsyncFrameHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestAsyncFrameHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestAsyncFrameHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestFrameHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestFrameHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestFrameHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/Timeouts.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/Timeouts.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/Timeouts.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/Timeouts.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java index bac1e2451d6..eeef7f56d4f 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketCloseTest.java @@ -58,7 +58,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class WebSocketCloseTest extends WebSocketTester { - private static Logger LOG = LoggerFactory.getLogger(WebSocketCloseTest.class); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketCloseTest.class); private static final String WS_SCHEME = "ws"; private static final String WSS_SCHEME = "wss"; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java index 3ef42883dce..6c75606b6ad 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketFrameTest.java @@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class WebSocketFrameTest { - private Generator generator = new Generator(); + private final Generator generator = new Generator(); private ByteBuffer generateWholeFrame(Generator generator, Frame frame) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java index 4cee6345c71..5fc140cb0b6 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java @@ -76,7 +76,7 @@ public class WebSocketNegotiationTest extends WebSocketTester private WebSocketServer server; private WebSocketCoreClient client; - private WebSocketComponents components = new WebSocketComponents(); + private final WebSocketComponents components = new WebSocketComponents(); @BeforeEach public void startup() throws Exception diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java index a96241d613d..1b564a76448 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketOpenTest.java @@ -46,7 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class WebSocketOpenTest extends WebSocketTester { - private static Logger LOG = LoggerFactory.getLogger(WebSocketOpenTest.class); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketOpenTest.class); private WebSocketServer server; private DemandingAsyncFrameHandler serverHandler; @@ -190,7 +190,7 @@ public class WebSocketOpenTest extends WebSocketTester static class DemandingAsyncFrameHandler extends TestAsyncFrameHandler { - private BiFunction onOpen; + private final BiFunction onOpen; DemandingAsyncFrameHandler(BiFunction onOpen) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java index 8ea7da37f89..4eb84f8cc0a 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketTester.java @@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.startsWith; public class WebSocketTester { - private static String NON_RANDOM_KEY = Base64.getEncoder().encodeToString("0123456701234567".getBytes()); + private static final String NON_RANDOM_KEY = Base64.getEncoder().encodeToString("0123456701234567".getBytes()); private static SslContextFactory.Client sslContextFactory; protected ByteBufferPool bufferPool; protected ByteBuffer buffer; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnFrameHandler.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java index 79252a0c1a3..3e297e52127 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java @@ -138,9 +138,9 @@ public class CoreAutobahnClient } private static final Logger LOG = LoggerFactory.getLogger(CoreAutobahnClient.class); - private URI baseWebsocketUri; - private WebSocketCoreClient client; - private String userAgent; + private final URI baseWebsocketUri; + private final WebSocketCoreClient client; + private final String userAgent; public CoreAutobahnClient(String hostname, int port, String userAgent) throws Exception { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java similarity index 95% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java index e5192c37dc3..3734c499324 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java @@ -36,11 +36,11 @@ import org.slf4j.LoggerFactory; public class ChatWebSocketClient { - private static Logger LOG = LoggerFactory.getLogger(ChatWebSocketClient.class); + private static final Logger LOG = LoggerFactory.getLogger(ChatWebSocketClient.class); - private URI baseWebsocketUri; - private WebSocketCoreClient client; - private MessageHandler handler; + private final URI baseWebsocketUri; + private final WebSocketCoreClient client; + private final MessageHandler handler; private String name = String.format("unknown@%x", ThreadLocalRandom.current().nextInt()); public ChatWebSocketClient(String hostname, int port) throws Exception diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java index 493946f2183..fee18160955 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java @@ -45,7 +45,7 @@ import static org.eclipse.jetty.util.Callback.NOOP; public class ChatWebSocketServer { - private Set members = new HashSet<>(); + private final Set members = new HashSet<>(); private FrameHandler negotiate(Negotiation negotiation) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java index 8a4260cad67..3a4dc6741a4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/client/WebSocketClientServerTest.java @@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class WebSocketClientServerTest { - private static Logger LOG = LoggerFactory.getLogger(WebSocketClientServerTest.class); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientServerTest.class); private WebSocketServer server; private TestFrameHandler serverHandler; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/AbstractExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/AbstractExtensionTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/AbstractExtensionTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/AbstractExtensionTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionConfigTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionConfigTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionConfigTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionConfigTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionStackTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionStackTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionStackTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionStackTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java similarity index 97% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java index c8d080b0a13..1f5d2826da4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java @@ -51,11 +51,11 @@ public class ExtensionTool { public class Tester { - private String requestedExtParams; - private ExtensionConfig extConfig; + private final String requestedExtParams; + private final ExtensionConfig extConfig; private Extension ext; - private Parser parser; - private IncomingFramesCapture capture; + private final Parser parser; + private final IncomingFramesCapture capture; private Tester(String parameterizedExtension) { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/FragmentExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/FragmentExtensionTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/FragmentExtensionTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/FragmentExtensionTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/IdentityExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/IdentityExtensionTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/IdentityExtensionTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/IdentityExtensionTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java similarity index 98% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java index 8d3a40bae68..5f28a82b544 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java @@ -53,8 +53,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class PerMessageDeflaterBufferSizeTest { private WebSocketServer server; - private TestFrameHandler serverHandler = new TestFrameHandler(); - private TestNegotiator testNegotiator = new TestNegotiator(); + private final TestFrameHandler serverHandler = new TestFrameHandler(); + private final TestNegotiator testNegotiator = new TestNegotiator(); private URI serverUri; private WebSocketCoreClient client; diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java index 2e376571e18..35f034d244c 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/FrameFlusherTest.java @@ -57,7 +57,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class FrameFlusherTest { - private ByteBufferPool bufferPool = new MappedByteBufferPool(); + private final ByteBufferPool bufferPool = new MappedByteBufferPool(); private Scheduler scheduler; @BeforeEach diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/internal/MockEndpoint.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java index 5d6944e0bdc..6af276077e1 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxy.java @@ -51,8 +51,8 @@ class WebSocketProxy } private final Object lock = new Object(); - private WebSocketCoreClient client; - private URI serverUri; + private final WebSocketCoreClient client; + private final URI serverUri; public Client2Proxy client2Proxy = new Client2Proxy(); public Server2Proxy server2Proxy = new Server2Proxy(); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java similarity index 100% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java similarity index 99% rename from jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java index 66f235de234..d46db6e37f0 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/server/WebSocketServerTest.java @@ -53,7 +53,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class WebSocketServerTest extends WebSocketTester { - private static Logger LOG = LoggerFactory.getLogger(WebSocketServerTest.class); + private static final Logger LOG = LoggerFactory.getLogger(WebSocketServerTest.class); private WebSocketServer server; diff --git a/jetty-websocket/websocket-core/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-core-tests/src/test/resources/jetty-logging.properties similarity index 100% rename from jetty-websocket/websocket-core/src/test/resources/jetty-logging.properties rename to jetty-websocket/websocket-core-tests/src/test/resources/jetty-logging.properties diff --git a/jetty-websocket/websocket-core/src/test/resources/keystore.p12 b/jetty-websocket/websocket-core-tests/src/test/resources/keystore.p12 similarity index 100% rename from jetty-websocket/websocket-core/src/test/resources/keystore.p12 rename to jetty-websocket/websocket-core-tests/src/test/resources/keystore.p12 diff --git a/jetty-websocket/websocket-javax-client/pom.xml b/jetty-websocket/websocket-javax-client/pom.xml index b2fa1cd48aa..3d3f594e723 100644 --- a/jetty-websocket/websocket-javax-client/pom.xml +++ b/jetty-websocket/websocket-javax-client/pom.xml @@ -15,6 +15,15 @@ + + org.eclipse.jetty.toolchain + jetty-javax-websocket-api + + + org.eclipse.jetty.websocket + websocket-javax-common + ${project.version} + org.eclipse.jetty.websocket websocket-util @@ -22,7 +31,7 @@ org.eclipse.jetty.websocket - websocket-javax-common + websocket-core-client ${project.version} @@ -30,21 +39,12 @@ jetty-client ${project.version} - - org.eclipse.jetty.toolchain - jetty-javax-websocket-api - org.eclipse.jetty jetty-xml ${project.version} test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-javax-client/src/main/java/module-info.java b/jetty-websocket/websocket-javax-client/src/main/java/module-info.java index eb58cdef38e..362a4a64ac5 100644 --- a/jetty-websocket/websocket-javax-client/src/main/java/module-info.java +++ b/jetty-websocket/websocket-javax-client/src/main/java/module-info.java @@ -25,9 +25,10 @@ module org.eclipse.jetty.websocket.javax.client exports org.eclipse.jetty.websocket.javax.client; exports org.eclipse.jetty.websocket.javax.client.internal to org.eclipse.jetty.websocket.javax.server; - requires transitive jetty.websocket.api; - requires transitive org.eclipse.jetty.client; + requires org.eclipse.jetty.client; + requires org.eclipse.jetty.websocket.core.client; requires org.eclipse.jetty.websocket.javax.common; + requires transitive jetty.websocket.api; provides ContainerProvider with JavaxWebSocketClientContainerProvider; } diff --git a/jetty-websocket/websocket-javax-common/pom.xml b/jetty-websocket/websocket-javax-common/pom.xml index d606965d46c..5788cfeb68a 100644 --- a/jetty-websocket/websocket-javax-common/pom.xml +++ b/jetty-websocket/websocket-javax-common/pom.xml @@ -67,9 +67,8 @@ - org.eclipse.jetty.websocket - websocket-core - ${project.version} + org.eclipse.jetty.toolchain + jetty-javax-websocket-api org.eclipse.jetty.websocket @@ -77,8 +76,9 @@ ${project.version} - org.eclipse.jetty.toolchain - jetty-javax-websocket-api + org.eclipse.jetty.websocket + websocket-core-client + ${project.version} org.slf4j @@ -89,10 +89,5 @@ jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-javax-common/src/main/java/module-info.java b/jetty-websocket/websocket-javax-common/src/main/java/module-info.java index 08b85dda862..97397c3d70e 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/module-info.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/module-info.java @@ -23,10 +23,8 @@ module org.eclipse.jetty.websocket.javax.common exports org.eclipse.jetty.websocket.javax.common.encoders; exports org.eclipse.jetty.websocket.javax.common.messages; - requires transitive jetty.websocket.api; - requires transitive org.eclipse.jetty.http; - requires transitive org.eclipse.jetty.io; - requires transitive org.eclipse.jetty.websocket.core; - requires transitive org.eclipse.jetty.websocket.util; requires org.slf4j; + requires transitive jetty.websocket.api; + requires transitive org.eclipse.jetty.websocket.core.client; + requires transitive org.eclipse.jetty.websocket.util; } diff --git a/jetty-websocket/websocket-javax-server/pom.xml b/jetty-websocket/websocket-javax-server/pom.xml index d629de14878..e543c2dc12c 100644 --- a/jetty-websocket/websocket-javax-server/pom.xml +++ b/jetty-websocket/websocket-javax-server/pom.xml @@ -43,11 +43,6 @@ jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod b/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod index d46554bdfaf..bb9bd0b26c5 100644 --- a/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod +++ b/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod @@ -11,7 +11,9 @@ client annotations [lib] -lib/websocket/websocket-core-${jetty.version}.jar +lib/websocket/websocket-core-common-${jetty.version}.jar +lib/websocket/websocket-core-client-${jetty.version}.jar +lib/websocket/websocket-core-server-${jetty.version}.jar lib/websocket/websocket-util-${jetty.version}.jar lib/websocket/websocket-util-server-${jetty.version}.jar lib/websocket/jetty-javax-websocket-api-1.1.2.jar diff --git a/jetty-websocket/websocket-javax-server/src/main/java/module-info.java b/jetty-websocket/websocket-javax-server/src/main/java/module-info.java index af5c88bbdd4..c4ad6598d80 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/module-info.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/module-info.java @@ -28,11 +28,11 @@ module org.eclipse.jetty.websocket.javax.server { exports org.eclipse.jetty.websocket.javax.server.config; - requires transitive org.eclipse.jetty.webapp; - requires transitive org.eclipse.jetty.websocket.javax.client; requires org.eclipse.jetty.websocket.javax.common; requires org.eclipse.jetty.websocket.util.server; requires org.slf4j; + requires transitive org.eclipse.jetty.webapp; + requires transitive org.eclipse.jetty.websocket.javax.client; provides ServletContainerInitializer with JavaxWebSocketServletContainerInitializer; provides ServerEndpointConfig.Configurator with ContainerDefaultConfigurator; diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java index 87739c6a434..af4cca34fe3 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java @@ -37,6 +37,7 @@ import org.eclipse.jetty.servlet.listener.ContainerInitializer; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.thread.ThreadClassLoaderScope; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerContainer; import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping; @@ -70,20 +71,14 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain String cp = context.getInitParameter(keyName); if (cp != null) { - if (TypeUtil.isTrue(cp)) - return true; - else - return false; + return TypeUtil.isTrue(cp); } // Next, try attribute on context Object enable = context.getAttribute(keyName); if (enable != null) { - if (TypeUtil.isTrue(enable)) - return true; - else - return false; + return TypeUtil.isTrue(enable); } return null; @@ -153,7 +148,7 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain JavaxWebSocketServerContainer serverContainer = JavaxWebSocketServerContainer.getContainer(context.getServletContext()); if (serverContainer == null) { - WebSocketComponents components = WebSocketComponents.ensureWebSocketComponents(context.getServletContext()); + WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(context.getServletContext()); FilterHolder filterHolder = WebSocketUpgradeFilter.ensureFilter(context.getServletContext()); WebSocketMapping mapping = WebSocketMapping.ensureMapping(context.getServletContext(), WebSocketMapping.DEFAULT_KEY); serverContainer = JavaxWebSocketServerContainer.ensureContainer(context.getServletContext()); diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java index 35a5ba4a86c..59f211b5f2e 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java @@ -37,6 +37,7 @@ import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.core.exception.WebSocketException; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping; @@ -95,7 +96,7 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer // Create the Jetty ServerContainer implementation container = new JavaxWebSocketServerContainer( WebSocketMapping.ensureMapping(servletContext, WebSocketMapping.DEFAULT_KEY), - WebSocketComponents.ensureWebSocketComponents(servletContext), + WebSocketServerComponents.ensureWebSocketComponents(servletContext), coreClientSupplier); contextHandler.addManaged(container); contextHandler.addEventListener(container); diff --git a/jetty-websocket/websocket-jetty-api/pom.xml b/jetty-websocket/websocket-jetty-api/pom.xml index 5f7a34e1f77..15edf958083 100644 --- a/jetty-websocket/websocket-jetty-api/pom.xml +++ b/jetty-websocket/websocket-jetty-api/pom.xml @@ -14,14 +14,6 @@ ${project.groupId}.api - - - org.eclipse.jetty.toolchain - jetty-test-helper - test - - - diff --git a/jetty-websocket/websocket-jetty-client/pom.xml b/jetty-websocket/websocket-jetty-client/pom.xml index ad9d334d39f..cc3c39db832 100644 --- a/jetty-websocket/websocket-jetty-client/pom.xml +++ b/jetty-websocket/websocket-jetty-client/pom.xml @@ -25,6 +25,11 @@ websocket-jetty-common ${project.version} + + org.eclipse.jetty.websocket + websocket-core-client + ${project.version} + org.eclipse.jetty jetty-client @@ -39,11 +44,6 @@ jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-jetty-client/src/main/java/module-info.java b/jetty-websocket/websocket-jetty-client/src/main/java/module-info.java index aa113d80a62..27c6f8600c3 100644 --- a/jetty-websocket/websocket-jetty-client/src/main/java/module-info.java +++ b/jetty-websocket/websocket-jetty-client/src/main/java/module-info.java @@ -20,9 +20,9 @@ module org.eclipse.jetty.websocket.jetty.client { exports org.eclipse.jetty.websocket.client; - requires transitive org.eclipse.jetty.client; - requires transitive org.eclipse.jetty.websocket.jetty.api; - requires org.eclipse.jetty.websocket.core; + requires org.eclipse.jetty.websocket.core.client; requires org.eclipse.jetty.websocket.jetty.common; requires org.slf4j; + requires transitive org.eclipse.jetty.client; + requires transitive org.eclipse.jetty.websocket.jetty.api; } diff --git a/jetty-websocket/websocket-jetty-common/pom.xml b/jetty-websocket/websocket-jetty-common/pom.xml index 83c726eb91d..b3809d06724 100644 --- a/jetty-websocket/websocket-jetty-common/pom.xml +++ b/jetty-websocket/websocket-jetty-common/pom.xml @@ -51,39 +51,10 @@ websocket-jetty-api ${project.version} - - org.eclipse.jetty.websocket - websocket-core - ${project.version} - org.eclipse.jetty.websocket websocket-util ${project.version} - - org.eclipse.jetty - jetty-util - ${project.version} - - - org.eclipse.jetty - jetty-io - ${project.version} - - - org.slf4j - slf4j-api - - - org.eclipse.jetty - jetty-slf4j-impl - test - - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java b/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java index 3b652531aab..4bac66d7684 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java @@ -23,10 +23,11 @@ module org.eclipse.jetty.websocket.jetty.common { exports org.eclipse.jetty.websocket.common; - requires transitive org.eclipse.jetty.websocket.core; + requires org.eclipse.jetty.util; + requires org.slf4j; + requires transitive org.eclipse.jetty.websocket.core.common; requires transitive org.eclipse.jetty.websocket.jetty.api; requires transitive org.eclipse.jetty.websocket.util; - requires org.slf4j; provides ExtensionConfig.Parser with ExtensionConfigParser; } diff --git a/jetty-websocket/websocket-jetty-server/pom.xml b/jetty-websocket/websocket-jetty-server/pom.xml index ade9576c6e7..0387a72b773 100644 --- a/jetty-websocket/websocket-jetty-server/pom.xml +++ b/jetty-websocket/websocket-jetty-server/pom.xml @@ -15,27 +15,6 @@ - - org.eclipse.jetty - jetty-servlet - ${project.version} - - - org.eclipse.jetty - jetty-annotations - ${project.version} - - - org.eclipse.jetty - jetty-server - ${project.version} - - - org.eclipse.jetty - jetty-jmx - ${project.version} - true - org.eclipse.jetty.websocket websocket-jetty-api @@ -55,6 +34,22 @@ org.eclipse.jetty.toolchain jetty-servlet-api + + org.eclipse.jetty + jetty-servlet + ${project.version} + + + org.eclipse.jetty + jetty-annotations + ${project.version} + + + org.eclipse.jetty + jetty-jmx + ${project.version} + true + org.slf4j slf4j-api @@ -64,11 +59,6 @@ jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod b/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod index 9a93574f2bf..0dae0b934d1 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod +++ b/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod @@ -11,7 +11,9 @@ client annotations [lib] -lib/websocket/websocket-core-${jetty.version}.jar +lib/websocket/websocket-core-common-${jetty.version}.jar +lib/websocket/websocket-core-client-${jetty.version}.jar +lib/websocket/websocket-core-server-${jetty.version}.jar lib/websocket/websocket-util-${jetty.version}.jar lib/websocket/websocket-util-server-${jetty.version}.jar lib/websocket/websocket-jetty-api-${jetty.version}.jar diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java index 06a614efec2..bc6c85030e8 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java @@ -39,6 +39,7 @@ import org.eclipse.jetty.websocket.common.SessionTracker; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.exception.WebSocketException; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; @@ -73,7 +74,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements container = new JettyWebSocketServerContainer( contextHandler, WebSocketMapping.ensureMapping(servletContext, WebSocketMapping.DEFAULT_KEY), - WebSocketComponents.ensureWebSocketComponents(servletContext), executor); + WebSocketServerComponents.ensureWebSocketComponents(servletContext), executor); servletContext.setAttribute(JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE, container); contextHandler.addManaged(container); contextHandler.addEventListener(container); diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java index 448694577c5..be184470323 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; @@ -129,7 +130,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet { ServletContext servletContext = getServletContext(); - components = WebSocketComponents.ensureWebSocketComponents(servletContext); + components = WebSocketServerComponents.ensureWebSocketComponents(servletContext); mapping = new WebSocketMapping(components); String max = getInitParameter("idleTimeout"); @@ -262,7 +263,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet private static class WrappedJettyCreator implements WebSocketCreator { - private JettyWebSocketCreator creator; + private final JettyWebSocketCreator creator; private WrappedJettyCreator(JettyWebSocketCreator creator) { diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java index 43b65eafd16..3b164c017f8 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java @@ -26,6 +26,7 @@ import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.listener.ContainerInitializer; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer; import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping; @@ -89,7 +90,7 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain */ private static JettyWebSocketServerContainer initialize(ServletContextHandler context) { - WebSocketComponents components = WebSocketComponents.ensureWebSocketComponents(context.getServletContext()); + WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(context.getServletContext()); FilterHolder filterHolder = WebSocketUpgradeFilter.ensureFilter(context.getServletContext()); WebSocketMapping mapping = WebSocketMapping.ensureMapping(context.getServletContext(), WebSocketMapping.DEFAULT_KEY); JettyWebSocketServerContainer container = JettyWebSocketServerContainer.ensureContainer(context.getServletContext()); diff --git a/jetty-websocket/websocket-util-server/pom.xml b/jetty-websocket/websocket-util-server/pom.xml index c8b50273799..3fd5fc74a48 100644 --- a/jetty-websocket/websocket-util-server/pom.xml +++ b/jetty-websocket/websocket-util-server/pom.xml @@ -66,7 +66,7 @@ org.eclipse.jetty.websocket - websocket-core + websocket-core-server ${project.version} diff --git a/jetty-websocket/websocket-util-server/src/main/java/module-info.java b/jetty-websocket/websocket-util-server/src/main/java/module-info.java index ae57cc58894..c067bea8bf3 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/module-info.java +++ b/jetty-websocket/websocket-util-server/src/main/java/module-info.java @@ -23,5 +23,5 @@ module org.eclipse.jetty.websocket.util.server requires org.slf4j; requires transitive org.eclipse.jetty.servlet; - requires transitive org.eclipse.jetty.websocket.core; + requires transitive org.eclipse.jetty.websocket.core.server; } diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java index b0a9c030e90..5a64fc85ef0 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java +++ b/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java @@ -38,7 +38,7 @@ import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -168,7 +168,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable if (mappingKey != null) mapping = WebSocketMapping.ensureMapping(context, mappingKey); else - mapping = new WebSocketMapping(WebSocketComponents.ensureWebSocketComponents(context)); + mapping = new WebSocketMapping(WebSocketServerComponents.ensureWebSocketComponents(context)); String max = config.getInitParameter("idleTimeout"); if (max == null) diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMapping.java b/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMapping.java index a96a55d315c..d76cbd53e9f 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMapping.java +++ b/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMapping.java @@ -42,6 +42,7 @@ import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.server.Handshaker; import org.eclipse.jetty.websocket.core.server.Negotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +66,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener if (mappingObject != null) { - if (WebSocketMapping.class.isInstance(mappingObject)) + if (mappingObject instanceof WebSocketMapping) return (WebSocketMapping)mappingObject; else throw new IllegalStateException( @@ -88,7 +89,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener if (mapping == null) { - mapping = new WebSocketMapping(WebSocketComponents.ensureWebSocketComponents(servletContext)); + mapping = new WebSocketMapping(WebSocketServerComponents.ensureWebSocketComponents(servletContext)); servletContext.setAttribute(mappingKey, mapping); } diff --git a/jetty-websocket/websocket-util/pom.xml b/jetty-websocket/websocket-util/pom.xml index 9412101ce9f..cafdccef949 100644 --- a/jetty-websocket/websocket-util/pom.xml +++ b/jetty-websocket/websocket-util/pom.xml @@ -48,7 +48,7 @@ org.eclipse.jetty.websocket - websocket-core + websocket-core-common ${project.version} @@ -60,10 +60,5 @@ jetty-slf4j-impl test - - org.eclipse.jetty.toolchain - jetty-test-helper - test - diff --git a/jetty-websocket/websocket-util/src/main/java/module-info.java b/jetty-websocket/websocket-util/src/main/java/module-info.java index 183e1fd2715..22dafa0caea 100644 --- a/jetty-websocket/websocket-util/src/main/java/module-info.java +++ b/jetty-websocket/websocket-util/src/main/java/module-info.java @@ -21,6 +21,8 @@ module org.eclipse.jetty.websocket.util exports org.eclipse.jetty.websocket.util; exports org.eclipse.jetty.websocket.util.messages; + requires org.eclipse.jetty.util; requires org.slf4j; - requires transitive org.eclipse.jetty.websocket.core; + requires org.eclipse.jetty.io; + requires transitive org.eclipse.jetty.websocket.core.common; } From 8b489806b66197481b5747c73bf01ff0787cb529 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 12 May 2020 17:00:30 +1000 Subject: [PATCH 22/77] Fix osgi issues in websocket-core-common Signed-off-by: Lachlan Roberts --- jetty-websocket/websocket-core-common/pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jetty-websocket/websocket-core-common/pom.xml b/jetty-websocket/websocket-core-common/pom.xml index 4290b2ffb5d..91cfb795f07 100644 --- a/jetty-websocket/websocket-core-common/pom.xml +++ b/jetty-websocket/websocket-core-common/pom.xml @@ -75,6 +75,24 @@ + + org.apache.felix + maven-bundle-plugin + true + + + generate-manifest + + manifest + + + + *,org.eclipse.jetty.websocket.core.common.internal.* + + + + + From 9f39fd1dd1b12415b636f0421c8f1715a8283a9b Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 12 May 2020 11:54:28 +1000 Subject: [PATCH 23/77] Issue #4861 - reduce garbage created by the async request attributes Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/server/AsyncAttributes.java | 130 ++++++++++++++++++ .../org/eclipse/jetty/server/Dispatcher.java | 22 +-- .../org/eclipse/jetty/server/Request.java | 29 ++-- .../jetty/server/ServletAttributes.java | 64 +++++++++ .../org/eclipse/jetty/util/AttributesMap.java | 3 +- 5 files changed, 217 insertions(+), 31 deletions(-) create mode 100644 jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java create mode 100644 jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java new file mode 100644 index 00000000000..90f0b452896 --- /dev/null +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java @@ -0,0 +1,130 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.server; + +import java.util.HashSet; +import java.util.Set; +import javax.servlet.AsyncContext; + +import org.eclipse.jetty.util.Attributes; + +class AsyncAttributes extends Attributes.Wrapper +{ + /** + * Async dispatch attribute name prefix. + */ + public static final String __ASYNC_PREFIX = "javax.servlet.async."; + + private String _requestURI; + private String _contextPath; + private String _servletPath; + private String _pathInfo; + private String _query; + + AsyncAttributes(Attributes attributes) + { + super(attributes); + } + + @Override + public Object getAttribute(String key) + { + if (!key.startsWith(__ASYNC_PREFIX)) + return super.getAttribute(key); + + switch (key) + { + case AsyncContext.ASYNC_REQUEST_URI: + return _requestURI; + case AsyncContext.ASYNC_CONTEXT_PATH: + return _contextPath; + case AsyncContext.ASYNC_SERVLET_PATH: + return _servletPath; + case AsyncContext.ASYNC_PATH_INFO: + return _pathInfo; + case AsyncContext.ASYNC_QUERY_STRING: + return _query; + default: + return super.getAttribute(key); + } + } + + @Override + public Set getAttributeNameSet() + { + HashSet set = new HashSet<>(); + for (String name : _attributes.getAttributeNameSet()) + { + if (!name.startsWith(__ASYNC_PREFIX)) + set.add(name); + } + + if (_requestURI != null) + set.add(AsyncContext.ASYNC_REQUEST_URI); + if (_contextPath != null) + set.add(AsyncContext.ASYNC_CONTEXT_PATH); + if (_servletPath != null) + set.add(AsyncContext.ASYNC_SERVLET_PATH); + if (_pathInfo != null) + set.add(AsyncContext.ASYNC_PATH_INFO); + if (_query != null) + set.add(AsyncContext.ASYNC_QUERY_STRING); + + return set; + } + + @Override + public void setAttribute(String key, Object value) + { + if (!key.startsWith(__ASYNC_PREFIX)) + super.setAttribute(key, value); + + switch (key) + { + case AsyncContext.ASYNC_REQUEST_URI: + _requestURI = (String)value; + break; + case AsyncContext.ASYNC_CONTEXT_PATH: + _contextPath = (String)value; + break; + case AsyncContext.ASYNC_SERVLET_PATH: + _servletPath = (String)value; + break; + case AsyncContext.ASYNC_PATH_INFO: + _pathInfo = (String)value; + break; + case AsyncContext.ASYNC_QUERY_STRING: + _query = (String)value; + break; + default: + super.setAttribute(key, value); + } + } + + @Override + public void clearAttributes() + { + _requestURI = null; + _contextPath = null; + _servletPath = null; + _pathInfo = null; + _query = null; + super.clearAttributes(); + } +} diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java index 1f3aa6150c5..649e30388c2 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java @@ -330,24 +330,25 @@ public class Dispatcher implements RequestDispatcher { case FORWARD_PATH_INFO: _pathInfo = (String)value; - return; + break; case FORWARD_REQUEST_URI: _requestURI = (String)value; - return; + break; case FORWARD_SERVLET_PATH: _servletPath = (String)value; - return; + break; case FORWARD_CONTEXT_PATH: _contextPath = (String)value; - return; + break; case FORWARD_QUERY_STRING: _query = (String)value; - return; + break; default: if (value == null) _attributes.removeAttribute(key); else _attributes.setAttribute(key, value); + break; } } else if (value == null) @@ -452,24 +453,25 @@ public class Dispatcher implements RequestDispatcher { case INCLUDE_PATH_INFO: _pathInfo = (String)value; - return; + break; case INCLUDE_REQUEST_URI: _requestURI = (String)value; - return; + break; case INCLUDE_SERVLET_PATH: _servletPath = (String)value; - return; + break; case INCLUDE_CONTEXT_PATH: _contextPath = (String)value; - return; + break; case INCLUDE_QUERY_STRING: _query = (String)value; - return; + break; default: if (value == null) _attributes.removeAttribute(key); else _attributes.setAttribute(key, value); + break; } } else if (value == null) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 8b0bf63e974..07495e906a3 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -39,6 +39,7 @@ import java.util.EventListener; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.function.Supplier; import java.util.stream.Collectors; import javax.servlet.AsyncContext; @@ -199,7 +200,7 @@ public class Request implements HttpServletRequest private boolean _handled = false; private boolean _contentParamsExtracted; private boolean _requestedSessionIdFromCookie = false; - private Attributes _attributes; + private Attributes _attributes = new ServletAttributes(); private Authentication _authentication; private String _contentType; private String _characterEncoding; @@ -626,7 +627,7 @@ public class Request implements HttpServletRequest _channel.getHttpTransport() instanceof HttpConnection) return _channel.getHttpTransport(); } - return (_attributes == null) ? null : _attributes.getAttribute(name); + return _attributes.getAttribute(name); } /* @@ -635,16 +636,11 @@ public class Request implements HttpServletRequest @Override public Enumeration getAttributeNames() { - if (_attributes == null) - return Collections.enumeration(Collections.emptyList()); - return AttributesMap.getAttributeNamesCopy(_attributes); } public Attributes getAttributes() { - if (_attributes == null) - _attributes = new AttributesMap(); return _attributes; } @@ -1868,13 +1864,10 @@ public class Request implements HttpServletRequest _asyncNotSupportedSource = null; _handled = false; _attributes = Attributes.unwrap(_attributes); - if (_attributes != null) - { - if (AttributesMap.class.equals(_attributes.getClass())) - _attributes.clearAttributes(); - else - _attributes = null; - } + if (ServletAttributes.class.equals(_attributes.getClass())) + _attributes.clearAttributes(); + else + _attributes = new ServletAttributes(); _contentType = null; _characterEncoding = null; _contextPath = null; @@ -1911,7 +1904,7 @@ public class Request implements HttpServletRequest @Override public void removeAttribute(String name) { - Object oldValue = _attributes == null ? null : _attributes.getAttribute(name); + Object oldValue = _attributes.getAttribute(name); if (_attributes != null) _attributes.removeAttribute(name); @@ -1945,15 +1938,13 @@ public class Request implements HttpServletRequest @Override public void setAttribute(String name, Object value) { - Object oldValue = _attributes == null ? null : _attributes.getAttribute(name); + Object oldValue = _attributes.getAttribute(name); if ("org.eclipse.jetty.server.Request.queryEncoding".equals(name)) setQueryEncoding(value == null ? null : value.toString()); else if ("org.eclipse.jetty.server.sendContent".equals(name)) LOG.warn("Deprecated: org.eclipse.jetty.server.sendContent"); - if (_attributes == null) - _attributes = new AttributesMap(); _attributes.setAttribute(name, value); if (!_requestAttributeListeners.isEmpty()) @@ -1973,7 +1964,7 @@ public class Request implements HttpServletRequest public void setAttributes(Attributes attributes) { - _attributes = attributes; + _attributes = Objects.requireNonNull(attributes); } /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java new file mode 100644 index 00000000000..08df2f498de --- /dev/null +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java @@ -0,0 +1,64 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.server; + +import java.util.Set; + +import org.eclipse.jetty.util.Attributes; +import org.eclipse.jetty.util.AttributesMap; + +public class ServletAttributes implements Attributes +{ + private final Attributes _attributes; + + public ServletAttributes() + { + _attributes = new AsyncAttributes(new AttributesMap()); + } + + @Override + public void removeAttribute(String name) + { + _attributes.removeAttribute(name); + } + + @Override + public void setAttribute(String name, Object attribute) + { + _attributes.setAttribute(name, attribute); + } + + @Override + public Object getAttribute(String name) + { + return _attributes.getAttribute(name); + } + + @Override + public Set getAttributeNameSet() + { + return _attributes.getAttributeNameSet(); + } + + @Override + public void clearAttributes() + { + _attributes.clearAttributes(); + } +} diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java b/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java index 8c41e073ce1..27bfefdc2bb 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/AttributesMap.java @@ -111,8 +111,7 @@ public class AttributesMap implements Attributes, Dumpable if (attrs instanceof AttributesMap) return Collections.enumeration(((AttributesMap)attrs).keySet()); - List names = new ArrayList<>(); - names.addAll(Collections.list(attrs.getAttributeNames())); + List names = new ArrayList<>(Collections.list(attrs.getAttributeNames())); return Collections.enumeration(names); } From f039becb978ee8f515820d77f92ad545ce9b3243 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 13 May 2020 09:14:59 +0200 Subject: [PATCH 24/77] Replace HashSet with ArrayList as that has two benefits: (#4871) - ArrayList contains() + add() is faster than HashSet add() for small collections - A heap allocation of the iterator is required when iterating HashSet while iterating ArrayList can do with a stack allocation Signed-off-by: Ludovic Orban --- .../main/java/org/eclipse/jetty/http2/HTTP2Flusher.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java index 3b3dd9903f7..aafbeb635e6 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Flusher.java @@ -21,6 +21,8 @@ package org.eclipse.jetty.http2; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; import java.util.Deque; import java.util.HashSet; import java.util.Iterator; @@ -47,7 +49,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable private final Queue windows = new ArrayDeque<>(); private final Deque entries = new ArrayDeque<>(); private final Queue pendingEntries = new ArrayDeque<>(); - private final Set processedEntries = new HashSet<>(); + private final Collection processedEntries = new ArrayList<>(); private final HTTP2Session session; private final ByteBufferPool.Lease lease; private Throwable terminated; @@ -192,7 +194,10 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable progress = true; - processedEntries.add(entry); + // We use ArrayList contains() + add() instead of HashSet add() + // because that is faster for collections of size up to 250 entries. + if (!processedEntries.contains(entry)) + processedEntries.add(entry); if (entry.getDataBytesRemaining() == 0) pending.remove(); From 629e106045a7ea357c229d83ba18ff196dc434b1 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 13 May 2020 19:10:11 +1000 Subject: [PATCH 25/77] Issue #4861 - increase efficiency of ServletAttributes when going async Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/server/AsyncAttributes.java | 54 +++++++++-------- .../jetty/server/AsyncContextEvent.java | 31 ++-------- .../org/eclipse/jetty/server/Request.java | 58 +++++++++++++++++-- .../jetty/server/ServletAttributes.java | 35 ++++++++--- 4 files changed, 112 insertions(+), 66 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java index 90f0b452896..9d040cb9a06 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java @@ -26,28 +26,27 @@ import org.eclipse.jetty.util.Attributes; class AsyncAttributes extends Attributes.Wrapper { - /** - * Async dispatch attribute name prefix. - */ - public static final String __ASYNC_PREFIX = "javax.servlet.async."; - private String _requestURI; private String _contextPath; private String _servletPath; private String _pathInfo; - private String _query; + private String _queryString; - AsyncAttributes(Attributes attributes) + public AsyncAttributes(Attributes attributes, String requestUri, String contextPath, String servletPath, String pathInfo, String queryString) { super(attributes); + + // TODO: make fields final in jetty-10 and NOOP when one of these attributes is set. + _requestURI = requestUri; + _contextPath = contextPath; + _servletPath = servletPath; + _pathInfo = pathInfo; + _queryString = queryString; } @Override public Object getAttribute(String key) { - if (!key.startsWith(__ASYNC_PREFIX)) - return super.getAttribute(key); - switch (key) { case AsyncContext.ASYNC_REQUEST_URI: @@ -59,7 +58,7 @@ class AsyncAttributes extends Attributes.Wrapper case AsyncContext.ASYNC_PATH_INFO: return _pathInfo; case AsyncContext.ASYNC_QUERY_STRING: - return _query; + return _queryString; default: return super.getAttribute(key); } @@ -68,13 +67,7 @@ class AsyncAttributes extends Attributes.Wrapper @Override public Set getAttributeNameSet() { - HashSet set = new HashSet<>(); - for (String name : _attributes.getAttributeNameSet()) - { - if (!name.startsWith(__ASYNC_PREFIX)) - set.add(name); - } - + Set set = new HashSet<>(super.getAttributeNameSet()); if (_requestURI != null) set.add(AsyncContext.ASYNC_REQUEST_URI); if (_contextPath != null) @@ -83,18 +76,14 @@ class AsyncAttributes extends Attributes.Wrapper set.add(AsyncContext.ASYNC_SERVLET_PATH); if (_pathInfo != null) set.add(AsyncContext.ASYNC_PATH_INFO); - if (_query != null) + if (_queryString != null) set.add(AsyncContext.ASYNC_QUERY_STRING); - return set; } @Override public void setAttribute(String key, Object value) { - if (!key.startsWith(__ASYNC_PREFIX)) - super.setAttribute(key, value); - switch (key) { case AsyncContext.ASYNC_REQUEST_URI: @@ -110,10 +99,11 @@ class AsyncAttributes extends Attributes.Wrapper _pathInfo = (String)value; break; case AsyncContext.ASYNC_QUERY_STRING: - _query = (String)value; + _queryString = (String)value; break; default: super.setAttribute(key, value); + break; } } @@ -124,7 +114,21 @@ class AsyncAttributes extends Attributes.Wrapper _contextPath = null; _servletPath = null; _pathInfo = null; - _query = null; + _queryString = null; super.clearAttributes(); } + + public void applyToAttributes(Attributes attributes) + { + if (_requestURI != null) + attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, _requestURI); + if (_contextPath != null) + attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, _contextPath); + if (_servletPath != null) + attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, _servletPath); + if (_pathInfo != null) + attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, _pathInfo); + if (_queryString != null) + attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, _queryString); + } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContextEvent.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContextEvent.java index 9be11f7f39e..cc413f9ec8f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContextEvent.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContextEvent.java @@ -20,7 +20,6 @@ package org.eclipse.jetty.server; import javax.servlet.AsyncContext; import javax.servlet.AsyncEvent; -import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; @@ -32,7 +31,7 @@ public class AsyncContextEvent extends AsyncEvent implements Runnable { private final Context _context; private final AsyncContextState _asyncContext; - private volatile HttpChannelState _state; + private final HttpChannelState _state; private ServletContext _dispatchContext; private String _dispatchPath; private volatile Scheduler.Task _timeoutTask; @@ -45,31 +44,9 @@ public class AsyncContextEvent extends AsyncEvent implements Runnable _asyncContext = asyncContext; _state = state; - // If we haven't been async dispatched before - if (baseRequest.getAttribute(AsyncContext.ASYNC_REQUEST_URI) == null) - { - // We are setting these attributes during startAsync, when the spec implies that - // they are only available after a call to AsyncContext.dispatch(...); - - // have we been forwarded before? - String uri = (String)baseRequest.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); - if (uri != null) - { - baseRequest.setAttribute(AsyncContext.ASYNC_REQUEST_URI, uri); - baseRequest.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, baseRequest.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH)); - baseRequest.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, baseRequest.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH)); - baseRequest.setAttribute(AsyncContext.ASYNC_PATH_INFO, baseRequest.getAttribute(RequestDispatcher.FORWARD_PATH_INFO)); - baseRequest.setAttribute(AsyncContext.ASYNC_QUERY_STRING, baseRequest.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); - } - else - { - baseRequest.setAttribute(AsyncContext.ASYNC_REQUEST_URI, baseRequest.getRequestURI()); - baseRequest.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, baseRequest.getContextPath()); - baseRequest.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, baseRequest.getServletPath()); - baseRequest.setAttribute(AsyncContext.ASYNC_PATH_INFO, baseRequest.getPathInfo()); - baseRequest.setAttribute(AsyncContext.ASYNC_QUERY_STRING, baseRequest.getQueryString()); - } - } + // We are setting these attributes during startAsync, when the spec implies that + // they are only available after a call to AsyncContext.dispatch(...); + baseRequest.setAsyncAttributes(); } public ServletContext getSuspendedContext() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 07495e906a3..0b8939f6dcb 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -39,7 +39,6 @@ import java.util.EventListener; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.function.Supplier; import java.util.stream.Collectors; import javax.servlet.AsyncContext; @@ -200,7 +199,7 @@ public class Request implements HttpServletRequest private boolean _handled = false; private boolean _contentParamsExtracted; private boolean _requestedSessionIdFromCookie = false; - private Attributes _attributes = new ServletAttributes(); + private Attributes _attributes; private Authentication _authentication; private String _contentType; private String _characterEncoding; @@ -627,7 +626,7 @@ public class Request implements HttpServletRequest _channel.getHttpTransport() instanceof HttpConnection) return _channel.getHttpTransport(); } - return _attributes.getAttribute(name); + return (_attributes == null) ? null : _attributes.getAttribute(name); } /* @@ -636,11 +635,16 @@ public class Request implements HttpServletRequest @Override public Enumeration getAttributeNames() { + if (_attributes == null) + return Collections.enumeration(Collections.emptyList()); + return AttributesMap.getAttributeNamesCopy(_attributes); } public Attributes getAttributes() { + if (_attributes == null) + _attributes = new ServletAttributes(); return _attributes; } @@ -1904,7 +1908,7 @@ public class Request implements HttpServletRequest @Override public void removeAttribute(String name) { - Object oldValue = _attributes.getAttribute(name); + Object oldValue = _attributes == null ? null : _attributes.getAttribute(name); if (_attributes != null) _attributes.removeAttribute(name); @@ -1938,13 +1942,15 @@ public class Request implements HttpServletRequest @Override public void setAttribute(String name, Object value) { - Object oldValue = _attributes.getAttribute(name); + Object oldValue = _attributes == null ? null : _attributes.getAttribute(name); if ("org.eclipse.jetty.server.Request.queryEncoding".equals(name)) setQueryEncoding(value == null ? null : value.toString()); else if ("org.eclipse.jetty.server.sendContent".equals(name)) LOG.warn("Deprecated: org.eclipse.jetty.server.sendContent"); + if (_attributes == null) + _attributes = new ServletAttributes(); _attributes.setAttribute(name, value); if (!_requestAttributeListeners.isEmpty()) @@ -1964,7 +1970,47 @@ public class Request implements HttpServletRequest public void setAttributes(Attributes attributes) { - _attributes = Objects.requireNonNull(attributes); + _attributes = attributes; + } + + public void setAsyncAttributes() + { + // Return if we have been async dispatched before. + if (getAttribute(AsyncContext.ASYNC_REQUEST_URI) != null) + return; + + // Unwrap the _attributes to get the base attributes instance. + Attributes baseAttributes; + if (_attributes == null) + _attributes = baseAttributes = new ServletAttributes(); + else + baseAttributes = Attributes.unwrap(_attributes); + + AsyncAttributes asyncAttributes; + // Have we been forwarded before? + String uri = (String)getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); + if (uri != null) + { + String contextPath = (String)getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); + String servletPath = (String)getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); + String pathInfo = (String)getAttribute(RequestDispatcher.FORWARD_PATH_INFO); + String queryString = (String)getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); + asyncAttributes = new AsyncAttributes(baseAttributes, uri, contextPath, servletPath, pathInfo, queryString); + } + else + { + String requestURI = getRequestURI(); + String contextPath = getContextPath(); + String servletPath = getServletPath(); + String pathInfo = getPathInfo(); + String queryString = getQueryString(); + asyncAttributes = new AsyncAttributes(baseAttributes, requestURI, contextPath, servletPath, pathInfo, queryString); + } + + if (baseAttributes instanceof ServletAttributes) + ((ServletAttributes)_attributes).setAsyncAttributes(asyncAttributes); + else + asyncAttributes.applyToAttributes(_attributes); } /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java index 08df2f498de..18c1dd8e305 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java @@ -25,40 +25,59 @@ import org.eclipse.jetty.util.AttributesMap; public class ServletAttributes implements Attributes { - private final Attributes _attributes; + private final Attributes _attributes = new AttributesMap(); + private AsyncAttributes _asyncAttributes; - public ServletAttributes() + public void setAsyncAttributes(AsyncAttributes attributes) { - _attributes = new AsyncAttributes(new AttributesMap()); + _asyncAttributes = attributes; } @Override public void removeAttribute(String name) { - _attributes.removeAttribute(name); + if (_asyncAttributes == null) + _attributes.removeAttribute(name); + else + _asyncAttributes.removeAttribute(name); } @Override public void setAttribute(String name, Object attribute) { - _attributes.setAttribute(name, attribute); + if (_asyncAttributes == null) + _attributes.setAttribute(name, attribute); + else + _asyncAttributes.setAttribute(name, attribute); } @Override public Object getAttribute(String name) { - return _attributes.getAttribute(name); + if (_asyncAttributes == null) + return _attributes.getAttribute(name); + else + return _asyncAttributes.getAttribute(name); } @Override public Set getAttributeNameSet() { - return _attributes.getAttributeNameSet(); + if (_asyncAttributes == null) + return _attributes.getAttributeNameSet(); + else + return _asyncAttributes.getAttributeNameSet(); } @Override public void clearAttributes() { - _attributes.clearAttributes(); + if (_asyncAttributes == null) + _attributes.clearAttributes(); + else + { + _asyncAttributes.clearAttributes(); + _asyncAttributes = null; + } } } From 475c2c2f1e065c71ee220491c853f95c7a60bfcf Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 13 May 2020 11:48:30 +0200 Subject: [PATCH 26/77] Issue #4836 - Too Many Files Error with AWS ALB. Added test to replicate the traffic seen in the issue. The test shows that we do close the server EndPoint. Signed-off-by: Simone Bordet --- .../jetty/client/ssl/SslBytesServerTest.java | 75 +++++++++++++++++-- .../jetty/client/ssl/SslBytesTest.java | 2 + 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java index 16162f34aae..40332f31b01 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesServerTest.java @@ -67,6 +67,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assumptions; @@ -88,8 +89,9 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.condition.OS.LINUX; import static org.junit.jupiter.api.condition.OS.WINDOWS; -// This whole test is very specific to how TLS < 1.3 works. -@EnabledOnJre({JRE.JAVA_8, JRE.JAVA_9, JRE.JAVA_10}) +// Other JREs have slight differences in how TLS work +// and this test expects a very specific TLS behavior. +@EnabledOnJre({JRE.JAVA_8, JRE.JAVA_11}) public class SslBytesServerTest extends SslBytesTest { private final AtomicInteger sslFills = new AtomicInteger(); @@ -108,9 +110,9 @@ public class SslBytesServerTest extends SslBytesTest @BeforeEach public void init() throws Exception { - - threadPool = Executors.newCachedThreadPool(); - server = new Server(); + QueuedThreadPool serverThreads = new QueuedThreadPool(); + serverThreads.setName("server"); + server = new Server(serverThreads); sslFills.set(0); sslFlushes.set(0); @@ -119,6 +121,8 @@ public class SslBytesServerTest extends SslBytesTest File keyStore = MavenTestingUtils.getTestResourceFile("keystore.p12"); sslContextFactory = new SslContextFactory.Server(); + // This whole test is very specific to how TLS < 1.3 works. + sslContextFactory.setIncludeProtocols("TLSv1.2"); sslContextFactory.setKeyStorePath(keyStore.getAbsolutePath()); sslContextFactory.setKeyStorePassword("storepwd"); @@ -238,6 +242,7 @@ public class SslBytesServerTest extends SslBytesTest sslContext = sslContextFactory.getSslContext(); + threadPool = Executors.newCachedThreadPool(); proxy = new SimpleProxy(threadPool, "localhost", serverPort); proxy.start(); logger.info("proxy:{} <==> server:{}", proxy.getPort(), serverPort); @@ -1128,6 +1133,66 @@ public class SslBytesServerTest extends SslBytesTest client.close(); } + @Test + public void testRequestResponseServerIdleTimeoutClientResets() throws Exception + { + SSLSocket client = newClient(); + + SimpleProxy.AutomaticFlow automaticProxyFlow = proxy.startAutomaticFlow(); + client.startHandshake(); + assertTrue(automaticProxyFlow.stop(5, TimeUnit.SECONDS)); + + Future request = threadPool.submit(() -> + { + OutputStream clientOutput = client.getOutputStream(); + clientOutput.write(( + "GET / HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "\r\n").getBytes(StandardCharsets.UTF_8)); + clientOutput.flush(); + return null; + }); + + // Application data + TLSRecord record = proxy.readFromClient(); + proxy.flushToServer(record); + assertNull(request.get(5, TimeUnit.SECONDS)); + + // Application data + record = proxy.readFromServer(); + assertEquals(TLSRecord.Type.APPLICATION, record.getType()); + proxy.flushToClient(record); + + BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream(), StandardCharsets.UTF_8)); + String line = reader.readLine(); + assertNotNull(line); + assertTrue(line.startsWith("HTTP/1.1 200 ")); + while ((line = reader.readLine()) != null) + { + if (line.trim().length() == 0) + break; + } + + // Wait for the server idle timeout. + Thread.sleep(idleTimeout); + + // We expect that the server sends the TLS Alert. + record = proxy.readFromServer(); + assertNotNull(record); + assertEquals(TLSRecord.Type.ALERT, record.getType()); + + // Send a RST to the server. + proxy.sendRSTToServer(); + + // Wait for the RST to be processed by the server. + Thread.sleep(1000); + + // The server EndPoint must be closed. + assertFalse(serverEndPoint.get().isOpen()); + + client.close(); + } + @Test @EnabledOnOs(LINUX) // see message below public void testRequestWithCloseAlertWithSplitBoundary() throws Exception diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesTest.java index 06827ecc9e3..b5b287391e4 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ssl/SslBytesTest.java @@ -237,6 +237,7 @@ public abstract class SslBytesTest public void flushToServer(TLSRecord record, long sleep) throws Exception { + logger.debug("P --> S {}", record); if (record == null) { server.shutdownOutput(); @@ -275,6 +276,7 @@ public abstract class SslBytesTest public void flushToClient(TLSRecord record) throws Exception { + logger.debug("C <-- P {}", record); if (record == null) { client.shutdownOutput(); From 6527b3b083b068e4a0fe583d0edd0c18a8bacb4d Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 13 May 2020 12:12:14 +0200 Subject: [PATCH 27/77] Issue #4868 update asm 7.3.1 (#4869) Signed-off-by: Jan Bartel --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ada9444a5af..b8986db6a86 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 9.4.8.Final 2.0.10 2.4.0 - 7.2 + 7.3.1 1.21 benchmarks 1.4.0 From 4aece5e9cfd8b461d0e13ea243cadc63947e35e7 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 13 May 2020 23:05:54 +1000 Subject: [PATCH 28/77] Issue #4861 - changes from review Signed-off-by: Lachlan Roberts --- .../org/eclipse/jetty/server/Request.java | 11 +++--- .../jetty/server/ServletAttributes.java | 34 ++++++------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 0b8939f6dcb..34f9e57bbb8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1868,10 +1868,13 @@ public class Request implements HttpServletRequest _asyncNotSupportedSource = null; _handled = false; _attributes = Attributes.unwrap(_attributes); - if (ServletAttributes.class.equals(_attributes.getClass())) - _attributes.clearAttributes(); - else - _attributes = new ServletAttributes(); + if (_attributes != null) + { + if (ServletAttributes.class.equals(_attributes.getClass())) + _attributes.clearAttributes(); + else + _attributes = null; + } _contentType = null; _characterEncoding = null; _contextPath = null; diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java index 18c1dd8e305..ec24e37216c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java @@ -33,51 +33,39 @@ public class ServletAttributes implements Attributes _asyncAttributes = attributes; } + private Attributes getAttributes() + { + return (_asyncAttributes == null) ? _attributes : _asyncAttributes; + } + @Override public void removeAttribute(String name) { - if (_asyncAttributes == null) - _attributes.removeAttribute(name); - else - _asyncAttributes.removeAttribute(name); + getAttributes().removeAttribute(name); } @Override public void setAttribute(String name, Object attribute) { - if (_asyncAttributes == null) - _attributes.setAttribute(name, attribute); - else - _asyncAttributes.setAttribute(name, attribute); + getAttributes().setAttribute(name, attribute); } @Override public Object getAttribute(String name) { - if (_asyncAttributes == null) - return _attributes.getAttribute(name); - else - return _asyncAttributes.getAttribute(name); + return getAttributes().getAttribute(name); } @Override public Set getAttributeNameSet() { - if (_asyncAttributes == null) - return _attributes.getAttributeNameSet(); - else - return _asyncAttributes.getAttributeNameSet(); + return getAttributes().getAttributeNameSet(); } @Override public void clearAttributes() { - if (_asyncAttributes == null) - _attributes.clearAttributes(); - else - { - _asyncAttributes.clearAttributes(); - _asyncAttributes = null; - } + getAttributes().clearAttributes(); + _asyncAttributes = null; } } From 87be7b15eb5c11326ee67b446b4a671a606dbfa9 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 13 May 2020 14:10:52 +0200 Subject: [PATCH 29/77] replace regex match with simple string comparisons Signed-off-by: Ludovic Orban --- .../src/main/java/org/eclipse/jetty/client/HttpClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index 54aa8edab8c..b181a46a915 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -1145,7 +1145,7 @@ public class HttpClient extends ContainerLifeCycle protected String normalizeHost(String host) { - if (host != null && host.matches("\\[.*\\]")) + if (host != null && host.startsWith("[") && host.endsWith("]")) return host.substring(1, host.length() - 1); return host; } From e7aa3c2e2302978df82eba1bee4724cef7a43d8b Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 13 May 2020 14:23:02 +0200 Subject: [PATCH 30/77] explicitly size the listeners array lists Signed-off-by: Ludovic Orban --- .../java/org/eclipse/jetty/client/HttpConversation.java | 2 +- .../main/java/org/eclipse/jetty/client/HttpReceiver.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java index 713b142d2f8..3e39039e944 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConversation.java @@ -117,9 +117,9 @@ public class HttpConversation extends AttributesMap // will notify a listener that may send a new request and trigger // another call to this method which will build different listeners // which may be iterated over when the iteration continues. - List listeners = new ArrayList<>(); HttpExchange firstExchange = exchanges.peekFirst(); HttpExchange lastExchange = exchanges.peekLast(); + List listeners = new ArrayList<>(firstExchange.getResponseListeners().size() + lastExchange.getResponseListeners().size()); if (firstExchange == lastExchange) { // We don't have a conversation, just a single request. diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index d8961dc8f62..f14eda67106 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.client; import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -31,7 +32,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; import java.util.function.LongConsumer; import java.util.function.LongUnaryOperator; -import java.util.stream.Collectors; import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.client.api.Result; @@ -693,10 +693,11 @@ public abstract class HttpReceiver private ContentListeners(List responseListeners) { - listeners = responseListeners.stream() + listeners = new ArrayList<>(responseListeners.size()); + responseListeners.stream() .filter(Response.DemandedContentListener.class::isInstance) .map(Response.DemandedContentListener.class::cast) - .collect(Collectors.toList()); + .forEach(listeners::add); } private boolean isEmpty() From 7d80c8fc3909b341bae48234df81224a28f28611 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 13 May 2020 14:10:10 +0200 Subject: [PATCH 31/77] Add constructor to better align with 10.0.x Signed-off-by: Ludovic Orban --- .../java/org/eclipse/jetty/client/HttpClient.java | 14 +++++++++++++- .../websocket/common/test/BlockheadClient.java | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index b181a46a915..545b13cf4b5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -163,7 +163,7 @@ public class HttpClient extends ContainerLifeCycle */ public HttpClient() { - this(null); + this(new HttpClientTransportOverHTTP(), null); } /** @@ -178,6 +178,18 @@ public class HttpClient extends ContainerLifeCycle this(new HttpClientTransportOverHTTP(), sslContextFactory); } + /** + * Creates a {@link HttpClient} instance that can perform requests to non-TLS destinations only + * (that is, requests with the "http" scheme only, and not "https"). + * + * @param transport the {@link HttpClientTransport} + * @see #HttpClient(HttpClientTransport, SslContextFactory) to perform requests to TLS destinations. + */ + public HttpClient(HttpClientTransport transport) + { + this(transport, null); + } + public HttpClient(HttpClientTransport transport, SslContextFactory sslContextFactory) { this.transport = transport; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java index 22e1a963ab8..d5fc0af0112 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java @@ -44,7 +44,6 @@ public class BlockheadClient extends HttpClient implements WebSocketContainerSco public BlockheadClient() { - super(null); setName("Blockhead-CLIENT"); this.extensionFactory = new WebSocketExtensionFactory(this); } From 1974b1b407c1d20496f4548457326511f30cd757 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 13 May 2020 17:35:10 +0200 Subject: [PATCH 32/77] avoid creating URI instances when possible Signed-off-by: Ludovic Orban --- .../jetty/client/HttpAuthenticationStore.java | 6 +++ .../eclipse/jetty/client/HttpConnection.java | 41 ++++++++++++++----- .../jetty/client/api/AuthenticationStore.java | 8 ++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java index 937bcac6b70..eadce9cee0f 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpAuthenticationStore.java @@ -93,4 +93,10 @@ public class HttpAuthenticationStore implements AuthenticationStore } return null; } + + @Override + public boolean hasAuthenticationResults() + { + return !results.isEmpty(); + } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index de07bd97afc..39b29e3ad56 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jetty.client.api.Authentication; +import org.eclipse.jetty.client.api.AuthenticationStore; import org.eclipse.jetty.client.api.Connection; import org.eclipse.jetty.client.api.ContentProvider; import org.eclipse.jetty.client.api.Request; @@ -103,12 +104,14 @@ public abstract class HttpConnection implements Connection request.path(path); } - URI uri = request.getURI(); - - if (proxy instanceof HttpProxy && !HttpClient.isSchemeSecure(request.getScheme()) && uri != null) + if (proxy instanceof HttpProxy && !HttpClient.isSchemeSecure(request.getScheme())) { - path = uri.toString(); - request.path(path); + URI uri = request.getURI(); + if (uri != null) + { + path = uri.toString(); + request.path(path); + } } // If we are HTTP 1.1, add the Host header @@ -147,9 +150,10 @@ public abstract class HttpConnection implements Connection // Cookies CookieStore cookieStore = getHttpClient().getCookieStore(); - if (cookieStore != null) + if (cookieStore != null && cookieStore.getClass() != HttpCookieStore.Empty.class) { StringBuilder cookies = null; + URI uri = request.getURI(); if (uri != null) cookies = convertCookies(HttpCookieStore.matchPath(uri, cookieStore.get(uri)), null); cookies = convertCookies(request.getCookies(), cookies); @@ -158,8 +162,8 @@ public abstract class HttpConnection implements Connection } // Authentication - applyAuthentication(request, proxy != null ? proxy.getURI() : null); - applyAuthentication(request, uri); + applyProxyAuthentication(request, proxy); + applyRequestAuthentication(request); } private StringBuilder convertCookies(List cookies, StringBuilder builder) @@ -175,11 +179,26 @@ public abstract class HttpConnection implements Connection return builder; } - private void applyAuthentication(Request request, URI uri) + private void applyRequestAuthentication(Request request) { - if (uri != null) + AuthenticationStore authenticationStore = getHttpClient().getAuthenticationStore(); + if (authenticationStore.hasAuthenticationResults()) { - Authentication.Result result = getHttpClient().getAuthenticationStore().findAuthenticationResult(uri); + URI uri = request.getURI(); + if (uri != null) + { + Authentication.Result result = authenticationStore.findAuthenticationResult(uri); + if (result != null) + result.apply(request); + } + } + } + + private void applyProxyAuthentication(Request request, ProxyConfiguration.Proxy proxy) + { + if (proxy != null) + { + Authentication.Result result = getHttpClient().getAuthenticationStore().findAuthenticationResult(proxy.getURI()); if (result != null) result.apply(request); } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java index 7c8429288dc..f0884f5bcc1 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/AuthenticationStore.java @@ -75,4 +75,12 @@ public interface AuthenticationStore * @return the {@link Authentication.Result} that matches the given URI, or null */ Authentication.Result findAuthenticationResult(URI uri); + + /** + * @return false if there are no stored authentication results, true if there may be some. + */ + default boolean hasAuthenticationResults() + { + return true; + } } From 7111f5f1617bbdb1f4f0a25aad016873108cfa06 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 14 May 2020 08:26:44 +1000 Subject: [PATCH 33/77] Issue #4861 - AsyncAttributes should wrap ServletAttributes inner AttributesMap Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/server/AsyncAttributes.java | 22 ++++---- .../org/eclipse/jetty/server/Request.java | 56 +++++++++++-------- .../jetty/server/ServletAttributes.java | 4 +- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java index 9d040cb9a06..8121d61cb5f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java @@ -118,17 +118,17 @@ class AsyncAttributes extends Attributes.Wrapper super.clearAttributes(); } - public void applyToAttributes(Attributes attributes) + public static void applyAsyncAttributes(Attributes attributes, String requestURI, String contextPath, String servletPath, String pathInfo, String queryString) { - if (_requestURI != null) - attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, _requestURI); - if (_contextPath != null) - attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, _contextPath); - if (_servletPath != null) - attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, _servletPath); - if (_pathInfo != null) - attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, _pathInfo); - if (_queryString != null) - attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, _queryString); + if (requestURI != null) + attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, requestURI); + if (contextPath != null) + attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, contextPath); + if (servletPath != null) + attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, servletPath); + if (pathInfo != null) + attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, pathInfo); + if (queryString != null) + attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, queryString); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index 34f9e57bbb8..6565a6e7a7b 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1982,6 +1982,30 @@ public class Request implements HttpServletRequest if (getAttribute(AsyncContext.ASYNC_REQUEST_URI) != null) return; + String requestURI; + String contextPath; + String servletPath; + String pathInfo; + String queryString; + + // Have we been forwarded before? + requestURI = (String)getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); + if (requestURI != null) + { + contextPath = (String)getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); + servletPath = (String)getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); + pathInfo = (String)getAttribute(RequestDispatcher.FORWARD_PATH_INFO); + queryString = (String)getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); + } + else + { + requestURI = getRequestURI(); + contextPath = getContextPath(); + servletPath = getServletPath(); + pathInfo = getPathInfo(); + queryString = getQueryString(); + } + // Unwrap the _attributes to get the base attributes instance. Attributes baseAttributes; if (_attributes == null) @@ -1989,31 +2013,17 @@ public class Request implements HttpServletRequest else baseAttributes = Attributes.unwrap(_attributes); - AsyncAttributes asyncAttributes; - // Have we been forwarded before? - String uri = (String)getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); - if (uri != null) - { - String contextPath = (String)getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); - String servletPath = (String)getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); - String pathInfo = (String)getAttribute(RequestDispatcher.FORWARD_PATH_INFO); - String queryString = (String)getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); - asyncAttributes = new AsyncAttributes(baseAttributes, uri, contextPath, servletPath, pathInfo, queryString); - } - else - { - String requestURI = getRequestURI(); - String contextPath = getContextPath(); - String servletPath = getServletPath(); - String pathInfo = getPathInfo(); - String queryString = getQueryString(); - asyncAttributes = new AsyncAttributes(baseAttributes, requestURI, contextPath, servletPath, pathInfo, queryString); - } - if (baseAttributes instanceof ServletAttributes) - ((ServletAttributes)_attributes).setAsyncAttributes(asyncAttributes); + { + // Set the AsyncAttributes on the ServletAttributes. + ServletAttributes servletAttributes = (ServletAttributes)baseAttributes; + servletAttributes.setAsyncAttributes(requestURI, contextPath, servletPath, pathInfo, queryString); + } else - asyncAttributes.applyToAttributes(_attributes); + { + // If ServletAttributes has been replaced just set them on the top level Attributes. + AsyncAttributes.applyAsyncAttributes(_attributes, requestURI, contextPath, servletPath, pathInfo, queryString); + } } /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java index ec24e37216c..b98a3a04e9c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java @@ -28,9 +28,9 @@ public class ServletAttributes implements Attributes private final Attributes _attributes = new AttributesMap(); private AsyncAttributes _asyncAttributes; - public void setAsyncAttributes(AsyncAttributes attributes) + public void setAsyncAttributes(String requestURI, String contextPath, String servletPath, String pathInfo, String queryString) { - _asyncAttributes = attributes; + _asyncAttributes = new AsyncAttributes(_attributes, requestURI, contextPath, servletPath, pathInfo, queryString); } private Attributes getAttributes() From dacd5e7e368fa7e74135afbbdebe99258b3b88b6 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 14 May 2020 16:02:21 +1000 Subject: [PATCH 34/77] fix websocket-core-test pom.xml file Signed-off-by: Lachlan Roberts --- jetty-websocket/websocket-core-tests/pom.xml | 52 +++++--------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/jetty-websocket/websocket-core-tests/pom.xml b/jetty-websocket/websocket-core-tests/pom.xml index bc20aa11c92..f24b3607818 100644 --- a/jetty-websocket/websocket-core-tests/pom.xml +++ b/jetty-websocket/websocket-core-tests/pom.xml @@ -41,45 +41,19 @@ org.apache.maven.plugins - maven-enforcer-plugin - - - ban-ws-apis - - enforce - - - - - - org.eclipse.jetty.websocket:websocket-jetty-api - javax.websocket - - - - - - - ban-java-servlet-api - - enforce - - - - - - javax.servlet - servletapi - org.eclipse.jetty.orbit:javax.servlet - org.mortbay.jetty:servlet-api - jetty:servlet-api - jetty-servlet-api - - - - - - + maven-deploy-plugin + + + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + true + From 5cff403a698410803ab23c4d58afd74d30ed3f0d Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 14 May 2020 14:57:49 +0200 Subject: [PATCH 35/77] Issue #4787 - Make org.eclipse.jetty.client.HttpRequest's host name writable. Made the methods in the interface default so that potential implementers do not break. Signed-off-by: Simone Bordet --- .../java/org/eclipse/jetty/client/api/Request.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java index a7c9217b44a..1a1ce529cf6 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/api/Request.java @@ -70,7 +70,10 @@ public interface Request * @param host the URI host of this request, such as "127.0.0.1" or "google.com" * @return this request object */ - Request host(String host); + default Request host(String host) + { + return this; + } /** * @return the URI port of this request such as 80 or 443 @@ -78,11 +81,13 @@ public interface Request int getPort(); /** - * * @param port the URI port of this request such as 80 or 443 * @return this request object */ - Request port(int port); + default Request port(int port) + { + return this; + } /** * @return the method of this request, such as GET or POST, as a String From a0b9cb3fa4e15405ad0ae9916e1a772fd6fccaba Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Fri, 8 May 2020 14:14:22 +1000 Subject: [PATCH 36/77] use docker image to test infinispan remote access Signed-off-by: olivier lamy --- .../test-infinispan-sessions/pom.xml | 16 +++++++--- .../remote/RemoteInfinispanTestSupport.java | 32 +++++++++++++++++-- .../test/resources/simplelogger.properties | 3 ++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tests/test-sessions/test-infinispan-sessions/src/test/resources/simplelogger.properties diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index 4a96db6f65e..fe7096d5d69 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -11,7 +11,9 @@ http://www.eclipse.org/jetty ${project.groupId}.sessions.infinispan - 127.0.0.1 + + + 9.4.11.Final @@ -129,15 +131,19 @@ org.slf4j - slf4j-jdk14 - 1.7.25 + slf4j-simple + test + + + org.testcontainers + testcontainers test - remote + remote-session-tests hotrod.enabled @@ -154,7 +160,7 @@ **/*.java - ${hotrod.host} + ${infinispan.docker.version} diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index 07db3147f19..a275f5c88fc 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -35,6 +35,10 @@ import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.protostream.FileDescriptorSource; import org.infinispan.protostream.SerializationContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -45,17 +49,33 @@ import static org.junit.jupiter.api.Assertions.fail; */ public class RemoteInfinispanTestSupport { + private static final Logger LOG = LoggerFactory.getLogger(RemoteInfinispanTestSupport.class); public static final String DEFAULT_CACHE_NAME = "session_test_cache"; public RemoteCache _cache; private String _name; public static RemoteCacheManager _manager; + private static final Logger INFINISPAN_LOG = + LoggerFactory.getLogger("org.eclipse.jetty.server.session.remote.infinispanLogs"); + + static GenericContainer infinispan = + new GenericContainer("jboss/infinispan-server:" + + System.getProperty("infinispan.docker.version", "9.4.11.Final")) + .withEnv("APP_USER","theuser") + .withEnv("APP_PASS","foobar") + .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); static { try { - String host = System.getProperty("hotrod.host", "127.0.0.1"); + long start = System.currentTimeMillis(); + infinispan.start(); + String host = infinispan.getContainerIpAddress(); + System.setProperty("hotrod.host", host); + int port = infinispan.getMappedPort(11222); + LOG.info("Infinispan container started for {}:{} - {}ms", host, port, + System.currentTimeMillis() - start); SearchMapping mapping = new SearchMapping(); mapping.entity(SessionData.class).indexed().providedId() .property("expiry", ElementType.METHOD).field(); @@ -64,7 +84,12 @@ public class RemoteInfinispanTestSupport properties.put(Environment.MODEL_MAPPING, mapping); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); - clientBuilder.withProperties(properties).addServer().host(host).marshaller(new ProtoStreamMarshaller()); + clientBuilder.withProperties(properties).addServer().host(host).port(port) + .security().authentication().enable().realm("default") + .serverName("infinispan") + .saslMechanism("DIGEST-MD5") + .username("theuser").password("foobar") + .marshaller(new ProtoStreamMarshaller()); _manager = new RemoteCacheManager(clientBuilder.build()); @@ -90,7 +115,8 @@ public class RemoteInfinispanTestSupport } catch (Exception e) { - fail(e); + LOG.error(e.getMessage(), e); + throw new RuntimeException(e); } } diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/resources/simplelogger.properties b/tests/test-sessions/test-infinispan-sessions/src/test/resources/simplelogger.properties new file mode 100644 index 00000000000..cc6528beeee --- /dev/null +++ b/tests/test-sessions/test-infinispan-sessions/src/test/resources/simplelogger.properties @@ -0,0 +1,3 @@ +org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.remote.infinispanLogs=info +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.remote.RemoteInfinispanTestSupport=info From abec84596f21ed19b4c37d58e8e14f83fe807ee9 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 11 May 2020 11:41:42 +1000 Subject: [PATCH 37/77] Activate infinispan remote testing using docker image Signed-off-by: olivier lamy --- .../test-infinispan-sessions/pom.xml | 8 ++- .../remote/RemoteInfinispanTestSupport.java | 50 +++++++++++++------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index fe7096d5d69..9529f0e2b32 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -13,7 +13,10 @@ ${project.groupId}.sessions.infinispan - 9.4.11.Final + + 9.4.8.Final + + jboss/infinispan-server @@ -160,7 +163,8 @@ **/*.java - ${infinispan.docker.version} + ${infinispan.docker.image.version} + ${infinispan.docker.image.name} diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index a275f5c88fc..438ae6e619d 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -31,18 +31,19 @@ import org.hibernate.search.cfg.Environment; import org.hibernate.search.cfg.SearchMapping; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; +import org.infinispan.client.hotrod.configuration.Configuration; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.protostream.FileDescriptorSource; import org.infinispan.protostream.SerializationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.testcontainers.Testcontainers; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; /** * RemoteInfinispanTestSupport @@ -57,18 +58,28 @@ public class RemoteInfinispanTestSupport private static final Logger INFINISPAN_LOG = LoggerFactory.getLogger("org.eclipse.jetty.server.session.remote.infinispanLogs"); - static GenericContainer infinispan = - new GenericContainer("jboss/infinispan-server:" + - System.getProperty("infinispan.docker.version", "9.4.11.Final")) - .withEnv("APP_USER","theuser") - .withEnv("APP_PASS","foobar") - .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); + static GenericContainer infinispan; static { try { + Testcontainers.exposeHostPorts(11222); long start = System.currentTimeMillis(); + String infinispanVersion = System.getProperty("infinispan.docker.image.version", "9.4.8.Final"); + infinispan = + new GenericContainer(System.getProperty("infinispan.docker.image.name", "jboss/infinispan-server") + + ":" + infinispanVersion) + .withEnv("APP_USER","theuser") + .withEnv("APP_PASS","foobar") + .withEnv("MGMT_USER", "admin") + .withEnv("MGMT_PASS", "admin") + .withExposedPorts(11222) + .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); + if (infinispanVersion.startsWith("9.4")) + { + infinispan = infinispan.withCommand("standalone"); + } infinispan.start(); String host = infinispan.getContainerIpAddress(); System.setProperty("hotrod.host", host); @@ -83,15 +94,22 @@ public class RemoteInfinispanTestSupport Properties properties = new Properties(); properties.put(Environment.MODEL_MAPPING, mapping); - ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); - clientBuilder.withProperties(properties).addServer().host(host).port(port) - .security().authentication().enable().realm("default") - .serverName("infinispan") - .saslMechanism("DIGEST-MD5") - .username("theuser").password("foobar") + ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().withProperties(properties) + .addServer().host(host).port(port) .marshaller(new ProtoStreamMarshaller()); - _manager = new RemoteCacheManager(clientBuilder.build()); + if (infinispanVersion.startsWith("1")) + { + configurationBuilder.security().authentication() + .realm("default") + .serverName("infinispan") + .saslMechanism("DIGEST-MD5") + .username("theuser").password("foobar"); + } + + Configuration configuration = configurationBuilder.build(); + + _manager = new RemoteCacheManager(configuration); FileDescriptorSource fds = new FileDescriptorSource(); fds.addProtoFiles("/session.proto"); @@ -111,7 +129,7 @@ public class RemoteInfinispanTestSupport } String content = baos.toString("UTF-8"); - _manager.getCache("___protobuf_metadata").put("session.proto", content); + _manager.administration().getOrCreateCache("___protobuf_metadata", (String)null).put("session.proto", content); } catch (Exception e) { @@ -140,7 +158,7 @@ public class RemoteInfinispanTestSupport public void setup() throws Exception { - _cache = _manager.getCache(_name); + _cache = _manager.administration().getOrCreateCache(_name,(String)null); } public void teardown() throws Exception From e2edd6f38fe5944547c91c543de2fba065699a57 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 13 May 2020 07:50:02 +1000 Subject: [PATCH 38/77] more testing with Jan configuration file Signed-off-by: olivier lamy --- .../remote/RemoteInfinispanTestSupport.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index 438ae6e619d..a23697b1afd 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory; import org.testcontainers.Testcontainers; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.utility.MountableFile; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -74,12 +75,15 @@ public class RemoteInfinispanTestSupport .withEnv("APP_PASS","foobar") .withEnv("MGMT_USER", "admin") .withEnv("MGMT_PASS", "admin") - .withExposedPorts(11222) + .withExposedPorts(4712,4713,7600,8080,8088,8089,8443,8181,8888,9990,9993,11211,11222,11223,11224,57600) + // /opt/jboss/infinispan-server/standalone/configuration/ + .withCopyFileToContainer(MountableFile.forClasspathResource("remote-session-test.xml"), + "/opt/jboss/infinispan-server/standalone/configuration/remote-session-test.xml") .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); - if (infinispanVersion.startsWith("9.4")) - { - infinispan = infinispan.withCommand("standalone"); - } +// if (infinispanVersion.startsWith("9.4")) +// { + infinispan = infinispan.withCommand("-c remote-session-test.xml"); // standalone +// } infinispan.start(); String host = infinispan.getContainerIpAddress(); System.setProperty("hotrod.host", host); From 6b0b5c13e502f5eb879be795d5c0800bd20a387d Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 13 May 2020 14:34:59 +1000 Subject: [PATCH 39/77] finally use the file from Jan :) Signed-off-by: olivier lamy --- .../remote/RemoteInfinispanTestSupport.java | 17 +- .../test/resources/remote-session-test.xml | 392 ++++++++++++++++++ 2 files changed, 403 insertions(+), 6 deletions(-) create mode 100644 tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index a23697b1afd..05849c0831f 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -31,6 +31,7 @@ import org.hibernate.search.cfg.Environment; import org.hibernate.search.cfg.SearchMapping; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; +import org.infinispan.client.hotrod.configuration.ClientIntelligence; import org.infinispan.client.hotrod.configuration.Configuration; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; @@ -41,6 +42,7 @@ import org.slf4j.LoggerFactory; import org.testcontainers.Testcontainers; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; import org.testcontainers.utility.MountableFile; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -75,15 +77,14 @@ public class RemoteInfinispanTestSupport .withEnv("APP_PASS","foobar") .withEnv("MGMT_USER", "admin") .withEnv("MGMT_PASS", "admin") - .withExposedPorts(4712,4713,7600,8080,8088,8089,8443,8181,8888,9990,9993,11211,11222,11223,11224,57600) - // /opt/jboss/infinispan-server/standalone/configuration/ + .waitingFor(new LogMessageWaitStrategy() + .withRegEx(".*Infinispan Server.*started in.*\\s")) + .withExposedPorts(4712,4713,8088,8089,8443,9990,9993,11211,11222,11223,11224) .withCopyFileToContainer(MountableFile.forClasspathResource("remote-session-test.xml"), "/opt/jboss/infinispan-server/standalone/configuration/remote-session-test.xml") .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); -// if (infinispanVersion.startsWith("9.4")) -// { - infinispan = infinispan.withCommand("-c remote-session-test.xml"); // standalone -// } + // we could simply use `standalone` as well but... :) + infinispan = infinispan.withCommand("-c remote-session-test.xml"); infinispan.start(); String host = infinispan.getContainerIpAddress(); System.setProperty("hotrod.host", host); @@ -100,6 +101,9 @@ public class RemoteInfinispanTestSupport ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().withProperties(properties) .addServer().host(host).port(port) + // we just want to limit connectivity to list of host:port we knows at start + // as infinispan create new host:port dynamically but due to how docker expose host/port we cannot do that + .clientIntelligence(ClientIntelligence.BASIC) .marshaller(new ProtoStreamMarshaller()); if (infinispanVersion.startsWith("1")) @@ -134,6 +138,7 @@ public class RemoteInfinispanTestSupport String content = baos.toString("UTF-8"); _manager.administration().getOrCreateCache("___protobuf_metadata", (String)null).put("session.proto", content); + _manager.administration().getOrCreateCache("remote-session-test", (String)null); } catch (Exception e) { diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml b/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml new file mode 100644 index 00000000000..eebc11417e3 --- /dev/null +++ b/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml @@ -0,0 +1,392 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 90527065c09eba77b53cc065df8b474c7f50db53 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 13 May 2020 20:00:44 +1000 Subject: [PATCH 40/77] no need to ignore those tests Signed-off-by: olivier lamy --- .../test-infinispan-sessions/pom.xml | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index 9529f0e2b32..bd2ee0d6e6a 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -171,66 +171,5 @@ - - jdk10 - - 10 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/ClusteredSessionScavengingTest - - - - - - - - jdk11 - - 11 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/ClusteredSessionScavengingTest - - - - - - - - - alltests - - - alltests - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - FOOBAR - - - - - - From ebbe2c5843e5abd534a1b44ac8cd47d2643a61ba Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 13 May 2020 20:15:17 +1000 Subject: [PATCH 41/77] use new junit api to test exception Signed-off-by: olivier lamy --- .../session/InfinispanSessionDataStoreTest.java | 12 ++---------- .../SerializedInfinispanSessionDataStoreTest.java | 12 ++---------- .../remote/RemoteInfinispanSessionDataStoreTest.java | 12 ++---------- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java index 62c4446c871..1465b334eda 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanSessionDataStoreTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * InfinispanSessionDataStoreTest @@ -106,15 +106,7 @@ public class InfinispanSessionDataStoreTest extends AbstractSessionDataStoreTest ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class, () -> store.load("222")); } /** diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java index 5f45903196b..37f92e3b447 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/SerializedInfinispanSessionDataStoreTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * SerializedInfinispanSessionDataStoreTest @@ -107,15 +107,7 @@ public class SerializedInfinispanSessionDataStoreTest extends AbstractSessionDat ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class,() -> store.load("222")); } /** diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java index 510ffdd6a0c..718a38e06e3 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanSessionDataStoreTest.java @@ -38,7 +38,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * RemoteInfinispanSessionDataStoreTest @@ -130,15 +130,7 @@ public class RemoteInfinispanSessionDataStoreTest extends AbstractSessionDataSto ((InfinispanSessionDataStore)store).setCache(null); //test that loading it fails - try - { - store.load("222"); - fail("Session should be unreadable"); - } - catch (UnreadableSessionDataException e) - { - //expected exception - } + assertThrows(UnreadableSessionDataException.class, () -> store.load("222")); } @Test From bb26241a37736e4526e4c34e3e8563ba9dad9f51 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 14 May 2020 14:54:23 +1000 Subject: [PATCH 42/77] add RemoteQueryManagerTest to use infinispan via testcontainer, simplify how we start infinispan Signed-off-by: olivier lamy --- .../infinispan-remote-query/pom.xml | 18 +- .../infinispan/RemoteQueryManagerTest.java | 73 +++- .../test/resources/simplelogger.properties | 3 + .../test-infinispan-sessions/pom.xml | 4 +- .../remote/RemoteInfinispanTestSupport.java | 7 +- .../test/resources/remote-session-test.xml | 392 ------------------ 6 files changed, 82 insertions(+), 415 deletions(-) create mode 100644 jetty-infinispan/infinispan-remote-query/src/test/resources/simplelogger.properties delete mode 100644 tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml diff --git a/jetty-infinispan/infinispan-remote-query/pom.xml b/jetty-infinispan/infinispan-remote-query/pom.xml index a9ec47afbaa..4cb8d9bbb6a 100644 --- a/jetty-infinispan/infinispan-remote-query/pom.xml +++ b/jetty-infinispan/infinispan-remote-query/pom.xml @@ -7,12 +7,11 @@ 4.0.0 infinispan-remote-query Jetty :: Infinispan Session Manager Remote - http://www.eclipse.org/jetty ${project.groupId}.infinispan.remote.query + 9.4.8.Final - install org.apache.maven.plugins @@ -127,10 +126,20 @@ infinispan-remote-query-client ${infinispan.version} + + org.slf4j + slf4j-simple + test + + + org.testcontainers + testcontainers + test + - remote + remote-session-tests hotrod.enabled @@ -144,6 +153,9 @@ maven-surefire-plugin false + + ${infinispan.docker.image.version} + diff --git a/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java b/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java index 6fd5521e9f0..53b04adeb25 100644 --- a/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java +++ b/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java @@ -27,6 +27,7 @@ import java.util.Random; import java.util.Set; import org.eclipse.jetty.server.session.SessionData; +import org.eclipse.jetty.session.infinispan.InfinispanSessionData; import org.eclipse.jetty.session.infinispan.QueryManager; import org.eclipse.jetty.session.infinispan.RemoteQueryManager; import org.eclipse.jetty.session.infinispan.SessionDataMarshaller; @@ -35,11 +36,23 @@ import org.hibernate.search.cfg.Environment; import org.hibernate.search.cfg.SearchMapping; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; +import org.infinispan.client.hotrod.configuration.ClientIntelligence; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.protostream.FileDescriptorSource; import org.infinispan.protostream.SerializationContext; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; +import org.testcontainers.utility.MountableFile; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -49,8 +62,45 @@ public class RemoteQueryManagerTest { public static final String DEFAULT_CACHE_NAME = "remote-session-test"; + private static final Logger LOG = LoggerFactory.getLogger(RemoteQueryManagerTest.class); + + private static final Logger INFINISPAN_LOG = + LoggerFactory.getLogger("org.eclipse.jetty.server.session.infinispan.infinispanLogs"); + + private String host; + private int port; + + GenericContainer infinispan = + new GenericContainer(System.getProperty("infinispan.docker.image.name", "jboss/infinispan-server") + + ":" + System.getProperty("infinispan.docker.image.version", "9.4.8.Final")) + .withEnv("APP_USER","theuser") + .withEnv("APP_PASS","foobar") + .withEnv("MGMT_USER", "admin") + .withEnv("MGMT_PASS", "admin") + .waitingFor(new LogMessageWaitStrategy() + .withRegEx(".*Infinispan Server.*started in.*\\s")) + .withExposedPorts(4712,4713,8088,8089,8443,9990,9993,11211,11222,11223,11224) + .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); + + @BeforeEach + public void setup() throws Exception + { + long start = System.currentTimeMillis(); + infinispan.start(); + host = infinispan.getContainerIpAddress(); + port = infinispan.getMappedPort(11222); + LOG.info("Infinispan container started for {}:{} - {}ms", host, port, + System.currentTimeMillis() - start); + } + + @AfterEach + public void stop() throws Exception + { + infinispan.stop(); + } + @Test - public void test() throws Exception + public void testQuery() throws Exception { SearchMapping mapping = new SearchMapping(); mapping.entity(SessionData.class).indexed().providedId().property("expiry", ElementType.FIELD).field(); @@ -59,9 +109,13 @@ public class RemoteQueryManagerTest properties.put(Environment.MODEL_MAPPING, mapping); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); - clientBuilder.withProperties(properties).addServer().host("127.0.0.1").marshaller(new ProtoStreamMarshaller()); + clientBuilder.withProperties(properties).addServer() + .host(this.host).port(this.port) + .clientIntelligence(ClientIntelligence.BASIC) + .marshaller(new ProtoStreamMarshaller()); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(clientBuilder.build()); + remoteCacheManager.administration().getOrCreateCache("remote-session-test", (String)null); FileDescriptorSource fds = new FileDescriptorSource(); fds.addProtoFiles("/session.proto"); @@ -70,20 +124,17 @@ public class RemoteQueryManagerTest serCtx.registerProtoFiles(fds); serCtx.registerMarshaller(new SessionDataMarshaller()); - RemoteCache cache = remoteCacheManager.getCache(DEFAULT_CACHE_NAME); - - ByteArrayOutputStream baos; - try (InputStream is = RemoteQueryManagerTest.class.getClassLoader().getResourceAsStream("session.proto")) + try (InputStream is = RemoteQueryManagerTest.class.getClassLoader().getResourceAsStream("session.proto"); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { if (is == null) throw new IllegalStateException("inputstream is null"); - - baos = new ByteArrayOutputStream(); IO.copy(is, baos); + String content = baos.toString("UTF-8"); + remoteCacheManager.getCache("___protobuf_metadata").put("session.proto", content); } - String content = baos.toString("UTF-8"); - remoteCacheManager.getCache("___protobuf_metadata").put("session.proto", content); + RemoteCache cache = remoteCacheManager.getCache(DEFAULT_CACHE_NAME); //put some sessions into the remote cache int numSessions = 10; @@ -97,7 +148,7 @@ public class RemoteQueryManagerTest String id = "sd" + i; //create new sessiondata with random expiry time long expiryTime = r.nextInt(maxExpiryTime); - SessionData sd = new SessionData(id, "", "", 0, 0, 0, 0); + InfinispanSessionData sd = new InfinispanSessionData(id, "", "", 0, 0, 0, 0); sd.setLastNode("lastNode"); sd.setExpiry(expiryTime); diff --git a/jetty-infinispan/infinispan-remote-query/src/test/resources/simplelogger.properties b/jetty-infinispan/infinispan-remote-query/src/test/resources/simplelogger.properties new file mode 100644 index 00000000000..0bd8aee936e --- /dev/null +++ b/jetty-infinispan/infinispan-remote-query/src/test/resources/simplelogger.properties @@ -0,0 +1,3 @@ +org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.infinispan.infinispanLogs=debug +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.infinispan.RemoteQueryManagerTest=debug diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index bd2ee0d6e6a..ba31c16285f 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -12,9 +12,7 @@ ${project.groupId}.sessions.infinispan - - - 9.4.8.Final + ${infinispan.version} jboss/infinispan-server diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index 05849c0831f..c94cb71ca73 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -39,7 +39,6 @@ import org.infinispan.protostream.FileDescriptorSource; import org.infinispan.protostream.SerializationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.Testcontainers; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; @@ -67,7 +66,7 @@ public class RemoteInfinispanTestSupport { try { - Testcontainers.exposeHostPorts(11222); + //Testcontainers.exposeHostPorts(11222); long start = System.currentTimeMillis(); String infinispanVersion = System.getProperty("infinispan.docker.image.version", "9.4.8.Final"); infinispan = @@ -80,11 +79,7 @@ public class RemoteInfinispanTestSupport .waitingFor(new LogMessageWaitStrategy() .withRegEx(".*Infinispan Server.*started in.*\\s")) .withExposedPorts(4712,4713,8088,8089,8443,9990,9993,11211,11222,11223,11224) - .withCopyFileToContainer(MountableFile.forClasspathResource("remote-session-test.xml"), - "/opt/jboss/infinispan-server/standalone/configuration/remote-session-test.xml") .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)); - // we could simply use `standalone` as well but... :) - infinispan = infinispan.withCommand("-c remote-session-test.xml"); infinispan.start(); String host = infinispan.getContainerIpAddress(); System.setProperty("hotrod.host", host); diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml b/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml deleted file mode 100644 index eebc11417e3..00000000000 --- a/tests/test-sessions/test-infinispan-sessions/src/test/resources/remote-session-test.xml +++ /dev/null @@ -1,392 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - h2 - - sa - sa - - - - - org.h2.jdbcx.JdbcDataSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 9b16f2deee34cdd4ed573231107a1cce070563a0 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 14 May 2020 15:00:30 +1000 Subject: [PATCH 43/77] do not create on start Signed-off-by: olivier lamy --- .../jetty/server/session/remote/RemoteInfinispanTestSupport.java | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java index c94cb71ca73..3955fe518fe 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/remote/RemoteInfinispanTestSupport.java @@ -133,7 +133,6 @@ public class RemoteInfinispanTestSupport String content = baos.toString("UTF-8"); _manager.administration().getOrCreateCache("___protobuf_metadata", (String)null).put("session.proto", content); - _manager.administration().getOrCreateCache("remote-session-test", (String)null); } catch (Exception e) { From 590b1a6ab17680b2793e4a1181e6226929cf732a Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 18 May 2020 11:49:12 +1000 Subject: [PATCH 44/77] Issue #4873 - fix timeout on ExecutorThreadPool.join() Signed-off-by: Lachlan Roberts --- .../java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java index db558cb8b89..9d1e2f0ea97 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutorThreadPool.java @@ -302,7 +302,7 @@ public class ExecutorThreadPool extends ContainerLifeCycle implements ThreadPool @Override public void join() throws InterruptedException { - _executor.awaitTermination(getStopTimeout(), TimeUnit.MILLISECONDS); + _executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); } @Override From 3215e11b3fe118652f181f6e4df2fb2c43aba7de Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 19 May 2020 16:28:53 +1000 Subject: [PATCH 45/77] Issue #4887 update documentation org.apache.aries.spifly.dynamic.bundle version 1.2.4 --- .../src/main/asciidoc/development/frameworks/osgi.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jetty-documentation/src/main/asciidoc/development/frameworks/osgi.adoc b/jetty-documentation/src/main/asciidoc/development/frameworks/osgi.adoc index 9f72bf7398c..e7059fdef4e 100644 --- a/jetty-documentation/src/main/asciidoc/development/frameworks/osgi.adoc +++ b/jetty-documentation/src/main/asciidoc/development/frameworks/osgi.adoc @@ -55,7 +55,7 @@ You *must also install the Apache Aries SPI Fly bundles* as many parts of Jetty [cols=",,",options="header",] |======================================================================= |Jar |Bundle Symbolic Name |Location -|org.apache.aries.spifly:org.apache.aries.spifly.dynamic.bundle-1.2.jar |org.apache.aries.spifly.dynamic.bundle +|org.apache.aries.spifly:org.apache.aries.spifly.dynamic.bundle-1.2.4.jar |org.apache.aries.spifly.dynamic.bundle |https://repo1.maven.org/maven2/org/apache/aries/spifly/org.apache.aries.spifly.dynamic.bundle/[Maven central] |======================================================================= From ae0b70fbfcca858eb554e3660896ed325c5b7b2a Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 20 May 2020 00:45:05 +1000 Subject: [PATCH 46/77] Issue #4873 - add test to reproduce the ExecutorThreadPool.join() issue Signed-off-by: Lachlan Roberts --- .../util/thread/ExecutorThreadPoolTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java index 95ab6a22aab..a495d719bb0 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java @@ -18,7 +18,13 @@ package org.eclipse.jetty.util.thread; +import java.time.Duration; + import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; public class ExecutorThreadPoolTest extends AbstractThreadPoolTest { @@ -27,4 +33,22 @@ public class ExecutorThreadPoolTest extends AbstractThreadPoolTest { return new ExecutorThreadPool(max); } + + @Test + public void testJoin() throws Exception + { + final long stopTimeout = 100; + ExecutorThreadPool executorThreadPool = new ExecutorThreadPool(10); + executorThreadPool.setStopTimeout(stopTimeout); + executorThreadPool.start(); + + // Verify that join does not timeout after waiting twice the stopTimeout. + assertThrows(Throwable.class, () -> + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), executorThreadPool::join) + ); + + // After stopping the ThreadPool join should unblock. + executorThreadPool.stop(); + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), executorThreadPool::join); + } } From 3845790c5d24ea69b1724acd45fdf27a76321c0c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 20 May 2020 10:47:23 +0200 Subject: [PATCH 47/77] Hpack optimizations If the dynamic table size is already 0, do not evictAll. Signed-off-by: Greg Wilkins --- .../eclipse/jetty/http2/hpack/HpackContext.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java index ab587240876..5625b2c0cb9 100644 --- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java +++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackContext.java @@ -395,12 +395,15 @@ public class HpackContext { if (LOG.isDebugEnabled()) LOG.debug(String.format("HdrTbl[%x] evictAll", HpackContext.this.hashCode())); - _fieldMap.clear(); - _nameMap.clear(); - _offset = 0; - _size = 0; - _dynamicTableSizeInBytes = 0; - Arrays.fill(_entries, null); + if (size() > 0) + { + _fieldMap.clear(); + _nameMap.clear(); + _offset = 0; + _size = 0; + _dynamicTableSizeInBytes = 0; + Arrays.fill(_entries, null); + } } } From 3ead429476cc82567631e40aa62376de7e178439 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 12:35:16 +0200 Subject: [PATCH 48/77] Fixes #4892 - Non-blocking JSON parser. Implemented non-blocking JSON parser. Signed-off-by: Simone Bordet --- .../eclipse/jetty/util/ajax/AsyncJSON.java | 1205 +++++++++++++++++ .../jetty/util/ajax/AsyncJSONTest.java | 503 +++++++ 2 files changed, 1708 insertions(+) create mode 100644 jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java create mode 100644 jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java new file mode 100644 index 00000000000..8dba7382402 --- /dev/null +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -0,0 +1,1205 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.util.ajax; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jetty.util.ArrayTernaryTrie; +import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.util.Loader; +import org.eclipse.jetty.util.Trie; +import org.eclipse.jetty.util.TypeUtil; +import org.eclipse.jetty.util.Utf8StringBuilder; + +public class AsyncJSON +{ + public static class Factory + { + private Trie cache; + private Map convertors; + private boolean detailedParseException; + + public boolean isDetailedParseException() + { + return detailedParseException; + } + + public void setDetailedParseException(boolean detailedParseException) + { + this.detailedParseException = detailedParseException; + } + + public void cache(String value) + { + if (cache == null) + cache = new ArrayTernaryTrie.Growing<>(false, 64, 64); + cache.put("\"" + value + "\"", value); + } + + public String cached(ByteBuffer buffer) + { + if (cache != null) + { + String result = cache.getBest(buffer, 0, buffer.remaining()); + if (result != null) + { + buffer.position(buffer.position() + result.length() + 2); + return result; + } + } + return null; + } + + public AsyncJSON newAsyncJSON() + { + return new AsyncJSON(this); + } + + public void putConvertor(String className, JSON.Convertor convertor) + { + if (convertors == null) + convertors = new ConcurrentHashMap<>(); + convertors.put(className, convertor); + } + + public JSON.Convertor removeConvertor(String className) + { + if (convertors != null) + return convertors.remove(className); + return null; + } + } + + private static final Object UNSET = new Object(); + + private final Factory factory; + private final FrameStack stack = new FrameStack(); + private final Utf8StringBuilder stringBuilder; + private final NumberBuilder numberBuilder; + private List chunks; + + public AsyncJSON(Factory factory) + { + this.factory = factory; + this.stringBuilder = new Utf8StringBuilder(32); + this.numberBuilder = new NumberBuilder(); + } + + // Used by tests only. + boolean isEmpty() + { + return stack.isEmpty(); + } + + public boolean parse(byte[] bytes) + { + return parse(ByteBuffer.wrap(bytes)); + } + + public boolean parse(ByteBuffer buffer) + { + try + { + if (factory.isDetailedParseException()) + { + if (chunks == null) + chunks = new ArrayList<>(); + ByteBuffer copy = buffer.isDirect() + ? ByteBuffer.allocateDirect(buffer.remaining()) + : ByteBuffer.allocate(buffer.remaining()); + copy.put(buffer).flip(); + chunks.add(copy); + buffer.flip(); + } + + if (stack.isEmpty()) + stack.push(State.COMPLETE, UNSET); + + while (true) + { + Frame frame = stack.peek(); + State state = frame.state; + switch (state) + { + case COMPLETE: + { + if (frame.value == UNSET) + { + if (parseAny(buffer)) + break; + return false; + } + else + { + while (buffer.hasRemaining()) + { + int position = buffer.position(); + byte peek = buffer.get(position); + if (Character.isWhitespace((char)peek)) + buffer.position(position + 1); + else + throw newInvalidJSON(buffer, "invalid character after JSON data"); + } + return true; + } + } + case NULL: + { + if (parseNull(buffer)) + break; + return false; + } + case TRUE: + { + if (parseTrue(buffer)) + break; + return false; + } + case FALSE: + { + if (parseFalse(buffer)) + break; + return false; + } + case NUMBER: + { + if (parseNumber(buffer)) + break; + return false; + } + case STRING: + { + if (parseString(buffer)) + break; + return false; + } + case ESCAPE: + { + if (parseEscape(buffer)) + break; + return false; + } + case UNICODE: + { + if (parseUnicode(buffer)) + break; + return false; + } + case ARRAY: + { + if (parseArray(buffer)) + break; + return false; + } + case OBJECT: + { + if (parseObject(buffer)) + break; + return false; + } + case OBJECT_FIELD: + { + if (parseObjectField(buffer)) + break; + return false; + } + case OBJECT_FIELD_NAME: + { + if (parseObjectFieldName(buffer)) + break; + return false; + } + case OBJECT_FIELD_VALUE: + { + if (parseObjectFieldValue(buffer)) + break; + return false; + } + default: + { + throw new IllegalStateException("invalid state " + state); + } + } + } + } + catch (Throwable x) + { + reset(); + throw x; + } + } + + public R eof() + { + try + { + if (stack.isEmpty()) + throw new IllegalStateException("no JSON parsed"); + + while (true) + { + State state = stack.peek().state; + switch (state) + { + case NUMBER: + { + Number value = numberBuilder.value(); + stack.pop(); + stack.peek().value(value); + break; + } + case COMPLETE: + { + if (stack.peek().value == UNSET) + throw new IllegalStateException("invalid state " + state); + return (R)complete(); + } + default: + { + throw newInvalidJSON(BufferUtil.EMPTY_BUFFER, "incomplete JSON"); + } + } + } + } + catch (Throwable x) + { + reset(); + throw x; + } + } + + protected Map newObject(Context context) + { + return new HashMap<>(); + } + + protected List newArray(Context context) + { + return new ArrayList<>(); + } + + private Object complete() + { + Object result = stack.peek().value; + reset(); + return result; + } + + private void reset() + { + stack.clear(); + chunks = null; + } + + private boolean parseAny(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte peek = buffer.get(buffer.position()); + switch (peek) + { + case '[': + if (parseArray(buffer)) + return true; + break; + case '{': + if (parseObject(buffer)) + return true; + break; + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (parseNumber(buffer)) + return true; + break; + case '"': + if (parseString(buffer)) + return true; + break; + case 'f': + if (parseFalse(buffer)) + return true; + break; + case 'n': + if (parseNull(buffer)) + return true; + break; + case 't': + if (parseTrue(buffer)) + return true; + break; + default: + if (Character.isWhitespace(peek)) + { + buffer.get(); + break; + } + throw newInvalidJSON(buffer, "unrecognized JSON value"); + } + } + return false; + } + + private boolean parseNull(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + case 'n': + if (stack.peek().state != State.NULL) + { + stack.push(State.NULL, 0); + parseNullCharacter(buffer, 0); + break; + } + throw newInvalidJSON(buffer, "invalid 'null' literal"); + case 'u': + parseNullCharacter(buffer, 1); + break; + case 'l': + int index = (Integer)stack.peek().value; + if (index == 2 || index == 3) + parseNullCharacter(buffer, index); + else + throw newInvalidJSON(buffer, "invalid 'null' literal"); + if (index == 3) + { + stack.pop(); + stack.peek().value(null); + return true; + } + break; + default: + throw newInvalidJSON(buffer, "invalid 'null' literal"); + } + } + return false; + } + + private void parseNullCharacter(ByteBuffer buffer, int index) + { + Frame frame = stack.peek(); + int value = (Integer)frame.value; + if (value == index) + frame.value = ++value; + else + throw newInvalidJSON(buffer, "invalid 'null' literal"); + } + + private boolean parseTrue(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + case 't': + if (stack.peek().state != State.TRUE) + { + stack.push(State.TRUE, 0); + parseTrueCharacter(buffer, 0); + break; + } + throw newInvalidJSON(buffer, "invalid 'true' literal"); + case 'r': + parseTrueCharacter(buffer, 1); + break; + case 'u': + parseTrueCharacter(buffer, 2); + break; + case 'e': + parseTrueCharacter(buffer, 3); + stack.pop(); + stack.peek().value(Boolean.TRUE); + return true; + default: + throw newInvalidJSON(buffer, "invalid 'true' literal"); + } + } + return false; + } + + private void parseTrueCharacter(ByteBuffer buffer, int index) + { + Frame frame = stack.peek(); + int value = (Integer)frame.value; + if (value == index) + frame.value = ++value; + else + throw newInvalidJSON(buffer, "invalid 'true' literal"); + } + + private boolean parseFalse(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + case 'f': + if (stack.peek().state != State.FALSE) + { + stack.push(State.FALSE, 0); + parseFalseCharacter(buffer, 0); + break; + } + throw newInvalidJSON(buffer, "invalid 'false' literal"); + case 'a': + parseFalseCharacter(buffer, 1); + break; + case 'l': + parseFalseCharacter(buffer, 2); + break; + case 's': + parseFalseCharacter(buffer, 3); + break; + case 'e': + parseFalseCharacter(buffer, 4); + stack.pop(); + stack.peek().value(Boolean.FALSE); + return true; + default: + throw newInvalidJSON(buffer, "invalid 'false' literal"); + } + } + return false; + } + + private void parseFalseCharacter(ByteBuffer buffer, int index) + { + Frame frame = stack.peek(); + int value = (Integer)frame.value; + if (value == index) + frame.value = ++value; + else + throw newInvalidJSON(buffer, "invalid 'false' literal"); + } + + private boolean parseNumber(ByteBuffer buffer) + { + if (stack.peek().state != State.NUMBER) + stack.push(State.NUMBER, numberBuilder); + + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + case '+': + case '-': + if (numberBuilder.appendSign(currentByte)) + break; + throw newInvalidJSON(buffer, "invalid number"); + case '.': + case 'E': + case 'e': + if (numberBuilder.appendAlpha(currentByte)) + break; + throw newInvalidJSON(buffer, "invalid number"); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + numberBuilder.appendDigit(currentByte); + break; + default: + buffer.position(buffer.position() - 1); + Number value = numberBuilder.value(); + stack.pop(); + stack.peek().value(value); + return true; + } + } + return false; + } + + private boolean parseString(ByteBuffer buffer) + { + Frame frame = stack.peek(); + if (buffer.hasRemaining() && frame.state != State.STRING) + { + String result = factory.cached(buffer); + if (result != null) + { + frame.value(result); + return true; + } + } + + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + // Explicit delimiter, handle push and pop in this method. + case '"': + { + if (stack.peek().state != State.STRING) + { + stack.push(State.STRING, stringBuilder); + break; + } + else + { + String string = stringBuilder.toString(); + stringBuilder.reset(); + stack.pop(); + stack.peek().value(string); + return true; + } + } + case '\\': + { + buffer.position(buffer.position() - 1); + if (parseEscape(buffer)) + break; + return false; + } + default: + { + stringBuilder.append(currentByte); + break; + } + } + } + return false; + } + + private boolean parseEscape(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + case '\\': + if (stack.peek().state != State.ESCAPE) + { + stack.push(State.ESCAPE, stringBuilder); + break; + } + else + { + return parseEscapeCharacter((char)currentByte); + } + case '"': + case '/': + return parseEscapeCharacter((char)currentByte); + case 'b': + return parseEscapeCharacter('\b'); + case 'f': + return parseEscapeCharacter('\f'); + case 'n': + return parseEscapeCharacter('\n'); + case 'r': + return parseEscapeCharacter('\r'); + case 't': + return parseEscapeCharacter('\t'); + case 'u': + stack.push(State.UNICODE, ByteBuffer.allocate(4)); + return parseUnicode(buffer); + default: + throw newInvalidJSON(buffer, "invalid escape sequence"); + } + } + return false; + } + + private boolean parseEscapeCharacter(char escape) + { + stack.pop(); + stringBuilder.append(escape); + return true; + } + + private boolean parseUnicode(ByteBuffer buffer) + { + // Expect 4 hex digits. + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + ByteBuffer hex = (ByteBuffer)stack.peek().value; + hex.put(hexToByte(buffer, currentByte)); + if (!hex.hasRemaining()) + { + int result = (hex.get(0) << 12) + + (hex.get(1) << 8) + + (hex.get(2) << 4) + + (hex.get(3)); + stack.pop(); + // Also done with escape parsing. + stack.pop(); + stringBuilder.append((char)result); + return true; + } + } + return false; + } + + private byte hexToByte(ByteBuffer buffer, byte currentByte) + { + try + { + return TypeUtil.convertHexDigit(currentByte); + } + catch (Throwable x) + { + throw newInvalidJSON(buffer, "invalid hex digit"); + } + } + + private boolean parseArray(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte peek = buffer.get(buffer.position()); + switch (peek) + { + // Explicit delimiters, handle push and pop in this method. + case '[': + { + buffer.get(); + stack.push(State.ARRAY, newArray(stack)); + break; + } + case ']': + { + buffer.get(); + Object array = stack.peek().value; + stack.pop(); + stack.peek().value(array); + return true; + } + case ',': + { + buffer.get(); + break; + } + default: + { + if (Character.isWhitespace(peek)) + { + buffer.get(); + break; + } + else + { + if (parseAny(buffer)) + { + break; + } + return false; + } + } + } + } + return false; + } + + private boolean parseObject(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte currentByte = buffer.get(); + switch (currentByte) + { + // Explicit delimiters, handle push and pop in this method. + case '{': + { + if (stack.peek().state != State.OBJECT) + { + stack.push(State.OBJECT, newObject(stack)); + break; + } + throw newInvalidJSON(buffer, "invalid object"); + } + case '}': + { + @SuppressWarnings("unchecked") + Map object = (Map)stack.peek().value; + stack.pop(); + stack.peek().value(convertObject(object)); + return true; + } + case ',': + { + break; + } + default: + { + if (Character.isWhitespace(currentByte)) + { + break; + } + else + { + buffer.position(buffer.position() - 1); + if (parseObjectField(buffer)) + break; + return false; + } + } + } + } + return false; + } + + private boolean parseObjectField(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte peek = buffer.get(buffer.position()); + switch (peek) + { + case '"': + { + if (stack.peek().state == State.OBJECT) + { + stack.push(State.OBJECT_FIELD, UNSET); + if (parseObjectFieldName(buffer)) + { + // We are not done yet, parse the value. + break; + } + return false; + } + else + { + return parseObjectFieldValue(buffer); + } + } + default: + { + if (Character.isWhitespace(peek)) + { + buffer.get(); + break; + } + else if (stack.peek().state == State.OBJECT_FIELD_VALUE) + { + return parseObjectFieldValue(buffer); + } + else + { + throw newInvalidJSON(buffer, "invalid object field"); + } + } + } + } + return false; + } + + private boolean parseObjectFieldName(ByteBuffer buffer) + { + while (buffer.hasRemaining()) + { + byte peek = buffer.get(buffer.position()); + switch (peek) + { + case '"': + { + if (stack.peek().state == State.OBJECT_FIELD) + { + stack.push(State.OBJECT_FIELD_NAME, UNSET); + if (parseString(buffer)) + { + // We are not done yet, parse until the ':'. + break; + } + return false; + } + else + { + throw newInvalidJSON(buffer, "invalid object field"); + } + } + case ':': + { + buffer.get(); + // We are done with the field name. + String fieldName = (String)stack.peek().value; + stack.pop(); + // Change state to parse the field value. + stack.push(fieldName, State.OBJECT_FIELD_VALUE, UNSET); + return true; + } + default: + { + if (Character.isWhitespace(peek)) + { + buffer.get(); + break; + } + else + { + throw newInvalidJSON(buffer, "invalid object field"); + } + } + } + } + return false; + } + + private boolean parseObjectFieldValue(ByteBuffer buffer) + { + if (stack.peek().value == UNSET) + { + if (!parseAny(buffer)) + return false; + } + + // We are done with the field value. + Frame frame = stack.peek(); + Object value = frame.value; + String name = frame.name; + stack.pop(); + // We are done with the field. + stack.pop(); + @SuppressWarnings("unchecked") + Map map = (Map)stack.peek().value; + map.put(name, value); + + return true; + } + + private Object convertObject(Map object) + { + Object result = convertObject("x-class", object); + if (result == null) + { + result = convertObject("class", object); + if (result == null) + return object; + } + return result; + } + + private Object convertObject(String fieldName, Map object) + { + String className = (String)object.get(fieldName); + if (className == null) + return null; + + JSON.Convertible convertible = toConvertible(className); + if (convertible != null) + { + convertible.fromJSON(object); + return convertible; + } + + JSON.Convertor convertor = factory.convertors.get(className); + if (convertor != null) + return convertor.fromJSON(object); + + return null; + } + + private JSON.Convertible toConvertible(String className) + { + try + { + Class klass = Loader.loadClass(className); + if (JSON.Convertible.class.isAssignableFrom(klass)) + return (JSON.Convertible)klass.getConstructor().newInstance(); + return null; + } + catch (Throwable x) + { + throw new IllegalArgumentException(x); + } + } + + protected RuntimeException newInvalidJSON(ByteBuffer buffer, String message) + { + Utf8StringBuilder builder = new Utf8StringBuilder(); + builder.append(System.lineSeparator()); + int position = buffer.position(); + if (factory.isDetailedParseException()) + { + chunks.forEach(chunk -> builder.append(buffer)); + } + else + { + buffer.position(0); + builder.append(buffer); + buffer.position(position); + } + builder.append(System.lineSeparator()); + String indent = ""; + if (position > 1) + { + char[] chars = new char[position - 1]; + Arrays.fill(chars, ' '); + indent = new String(chars); + } + builder.append(indent); + builder.append("^ "); + builder.append(message); + return new IllegalArgumentException(builder.toString()); + } + + public interface Context + { + public int depth(); + } + + private enum State + { + COMPLETE, NULL, TRUE, FALSE, NUMBER, STRING, ESCAPE, UNICODE, ARRAY, OBJECT, OBJECT_FIELD, OBJECT_FIELD_NAME, OBJECT_FIELD_VALUE + } + + private static class Frame + { + private String name; + private State state; + private Object value; + + private Frame(State state, Object value) + { + this.state = state; + this.value = value; + } + + private void value(Object value) + { + switch (state) + { + case COMPLETE: + case STRING: + case OBJECT_FIELD_NAME: + case OBJECT_FIELD_VALUE: + { + this.value = value; + break; + } + case ARRAY: + { + @SuppressWarnings("unchecked") + List array = (List)this.value; + array.add(value); + break; + } + default: + { + throw new IllegalStateException("invalid state " + state); + } + } + } + } + + private static class NumberBuilder + { + // 1 => positive integer + // 0 => non-integer + // -1 => negative integer + private int integer = 1; + private long value; + private StringBuilder builder; + + private boolean appendSign(byte b) + { + if (integer == 0) + { + if (builder.length() == 0) + { + builder.append((char)b); + return true; + } + else + { + char c = builder.charAt(builder.length() - 1); + if (c == 'E' || c == 'e') + { + builder.append((char)b); + return true; + } + } + return false; + } + else + { + if (value == 0) + { + if (b == '-') + { + if (integer == 1) + { + integer = -1; + return true; + } + } + else + { + return true; + } + } + } + return false; + } + + private void appendDigit(byte b) + { + if (integer == 0) + builder.append((char)b); + else + value = value * 10 + (b - '0'); + } + + private boolean appendAlpha(byte b) + { + if (integer == 0) + { + char c = builder.charAt(builder.length() - 1); + if ('0' <= c && c <= '9' && builder.indexOf("" + (char)b) < 0) + { + builder.append((char)b); + return true; + } + } + else + { + if (builder == null) + builder = new StringBuilder(16); + if (integer == -1) + builder.append('-'); + integer = 0; + builder.append(value); + builder.append((char)b); + return true; + } + return false; + } + + private Number value() + { + try + { + if (integer == 0) + return Double.parseDouble(builder.toString()); + return integer * value; + } + finally + { + reset(); + } + } + + private void reset() + { + integer = 1; + value = 0; + if (builder != null) + builder.setLength(0); + } + } + + private static class FrameStack implements AsyncJSON.Context + { + private final List stack = new ArrayList<>(); + private int cursor; + + private FrameStack() + { + grow(6); + } + + private void grow(int grow) + { + for (int i = 0; i < grow; i++) + { + stack.add(new Frame(null, null)); + } + } + + private void clear() + { + while (!isEmpty()) + { + pop(); + } + } + + private boolean isEmpty() + { + return cursor == 0; + } + + @Override + public int depth() + { + return cursor - 1; + } + + private Frame peek() + { + if (isEmpty()) + throw new IllegalStateException("empty stack"); + return stack.get(depth()); + } + + private void push(AsyncJSON.State state, Object value) + { + push(null, state, value); + } + + private void push(String name, AsyncJSON.State state, Object value) + { + if (cursor == stack.size()) + grow(2); + ++cursor; + Frame frame = stack.get(depth()); + frame.name = name; + frame.state = state; + frame.value = value; + } + + private void pop() + { + if (isEmpty()) + throw new IllegalStateException("empty stack"); + Frame frame = stack.get(depth()); + --cursor; + frame.name = null; + frame.value = null; + frame.state = null; + } + } +} diff --git a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java new file mode 100644 index 00000000000..07b2ccadce8 --- /dev/null +++ b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2008-2020 the original author or authors. + * + * Licensed 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 org.eclipse.jetty.util.ajax; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class AsyncJSONTest +{ + private static AsyncJSON newAsyncJSON() + { + AsyncJSON.Factory factory = new AsyncJSON.Factory(); + factory.setDetailedParseException(true); + return factory.newAsyncJSON(); + } + + @ParameterizedTest + @ValueSource(strings = {"|", "}", "]", "{]", "[}", "+", ".", "{} []"}) + public void testParseInvalidJSON(String json) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertThrows(IllegalArgumentException.class, () -> parser.parse(bytes)); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + assertThrows(IllegalArgumentException.class, () -> + { + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + }); + assertTrue(parser.isEmpty()); + } + + + @ParameterizedTest(name = "[{index}] ''{0}'' -> ''{1}''") + @MethodSource("validStrings") + public void testParseString(String string, String expected) + { + String json = "\"${value}\"".replace("${value}", string); + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertTrue(parser.parse(bytes)); + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + for (int i = 0; i < bytes.length; ++i) + { + byte b = bytes[i]; + if (i == bytes.length - 1) + assertTrue(parser.parse(new byte[]{b})); + else + assertFalse(parser.parse(new byte[]{b})); + } + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + } + + public static List validStrings() + { + List result = new ArrayList<>(); + result.add(new Object[]{"", ""}); + result.add(new Object[]{" \t\r\n", " \t\r\n"}); + result.add(new Object[]{"\u20AC", "\u20AC"}); + result.add(new Object[]{"\\u20AC", "\u20AC"}); + result.add(new Object[]{"/foo", "/foo"}); + result.add(new Object[]{"123E+01", "123E+01"}); + result.add(new Object[]{"A\\u20AC/foo\\t\\n", "A\u20AC/foo\t\n"}); + result.add(new Object[]{" ABC ", " ABC "}); + return result; + } + + @ParameterizedTest + @ValueSource(strings = {"\\u", "\\u0", "\\x"}) + public void testParseInvalidString(String value) + { + String json = "\"${value}\"".replace("${value}", value); + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertThrows(IllegalArgumentException.class, () -> parser.parse(bytes)); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + assertThrows(IllegalArgumentException.class, () -> + { + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + }); + assertTrue(parser.isEmpty()); + } + + @ParameterizedTest(name = "[{index}] {0} -> {1}") + @MethodSource("validArrays") + public void testParseArray(String json, List expected) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertTrue(parser.parse(bytes)); + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + ByteBuffer buffer = ByteBuffer.wrap(bytes); + assertTrue(parser.parse(buffer)); + assertFalse(buffer.hasRemaining()); + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + } + + public static List validArrays() + { + List result = new ArrayList<>(); + + List expected = Collections.emptyList(); + result.add(new Object[]{"[]", expected}); + result.add(new Object[]{"[] \n", expected}); + + expected = new ArrayList<>(); + expected.add(Collections.emptyList()); + result.add(new Object[]{"[[]]", expected}); + + expected = new ArrayList<>(); + expected.add("first"); + expected.add(5D); + expected.add(null); + expected.add(true); + expected.add(false); + expected.add(new HashMap<>()); + HashMap last = new HashMap<>(); + last.put("a", new ArrayList<>()); + expected.add(last); + result.add(new Object[]{"[\"first\", 5E+0, null, true, false, {}, {\"a\":[]}]", expected}); + + return result; + } + + @ParameterizedTest + @ValueSource(strings = {"[", "]", "[[,]", " [ 1,2,[ "}) + public void testParseInvalidArray(String json) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertThrows(IllegalArgumentException.class, () -> + { + parser.parse(bytes); + parser.eof(); + }); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + assertThrows(IllegalArgumentException.class, () -> + { + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + parser.eof(); + }); + assertTrue(parser.isEmpty()); + } + + @ParameterizedTest(name = "[{index}] {0} -> {1}") + @MethodSource("validObjects") + public void testParseObject(String json, Object expected) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertTrue(parser.parse(bytes)); + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + for (int i = 0; i < bytes.length; ++i) + { + byte b = bytes[i]; + if (i == bytes.length - 1) + { + assertTrue(parser.parse(new byte[]{b})); + } + else + { + assertFalse(parser.parse(new byte[]{b})); + } + } + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + } + + public static List validObjects() + { + List result = new ArrayList<>(); + + HashMap expected = new HashMap<>(); + result.add(new Object[]{"{}", expected}); + + expected = new HashMap<>(); + expected.put("", 0L); + result.add(new Object[]{"{\"\":0}", expected}); + + expected = new HashMap<>(); + expected.put("name", "value"); + result.add(new Object[]{"{ \"name\": \"value\" }", expected}); + + expected = new HashMap<>(); + expected.put("name", null); + expected.put("valid", true); + expected.put("secure", false); + expected.put("value", 42L); + result.add(new Object[]{ + "{, \"name\": null, \"valid\": true\n , \"secure\": false\r\n,\n \"value\":42, }", expected + }); + + return result; + } + + @ParameterizedTest + @ValueSource(strings = {"{", "}", "{{,}", "{:\"s\"}", "{[]:0}", "{1:0}", " {\": 0} ", "{\"a: \"b\"}"}) + public void testParseInvalidObject(String json) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertThrows(IllegalArgumentException.class, () -> + { + parser.parse(bytes); + parser.eof(); + }); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + assertThrows(IllegalArgumentException.class, () -> + { + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + parser.eof(); + }); + assertTrue(parser.isEmpty()); + } + + @ParameterizedTest(name = "[{index}] {0} -> {1}") + @MethodSource("validNumbers") + public void testParseNumber(String json, Number expected) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + parser.parse(bytes); + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + ByteBuffer buffer = ByteBuffer.wrap(bytes); + parser.parse(buffer); + assertEquals(expected, parser.eof()); + assertFalse(buffer.hasRemaining()); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + assertEquals(expected, parser.eof()); + assertTrue(parser.isEmpty()); + } + + public static List validNumbers() + { + List result = new ArrayList<>(); + + result.add(new Object[]{"0", 0L}); + result.add(new Object[]{"-0", -0L}); + result.add(new Object[]{"13\n", 13L}); + result.add(new Object[]{"-42", -42L}); + result.add(new Object[]{"123.456", 123.456D}); + result.add(new Object[]{"-234.567", -234.567D}); + result.add(new Object[]{"9e0", 9D}); + result.add(new Object[]{"8E+1\t", 80D}); + result.add(new Object[]{"-7E-2 ", -0.07D}); + result.add(new Object[]{"70.5E-1", 7.05D}); + + return result; + } + + @ParameterizedTest + @ValueSource(strings = {"--", "--1", ".5", "e0", "1a1", "3-7", "1+2", "1e0e1", "1.2.3"}) + public void testParseInvalidNumber(String json) + { + byte[] bytes = json.getBytes(UTF_8); + AsyncJSON parser = newAsyncJSON(); + + // Parse the whole input. + assertThrows(IllegalArgumentException.class, () -> + { + parser.parse(bytes); + parser.eof(); + }); + assertTrue(parser.isEmpty()); + + // Parse byte by byte. + assertThrows(IllegalArgumentException.class, () -> + { + for (byte b : bytes) + { + parser.parse(new byte[]{b}); + } + parser.eof(); + }); + assertTrue(parser.isEmpty()); + } + + @Test + public void testParseObjectWithConvertor() + { + AsyncJSON.Factory factory = new AsyncJSON.Factory(); + CustomConvertor convertor = new CustomConvertor(); + factory.putConvertor(CustomConvertor.class.getName(), convertor); + + String json = "{" + + "\"f1\": {\"class\":\"" + CustomConvertible.class.getName() + "\", \"field\": \"value\"}," + + "\"f2\": {\"class\":\"" + CustomConvertor.class.getName() + "\"}" + + "}"; + + AsyncJSON parser = factory.newAsyncJSON(); + assertTrue(parser.parse(UTF_8.encode(json))); + Map result = parser.eof(); + + Object value1 = result.get("f1"); + assertTrue(value1 instanceof CustomConvertible); + assertEquals("value", ((CustomConvertible)value1).field); + Object value2 = result.get("f2"); + assertTrue(value2 instanceof CustomConvertor.Custom); + + assertSame(convertor, factory.removeConvertor(CustomConvertor.class.getName())); + assertTrue(parser.parse(UTF_8.encode(json))); + result = parser.eof(); + + value1 = result.get("f1"); + assertTrue(value1 instanceof CustomConvertible); + assertEquals("value", ((CustomConvertible)value1).field); + value2 = result.get("f2"); + assertTrue(value2 instanceof Map); + @SuppressWarnings("unchecked") + Map map2 = (Map)value2; + assertEquals(CustomConvertor.class.getName(), map2.get("class")); + } + + public static class CustomConvertible implements JSON.Convertible + { + private Object field; + + @Override + public void toJSON(JSON.Output out) + { + } + + @Override + public void fromJSON(Map map) + { + this.field = map.get("field"); + } + } + + public static class CustomConvertor implements JSON.Convertor + { + @Override + public void toJSON(Object obj, JSON.Output out) + { + } + + @Override + public Object fromJSON(Map map) + { + return new Custom(); + } + + public static class Custom + { + } + } + + @Test + public void testContext() + { + AsyncJSON.Factory factory = new AsyncJSON.Factory() + { + @Override + public AsyncJSON newAsyncJSON() + { + return new AsyncJSON(this) + { + @Override + protected Map newObject(Context context) + { + if (context.depth() == 1) + { + return new CustomMap(); + } + return super.newObject(context); + } + }; + } + }; + AsyncJSON parser = factory.newAsyncJSON(); + + String json = "[{" + + "\"channel\": \"/meta/handshake\"," + + "\"version\": \"1.0\"," + + "\"supportedConnectionTypes\": [\"long-polling\"]," + + "\"advice\": {\"timeout\": 0}" + + "}]"; + + assertTrue(parser.parse(UTF_8.encode(json))); + List messages = parser.eof(); + + for (CustomMap message : messages) + { + @SuppressWarnings("unchecked") + Map advice = (Map)message.get("advice"); + assertFalse(advice instanceof CustomMap); + } + } + + public static class CustomMap extends HashMap + { + } + + @Test + public void testCaching() + { + AsyncJSON.Factory factory = new AsyncJSON.Factory(); + String foo = "foo"; + factory.cache(foo); + AsyncJSON parser = factory.newAsyncJSON(); + + String json = "{\"foo\": [\"foo\", \"foo\"]}"; + parser.parse(UTF_8.encode(json)); + Map object = parser.eof(); + + Map.Entry entry = object.entrySet().iterator().next(); + assertSame(foo, entry.getKey()); + @SuppressWarnings("unchecked") + List array = (List)entry.getValue(); + for (String item : array) + { + assertSame(foo, item); + } + } +} From caf2592587d5c2ff2e94091ce6cfb672a861beaa Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 13:00:29 +0200 Subject: [PATCH 49/77] Fixes #4892 - Non-blocking JSON parser. Fixed copyright header. Signed-off-by: Simone Bordet --- .../jetty/util/ajax/AsyncJSONTest.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java index 07b2ccadce8..cbc70bc13af 100644 --- a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java +++ b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java @@ -1,18 +1,21 @@ -/* - * Copyright (c) 2008-2020 the original author or authors. - * - * Licensed 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. - */ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + package org.eclipse.jetty.util.ajax; import java.nio.ByteBuffer; From bed046f01ce8019b61694ef62de867bed84a7d27 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 13:08:02 +0200 Subject: [PATCH 50/77] Fixes #4892 - Non-blocking JSON parser. Fixed checkstyle. Signed-off-by: Simone Bordet --- .../java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java index cbc70bc13af..d808ea400c4 100644 --- a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java +++ b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java @@ -68,7 +68,6 @@ public class AsyncJSONTest assertTrue(parser.isEmpty()); } - @ParameterizedTest(name = "[{index}] ''{0}'' -> ''{1}''") @MethodSource("validStrings") public void testParseString(String string, String expected) @@ -100,11 +99,11 @@ public class AsyncJSONTest List result = new ArrayList<>(); result.add(new Object[]{"", ""}); result.add(new Object[]{" \t\r\n", " \t\r\n"}); - result.add(new Object[]{"\u20AC", "\u20AC"}); - result.add(new Object[]{"\\u20AC", "\u20AC"}); + result.add(new Object[]{"\u20AC", "\u20AC"}); // euro symbol + result.add(new Object[]{"\\u20AC", "\u20AC"}); // euro symbol result.add(new Object[]{"/foo", "/foo"}); result.add(new Object[]{"123E+01", "123E+01"}); - result.add(new Object[]{"A\\u20AC/foo\\t\\n", "A\u20AC/foo\t\n"}); + result.add(new Object[]{"A\\u20AC/foo\\t\\n", "A\u20AC/foo\t\n"}); // euro symbol result.add(new Object[]{" ABC ", " ABC "}); return result; } From f2ef054b289167c98e51f49867eaf32ebdf6dca3 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 14:03:30 +0200 Subject: [PATCH 51/77] Fixes #4892 - Non-blocking JSON parser. Added javadocs. Signed-off-by: Simone Bordet --- .../eclipse/jetty/util/ajax/AsyncJSON.java | 148 +++++++++++++++++- 1 file changed, 140 insertions(+), 8 deletions(-) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java index 8dba7382402..00b83b4063e 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -32,25 +32,76 @@ import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.Trie; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.Utf8StringBuilder; +import org.eclipse.jetty.util.ajax.JSON.Convertible; +import org.eclipse.jetty.util.ajax.JSON.Convertor; +/** + *

    A non-blocking JSON parser that can parse partial JSON strings.

    + *

    Usage:

    + *
    + * AsyncJSON parser = new AsyncJSON.Factory().newAsyncJSON();
    + *
    + * // Feed the parser with partial JSON string content.
    + * parser.parse(chunk1);
    + * parser.parse(chunk2);
    + *
    + * // Tell the parser that the JSON string content
    + * // is terminated and get the JSON object back.
    + * Map<String, Object> object = parser.eof();
    + * 
    + *

    After the call to {@link #eof()} the parser can be reused to parse + * another JSON string.

    + *

    Custom objects can be created by specifying a {@code "class"} or + * {@code "x-class"} field:

    + *
    + * String json = """
    + * {
    + *   "x-class": "com.acme.Person",
    + *   "firstName": "John",
    + *   "lastName": "Doe",
    + *   "age": 42
    + * }
    + * """
    + *
    + * parser.parse(json);
    + * com.acme.Person person = parser.eof();
    + * 
    + *

    Class {@code com.acme.Person} must either implement {@link Convertible}, + * or be mapped with a {@link Convertor} via {@link Factory#putConvertor(String, Convertor)}.

    + */ public class AsyncJSON { + /** + *

    The factory that creates AsyncJSON instances.

    + *

    The factory can be configured with custom {@link Convertor}s, + * and with cached strings that will not be allocated if they can + * be looked up from the cache.

    + */ public static class Factory { private Trie cache; - private Map convertors; + private Map convertors; private boolean detailedParseException; + /** + * @return whether a parse failure should report the whole JSON string or just the last chunk + */ public boolean isDetailedParseException() { return detailedParseException; } + /** + * @param detailedParseException whether a parse failure should report the whole JSON string or just the last chunk + */ public void setDetailedParseException(boolean detailedParseException) { this.detailedParseException = detailedParseException; } + /** + * @param value the string to cache + */ public void cache(String value) { if (cache == null) @@ -58,6 +109,16 @@ public class AsyncJSON cache.put("\"" + value + "\"", value); } + /** + *

    Attempts to return a cached string from the buffer bytes.

    + *

    In case of a cache hit, the string is returned and the buffer + * position updated.

    + *

    In case of cache miss, {@code null} is returned and the buffer + * position is left unaltered.

    + * + * @param buffer the buffer to lookup the string from + * @return a cached string or {@code null} + */ public String cached(ByteBuffer buffer) { if (cache != null) @@ -72,24 +133,50 @@ public class AsyncJSON return null; } + /** + * @return a new parser instance + */ public AsyncJSON newAsyncJSON() { return new AsyncJSON(this); } - public void putConvertor(String className, JSON.Convertor convertor) + /** + *

    Associates the given {@link Convertor} to the given class name.

    + * + * @param className the domain class name such as {@code com.acme.Person} + * @param convertor the {@link Convertor} that converts {@code Map} to domain objects + */ + public void putConvertor(String className, Convertor convertor) { if (convertors == null) convertors = new ConcurrentHashMap<>(); convertors.put(className, convertor); } - public JSON.Convertor removeConvertor(String className) + /** + *

    Removes the {@link Convertor} associated with the given class name.

    + * + * @param className the class name associated with the {@link Convertor} + * @return the {@link Convertor} associated with the class name, or {@code null} + */ + public Convertor removeConvertor(String className) { if (convertors != null) return convertors.remove(className); return null; } + + /** + *

    Returns the {@link Convertor} associated with the given class name, if any.

    + * + * @param className the class name associated with the {@link Convertor} + * @return the {@link Convertor} associated with the class name, or {@code null} + */ + public Convertor getConvertor(String className) + { + return convertors == null ? null : convertors.get(className); + } } private static final Object UNSET = new Object(); @@ -113,11 +200,24 @@ public class AsyncJSON return stack.isEmpty(); } + /** + *

    Feeds the parser with the given bytes chunk.

    + * + * @param bytes the bytes to parse + * @return whether the JSON parsing was complete + */ public boolean parse(byte[] bytes) { return parse(ByteBuffer.wrap(bytes)); } + /** + *

    Feeds the parser with the given buffer chunk.

    + * + * @param buffer the buffer to parse + * @return whether the JSON parsing was complete + * @throws IllegalArgumentException if the JSON is malformed + */ public boolean parse(ByteBuffer buffer) { try @@ -251,6 +351,16 @@ public class AsyncJSON } } + /** + *

    Signals to the parser that the parse data is complete, and returns + * the object parsed from the JSON chunks passed to the {@code parse()} + * methods.

    + * + * @param the type the result is cast to + * @return the result of the JSON parsing + * @throws IllegalArgumentException if the JSON is malformed + * @throws IllegalStateException if the no JSON was passed to the {@code parse()} methods + */ public R eof() { try @@ -290,11 +400,27 @@ public class AsyncJSON } } + /** + *

    When a JSON { is encountered during parsing, + * this method is called to create a new {@code Map} instance.

    + *

    Subclasses may override to return a custom {@code Map} instance.

    + * + * @param context the parsing context + * @return a {@code Map} instance + */ protected Map newObject(Context context) { return new HashMap<>(); } + /** + *

    When a JSON [ is encountered during parsing, + * this method is called to create a new {@code List} instance.

    + *

    Subclasses may override to return a custom {@code List} instance.

    + * + * @param context the parsing context + * @return a {@code List} instance + */ protected List newArray(Context context) { return new ArrayList<>(); @@ -918,27 +1044,27 @@ public class AsyncJSON if (className == null) return null; - JSON.Convertible convertible = toConvertible(className); + Convertible convertible = toConvertible(className); if (convertible != null) { convertible.fromJSON(object); return convertible; } - JSON.Convertor convertor = factory.convertors.get(className); + Convertor convertor = factory.getConvertor(className); if (convertor != null) return convertor.fromJSON(object); return null; } - private JSON.Convertible toConvertible(String className) + private Convertible toConvertible(String className) { try { Class klass = Loader.loadClass(className); - if (JSON.Convertible.class.isAssignableFrom(klass)) - return (JSON.Convertible)klass.getConstructor().newInstance(); + if (Convertible.class.isAssignableFrom(klass)) + return (Convertible)klass.getConstructor().newInstance(); return null; } catch (Throwable x) @@ -976,8 +1102,14 @@ public class AsyncJSON return new IllegalArgumentException(builder.toString()); } + /** + *

    The state of JSON parsing.

    + */ public interface Context { + /** + * @return the depth in the JSON structure + */ public int depth(); } From 9ad7ff795e5ec5139981ce384303baa14171c687 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 15:12:24 +0200 Subject: [PATCH 52/77] Fixes #4892 - Non-blocking JSON parser. Updates after review. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/util/ajax/AsyncJSON.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java index 00b83b4063e..9899258cfac 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -181,17 +181,15 @@ public class AsyncJSON private static final Object UNSET = new Object(); - private final Factory factory; private final FrameStack stack = new FrameStack(); - private final Utf8StringBuilder stringBuilder; - private final NumberBuilder numberBuilder; + private final NumberBuilder numberBuilder = new NumberBuilder(); + private final Utf8StringBuilder stringBuilder = new Utf8StringBuilder(32); + private final Factory factory; private List chunks; public AsyncJSON(Factory factory) { this.factory = factory; - this.stringBuilder = new Utf8StringBuilder(32); - this.numberBuilder = new NumberBuilder(); } // Used by tests only. @@ -1124,12 +1122,6 @@ public class AsyncJSON private State state; private Object value; - private Frame(State state, Object value) - { - this.state = state; - this.value = value; - } - private void value(Object value) { switch (state) @@ -1277,7 +1269,7 @@ public class AsyncJSON { for (int i = 0; i < grow; i++) { - stack.add(new Frame(null, null)); + stack.add(new Frame()); } } From 8d5430bc60473afbdb0d194bc5f30ad2f9a09274 Mon Sep 17 00:00:00 2001 From: Lachlan Date: Wed, 20 May 2020 23:23:32 +1000 Subject: [PATCH 53/77] Issue #4741 - fix issues with HttpServletMapping (#4851) * Issue #4741 - fixes to jetty implementation of HttpServletMapping Signed-off-by: Lachlan Roberts * Issue #4741 - don't lazily generate HttpServletMapping to preserve servletName Signed-off-by: Lachlan Roberts * Issue #4741 - tests should expect no leading / for matchValue Signed-off-by: Lachlan Roberts * resolving TODOs from review - removed pathSpec from Request - getServletMapping moved to ServletHandler Signed-off-by: Lachlan Roberts * Issue #4741 - only create HttpServletMapping for exact matches once Signed-off-by: Lachlan Roberts * use wrapped attributes for async dispatch Signed-off-by: Lachlan Roberts * Issue #4741 - Changes from review, revert async attribute wrapping Signed-off-by: Lachlan Roberts * Issue #4741 - Changes from review Signed-off-by: Lachlan Roberts * Issue #4741 Async ServletMapping Greatly increased the scope of this PR by combining the servletPath and pathInfo into the ServletPathMapping class that implements the HttpServletPathMapping interface. This allows us to greatly simplify the matching of servlets and reduce the number of times we need to actually to the match per request. Signed-off-by: Greg Wilkins * Issue #4741 Async ServletMapping Fixed problems with previous commit more cleanup of attributes in dispatcher. Signed-off-by: Greg Wilkins * Issue #4741 Async ServletMapping More code cleanups Signed-off-by: Greg Wilkins * Issue #4741 Async ServletMapping Named dispatch cleanup Signed-off-by: Greg Wilkins * Issue #4741 Async ServletMapping misc cleanup Signed-off-by: Greg Wilkins * Issue #4741 Async HttpServletMapping Added tests for named dispatchers Do not use ServletPathMapping for named dispatch Signed-off-by: Greg Wilkins * Issue #4741 Async HttpServletMapping renamed confusing isDefault method on ServletMapping Signed-off-by: Greg Wilkins * Issue #4741 Async HttpServletMapping simplified setAttribute Signed-off-by: Greg Wilkins * Issue #4741 Async HttpServletMapping added javadoc about AsyncAttributes Signed-off-by: Greg Wilkins * Issue #4741 Async HttpServletMapping Fixed javadoc Signed-off-by: Greg Wilkins Co-authored-by: Greg Wilkins --- .../annotations/WebServletAnnotation.java | 4 +- .../annotations/TestServletAnnotations.java | 8 +- .../QuickStartDescriptorProcessor.java | 2 +- .../jetty/quickstart/TestQuickStart.java | 2 +- .../eclipse/jetty/server/AsyncAttributes.java | 86 ++----- .../org/eclipse/jetty/server/Dispatcher.java | 202 +++++---------- .../org/eclipse/jetty/server/Request.java | 195 ++++++--------- .../jetty/server/ServletAttributes.java | 13 +- .../jetty/server/ServletPathMapping.java | 159 ++++++++++++ .../org/eclipse/jetty/server/RequestTest.java | 152 +++++++----- .../eclipse/jetty/servlet/DefaultServlet.java | 5 +- .../org/eclipse/jetty/servlet/Invoker.java | 7 +- .../eclipse/jetty/servlet/ServletHandler.java | 229 ++++++++++-------- .../eclipse/jetty/servlet/ServletHolder.java | 2 +- .../eclipse/jetty/servlet/ServletMapping.java | 4 +- .../jetty/servlet/AsyncContextTest.java | 2 +- .../eclipse/jetty/servlet/DispatcherTest.java | 67 ++++- .../servlet/ServletContextHandlerTest.java | 13 +- .../jetty/servlet/ServletHandlerTest.java | 15 +- .../webapp/StandardDescriptorProcessor.java | 6 +- 20 files changed, 629 insertions(+), 544 deletions(-) create mode 100644 jetty-server/src/main/java/org/eclipse/jetty/server/ServletPathMapping.java diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotation.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotation.java index c310dfc0036..0ad7e061bc7 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotation.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/WebServletAnnotation.java @@ -211,7 +211,7 @@ public class WebServletAnnotation extends DiscoveredAnnotation for (String p : urlPatternList) { ServletMapping existingMapping = _context.getServletHandler().getServletMapping(p); - if (existingMapping != null && existingMapping.isDefault()) + if (existingMapping != null && existingMapping.isFromDefaultDescriptor()) { String[] updatedPaths = ArrayUtil.removeFromArray(existingMapping.getPathSpecs(), p); //if we removed the last path from a servletmapping, delete the servletmapping @@ -264,7 +264,7 @@ public class WebServletAnnotation extends DiscoveredAnnotation return false; for (ServletMapping m : mappings) { - if (!m.isDefault()) + if (!m.isFromDefaultDescriptor()) return true; } return false; diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java index c8e5d29516f..3572e08185d 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestServletAnnotations.java @@ -117,7 +117,7 @@ public class TestServletAnnotations ServletMapping m = new ServletMapping(); m.setPathSpec("/"); m.setServletName("default"); - m.setDefault(true); //this mapping will be from a default descriptor + m.setFromDefaultDescriptor(true); //this mapping will be from a default descriptor wac.getServletHandler().addServletMapping(m); WebServletAnnotation annotation = new WebServletAnnotation(wac, "org.eclipse.jetty.annotations.ServletD", null); @@ -150,13 +150,13 @@ public class TestServletAnnotations ServletMapping m = new ServletMapping(); m.setPathSpec("/"); m.setServletName("default"); - m.setDefault(true); //this mapping will be from a default descriptor + m.setFromDefaultDescriptor(true); //this mapping will be from a default descriptor wac.getServletHandler().addServletMapping(m); ServletMapping m2 = new ServletMapping(); m2.setPathSpec("/other"); m2.setServletName("default"); - m2.setDefault(true); //this mapping will be from a default descriptor + m2.setFromDefaultDescriptor(true); //this mapping will be from a default descriptor wac.getServletHandler().addServletMapping(m2); WebServletAnnotation annotation = new WebServletAnnotation(wac, "org.eclipse.jetty.annotations.ServletD", null); @@ -235,7 +235,7 @@ public class TestServletAnnotations ServletMapping m = new ServletMapping(); m.setPathSpec("/default"); - m.setDefault(true); + m.setFromDefaultDescriptor(true); m.setServletName("DServlet"); wac.getServletHandler().addServletMapping(m); diff --git a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java index 386c0258187..b2e13e269a4 100644 --- a/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java +++ b/jetty-quickstart/src/main/java/org/eclipse/jetty/quickstart/QuickStartDescriptorProcessor.java @@ -106,7 +106,7 @@ public class QuickStartDescriptorProcessor extends IterativeDescriptorProcessor { String origin = node.getAttribute(_originAttributeName); if (!StringUtil.isBlank(origin) && origin.startsWith(DefaultsDescriptor.class.getSimpleName())) - mapping.setDefault(true); + mapping.setFromDefaultDescriptor(true); } } diff --git a/jetty-quickstart/src/test/java/org/eclipse/jetty/quickstart/TestQuickStart.java b/jetty-quickstart/src/test/java/org/eclipse/jetty/quickstart/TestQuickStart.java index ba0541986d1..5ae648a5f82 100644 --- a/jetty-quickstart/src/test/java/org/eclipse/jetty/quickstart/TestQuickStart.java +++ b/jetty-quickstart/src/test/java/org/eclipse/jetty/quickstart/TestQuickStart.java @@ -100,7 +100,7 @@ public class TestQuickStart server.dumpStdErr(); //verify that FooServlet is now mapped to / and not the DefaultServlet - ServletHolder sh = webapp.getServletHandler().getMappedServlet("/").getResource(); + ServletHolder sh = webapp.getServletHandler().getMappedServlet("/").getServletHolder(); assertNotNull(sh); assertEquals("foo", sh.getName()); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java index ebbbc32ac91..4856a99fa5d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncAttributes.java @@ -21,30 +21,25 @@ package org.eclipse.jetty.server; import java.util.HashSet; import java.util.Set; import javax.servlet.AsyncContext; -import javax.servlet.http.HttpServletMapping; import org.eclipse.jetty.util.Attributes; class AsyncAttributes extends Attributes.Wrapper { - private String _requestURI; - private String _contextPath; - private String _servletPath; - private String _pathInfo; - private String _queryString; - private HttpServletMapping _httpServletMapping; + private final String _requestURI; + private final String _contextPath; + private final String _pathInContext; + private ServletPathMapping _mapping; + private final String _queryString; - public AsyncAttributes(Attributes attributes, String requestUri, String contextPath, String servletPath, String pathInfo, String queryString, HttpServletMapping httpServletMapping) + public AsyncAttributes(Attributes attributes, String requestUri, String contextPath, String pathInContext, ServletPathMapping mapping, String queryString) { super(attributes); - - // TODO: make fields final in jetty-10 and NOOP when one of these attributes is set. _requestURI = requestUri; _contextPath = contextPath; - _servletPath = servletPath; - _pathInfo = pathInfo; + _pathInContext = pathInContext; + _mapping = mapping; _queryString = queryString; - _httpServletMapping = httpServletMapping; } @Override @@ -57,13 +52,13 @@ class AsyncAttributes extends Attributes.Wrapper case AsyncContext.ASYNC_CONTEXT_PATH: return _contextPath; case AsyncContext.ASYNC_SERVLET_PATH: - return _servletPath; + return _mapping == null ? null : _mapping.getServletPath(); case AsyncContext.ASYNC_PATH_INFO: - return _pathInfo; + return _mapping == null ? _pathInContext : _mapping.getPathInfo(); case AsyncContext.ASYNC_QUERY_STRING: return _queryString; case AsyncContext.ASYNC_MAPPING: - return _httpServletMapping; + return _mapping; default: return super.getAttribute(key); } @@ -73,18 +68,12 @@ class AsyncAttributes extends Attributes.Wrapper public Set getAttributeNameSet() { Set set = new HashSet<>(super.getAttributeNameSet()); - if (_requestURI != null) - set.add(AsyncContext.ASYNC_REQUEST_URI); - if (_contextPath != null) - set.add(AsyncContext.ASYNC_CONTEXT_PATH); - if (_servletPath != null) - set.add(AsyncContext.ASYNC_SERVLET_PATH); - if (_pathInfo != null) - set.add(AsyncContext.ASYNC_PATH_INFO); - if (_queryString != null) - set.add(AsyncContext.ASYNC_QUERY_STRING); - if (_httpServletMapping != null) - set.add(AsyncContext.ASYNC_MAPPING); + set.add(AsyncContext.ASYNC_REQUEST_URI); + set.add(AsyncContext.ASYNC_CONTEXT_PATH); + set.add(AsyncContext.ASYNC_SERVLET_PATH); + set.add(AsyncContext.ASYNC_PATH_INFO); + set.add(AsyncContext.ASYNC_QUERY_STRING); + set.add(AsyncContext.ASYNC_MAPPING); return set; } @@ -94,54 +83,17 @@ class AsyncAttributes extends Attributes.Wrapper switch (key) { case AsyncContext.ASYNC_REQUEST_URI: - _requestURI = (String)value; - break; case AsyncContext.ASYNC_CONTEXT_PATH: - _contextPath = (String)value; - break; case AsyncContext.ASYNC_SERVLET_PATH: - _servletPath = (String)value; - break; case AsyncContext.ASYNC_PATH_INFO: - _pathInfo = (String)value; - break; case AsyncContext.ASYNC_QUERY_STRING: - _queryString = (String)value; - break; case AsyncContext.ASYNC_MAPPING: - _httpServletMapping = (HttpServletMapping)value; + // Ignore sets for these reserved names as this class is applied + // we will always override these particular attributes. break; default: super.setAttribute(key, value); break; } } - - @Override - public void clearAttributes() - { - _requestURI = null; - _contextPath = null; - _servletPath = null; - _pathInfo = null; - _queryString = null; - _httpServletMapping = null; - super.clearAttributes(); - } - - public static void applyAsyncAttributes(Attributes attributes, String requestURI, String contextPath, String servletPath, String pathInfo, String queryString, HttpServletMapping httpServletMapping) - { - if (requestURI != null) - attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, requestURI); - if (contextPath != null) - attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, contextPath); - if (servletPath != null) - attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, servletPath); - if (pathInfo != null) - attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, pathInfo); - if (queryString != null) - attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, queryString); - if (httpServletMapping != null) - attributes.setAttribute(AsyncContext.ASYNC_MAPPING, httpServletMapping); - } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java index 8f6ff444fd0..086ba3cb16a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java @@ -26,7 +26,6 @@ import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -101,14 +100,7 @@ public class Dispatcher implements RequestDispatcher } else { - IncludeAttributes attr = new IncludeAttributes(old_attr); - - attr._requestURI = _uri.getPath(); - attr._contextPath = _contextHandler.getContextPath(); - attr._servletPath = null; // set by ServletHandler - attr._pathInfo = _pathInContext; - attr._query = _uri.getQuery(); - attr._mapping = null; //set by ServletHandler + IncludeAttributes attr = new IncludeAttributes(old_attr, _uri.getPath(), _contextHandler.getContextPath(), _pathInContext, _uri.getQuery()); if (attr._query != null) baseRequest.mergeQueryParameters(baseRequest.getQueryString(), attr._query); baseRequest.setAttributes(attr); @@ -147,7 +139,7 @@ public class Dispatcher implements RequestDispatcher final String old_context_path = baseRequest.getContextPath(); final String old_servlet_path = baseRequest.getServletPath(); final String old_path_info = baseRequest.getPathInfo(); - final HttpServletMapping old_mapping = baseRequest.getHttpServletMapping(); + final ServletPathMapping old_mapping = baseRequest.getServletPathMapping(); final MultiMap old_query_params = baseRequest.getQueryParameters(); final Attributes old_attr = baseRequest.getAttributes(); @@ -163,30 +155,26 @@ public class Dispatcher implements RequestDispatcher } else { - ForwardAttributes attr = new ForwardAttributes(old_attr); - - //If we have already been forwarded previously, then keep using the established - //original value. Otherwise, this is the first forward and we need to establish the values. - //Note: the established value on the original request for pathInfo and - //for queryString is allowed to be null, but cannot be null for the other values. - if (old_attr.getAttribute(FORWARD_REQUEST_URI) != null) - { - attr._pathInfo = (String)old_attr.getAttribute(FORWARD_PATH_INFO); - attr._query = (String)old_attr.getAttribute(FORWARD_QUERY_STRING); - attr._requestURI = (String)old_attr.getAttribute(FORWARD_REQUEST_URI); - attr._contextPath = (String)old_attr.getAttribute(FORWARD_CONTEXT_PATH); - attr._servletPath = (String)old_attr.getAttribute(FORWARD_SERVLET_PATH); - attr._mapping = (HttpServletMapping)old_attr.getAttribute(FORWARD_MAPPING); - } - else - { - attr._pathInfo = old_path_info; - attr._query = old_uri.getQuery(); - attr._requestURI = old_uri.getPath(); - attr._contextPath = old_context_path; - attr._servletPath = old_servlet_path; - attr._mapping = old_mapping; - } + // If we have already been forwarded previously, then keep using the established + // original value. Otherwise, this is the first forward and we need to establish the values. + // Note: the established value on the original request for pathInfo and + // for queryString is allowed to be null, but cannot be null for the other values. + // Note: the pathInfo is passed as the pathInContext since it is only used when there is + // no mapping, and when there is no mapping the pathInfo is the pathInContext. + // TODO Ultimately it is intended for the request to carry the pathInContext for easy access + ForwardAttributes attr = old_attr.getAttribute(FORWARD_REQUEST_URI) != null + ? new ForwardAttributes(old_attr, + (String)old_attr.getAttribute(FORWARD_REQUEST_URI), + (String)old_attr.getAttribute(FORWARD_CONTEXT_PATH), + (String)old_attr.getAttribute(FORWARD_PATH_INFO), + (ServletPathMapping)old_attr.getAttribute(FORWARD_MAPPING), + (String)old_attr.getAttribute(FORWARD_QUERY_STRING)) + : new ForwardAttributes(old_attr, + old_uri.getPath(), + old_context_path, + baseRequest.getPathInfo(), // TODO replace with pathInContext + old_mapping, + old_uri.getQuery()); String query = _uri.getQuery(); if (query == null) @@ -194,6 +182,7 @@ public class Dispatcher implements RequestDispatcher baseRequest.setHttpURI(HttpURI.build(old_uri, _uri.getPath(), _uri.getParam(), query)); baseRequest.setContextPath(_contextHandler.getContextPath()); + baseRequest.setServletPathMapping(null); baseRequest.setServletPath(null); baseRequest.setPathInfo(_pathInContext); @@ -257,16 +246,20 @@ public class Dispatcher implements RequestDispatcher private class ForwardAttributes extends Attributes.Wrapper { - String _requestURI; - String _contextPath; - String _servletPath; - String _pathInfo; - String _query; - HttpServletMapping _mapping; + private final String _requestURI; + private final String _contextPath; + private final String _pathInContext; + private final ServletPathMapping _servletPathMapping; + private final String _query; - ForwardAttributes(Attributes attributes) + public ForwardAttributes(Attributes attributes, String requestURI, String contextPath, String pathInContext, ServletPathMapping mapping, String query) { super(attributes); + _requestURI = requestURI; + _contextPath = contextPath; + _pathInContext = pathInContext; + _servletPathMapping = mapping; + _query = query; } @Override @@ -277,22 +270,23 @@ public class Dispatcher implements RequestDispatcher switch (key) { case FORWARD_PATH_INFO: - return _pathInfo; + return _servletPathMapping == null ? _pathInContext : _servletPathMapping.getPathInfo(); case FORWARD_REQUEST_URI: return _requestURI; case FORWARD_SERVLET_PATH: - return _servletPath; + return _servletPathMapping == null ? null : _servletPathMapping.getServletPath(); case FORWARD_CONTEXT_PATH: return _contextPath; case FORWARD_QUERY_STRING: return _query; case FORWARD_MAPPING: - return _mapping; + return _servletPathMapping; default: break; } } + // If we are forwarded then we hide include attributes if (key.startsWith(__INCLUDE_PREFIX)) return null; @@ -312,18 +306,12 @@ public class Dispatcher implements RequestDispatcher if (_named == null) { - if (_pathInfo != null) - set.add(FORWARD_PATH_INFO); - else - set.remove(FORWARD_PATH_INFO); + set.add(FORWARD_PATH_INFO); set.add(FORWARD_REQUEST_URI); set.add(FORWARD_SERVLET_PATH); set.add(FORWARD_CONTEXT_PATH); set.add(FORWARD_MAPPING); - if (_query != null) - set.add(FORWARD_QUERY_STRING); - else - set.remove(FORWARD_QUERY_STRING); + set.add(FORWARD_QUERY_STRING); } return set; @@ -332,40 +320,11 @@ public class Dispatcher implements RequestDispatcher @Override public void setAttribute(String key, Object value) { - if (_named == null && key.startsWith("javax.servlet.")) - { - switch (key) - { - case FORWARD_PATH_INFO: - _pathInfo = (String)value; - break; - case FORWARD_REQUEST_URI: - _requestURI = (String)value; - break; - case FORWARD_SERVLET_PATH: - _servletPath = (String)value; - break; - case FORWARD_CONTEXT_PATH: - _contextPath = (String)value; - break; - case FORWARD_QUERY_STRING: - _query = (String)value; - break; - case FORWARD_MAPPING: - _mapping = (HttpServletMapping)value; - return; - default: - if (value == null) - _attributes.removeAttribute(key); - else - _attributes.setAttribute(key, value); - break; - } - } - else if (value == null) - _attributes.removeAttribute(key); - else - _attributes.setAttribute(key, value); + // Allow any attribute to be set, even if a reserved name. If a reserved + // name is set here, it will be hidden by this class during the forward, + // but revealed after the forward is complete just as if the reserved name + // attribute had be set by the application before the forward. + _attributes.setAttribute(key, value); } @Override @@ -389,16 +348,19 @@ public class Dispatcher implements RequestDispatcher private class IncludeAttributes extends Attributes.Wrapper { - String _requestURI; - String _contextPath; - String _servletPath; - String _pathInfo; - String _query; - HttpServletMapping _mapping; + private final String _requestURI; + private final String _contextPath; + private final String _pathInContext; + private ServletPathMapping _servletPathMapping; // Set later by ServletHandler + private final String _query; - IncludeAttributes(Attributes attributes) + public IncludeAttributes(Attributes attributes, String requestURI, String contextPath, String pathInContext, String query) { super(attributes); + _requestURI = requestURI; + _contextPath = contextPath; + _pathInContext = pathInContext; + _query = query; } @Override @@ -409,9 +371,9 @@ public class Dispatcher implements RequestDispatcher switch (key) { case INCLUDE_PATH_INFO: - return _pathInfo; + return _servletPathMapping == null ? _pathInContext : _servletPathMapping.getPathInfo(); case INCLUDE_SERVLET_PATH: - return _servletPath; + return _servletPathMapping == null ? null : _servletPathMapping.getServletPath(); case INCLUDE_CONTEXT_PATH: return _contextPath; case INCLUDE_QUERY_STRING: @@ -419,13 +381,11 @@ public class Dispatcher implements RequestDispatcher case INCLUDE_REQUEST_URI: return _requestURI; case INCLUDE_MAPPING: - return _mapping; + return _servletPathMapping; default: break; } } - else if (key.startsWith(__INCLUDE_PREFIX)) - return null; return _attributes.getAttribute(key); } @@ -442,18 +402,12 @@ public class Dispatcher implements RequestDispatcher if (_named == null) { - if (_pathInfo != null) - set.add(INCLUDE_PATH_INFO); - else - set.remove(INCLUDE_PATH_INFO); + set.add(INCLUDE_PATH_INFO); set.add(INCLUDE_REQUEST_URI); set.add(INCLUDE_SERVLET_PATH); set.add(INCLUDE_CONTEXT_PATH); set.add(INCLUDE_MAPPING); - if (_query != null) - set.add(INCLUDE_QUERY_STRING); - else - set.remove(INCLUDE_QUERY_STRING); + set.add(INCLUDE_QUERY_STRING); } return set; @@ -462,39 +416,11 @@ public class Dispatcher implements RequestDispatcher @Override public void setAttribute(String key, Object value) { - if (_named == null && key.startsWith("javax.servlet.")) - { - switch (key) - { - case INCLUDE_PATH_INFO: - _pathInfo = (String)value; - break; - case INCLUDE_REQUEST_URI: - _requestURI = (String)value; - break; - case INCLUDE_SERVLET_PATH: - _servletPath = (String)value; - break; - case INCLUDE_CONTEXT_PATH: - _contextPath = (String)value; - break; - case INCLUDE_QUERY_STRING: - _query = (String)value; - break; - case INCLUDE_MAPPING: - _mapping = (HttpServletMapping)value; - break; - default: - if (value == null) - _attributes.removeAttribute(key); - else - _attributes.setAttribute(key, value); - break; - } - } - else if (value == null) - _attributes.removeAttribute(key); + if (_servletPathMapping == null && _named == null && INCLUDE_MAPPING.equals(key)) + _servletPathMapping = (ServletPathMapping)value; else + // Allow any attribute to be set, even if a reserved name. If a reserved + // name is set here, it will be revealed after the include is complete. _attributes.setAttribute(key, value); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index e2790df11ca..8f39b9a7900 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -63,7 +63,6 @@ import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpUpgradeHandler; -import javax.servlet.http.MappingMatch; import javax.servlet.http.Part; import javax.servlet.http.PushBuilder; @@ -83,8 +82,6 @@ import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.MetaData; import org.eclipse.jetty.http.MimeTypes; -import org.eclipse.jetty.http.pathmap.PathSpec; -import org.eclipse.jetty.http.pathmap.ServletPathSpec; import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler.Context; @@ -193,85 +190,6 @@ public class Request implements HttpServletRequest return null; } - public static HttpServletMapping getServletMapping(PathSpec pathSpec, String servletPath, String servletName) - { - final MappingMatch match; - final String mapping; - if (pathSpec instanceof ServletPathSpec) - { - switch (pathSpec.getGroup()) - { - case ROOT: - match = MappingMatch.CONTEXT_ROOT; - mapping = ""; - break; - case DEFAULT: - match = MappingMatch.DEFAULT; - mapping = "/"; - break; - case EXACT: - match = MappingMatch.EXACT; - mapping = servletPath.startsWith("/") ? servletPath.substring(1) : servletPath; - break; - case SUFFIX_GLOB: - match = MappingMatch.EXTENSION; - int dot = servletPath.lastIndexOf('.'); - mapping = servletPath.substring(0, dot); - break; - case PREFIX_GLOB: - match = MappingMatch.PATH; - mapping = servletPath; - break; - default: - match = null; - mapping = servletPath; - break; - } - } - else - { - match = null; - mapping = servletPath; - } - - return new HttpServletMapping() - { - @Override - public String getMatchValue() - { - return (mapping == null ? "" : mapping); - } - - @Override - public String getPattern() - { - if (pathSpec != null) - return pathSpec.getDeclaration(); - return ""; - } - - @Override - public String getServletName() - { - return (servletName == null ? "" : servletName); - } - - @Override - public MappingMatch getMappingMatch() - { - return match; - } - - @Override - public String toString() - { - return "HttpServletMapping{matchValue=" + getMatchValue() + - ", pattern=" + getPattern() + ", servletName=" + getServletName() + - ", mappingMatch=" + getMappingMatch() + "}"; - } - }; - } - private final HttpChannel _channel; private final List _requestAttributeListeners = new ArrayList<>(); private final HttpInput _input; @@ -283,7 +201,7 @@ public class Request implements HttpServletRequest private String _contextPath; private String _servletPath; private String _pathInfo; - private PathSpec _pathSpec; + private ServletPathMapping _servletPathMapping; private boolean _secure; private String _asyncNotSupportedSource = null; private boolean _newContext; @@ -1841,7 +1759,6 @@ public class Request implements HttpServletRequest _queryParameters = null; _contentParameters = null; _parameters = null; - _pathSpec = null; _contentParamsExtracted = false; _inputState = INPUT_NONE; _multiParts = null; @@ -1925,50 +1842,67 @@ public class Request implements HttpServletRequest if (getAttribute(AsyncContext.ASYNC_REQUEST_URI) != null) return; - String requestURI; - String contextPath; - String servletPath; - String pathInfo; - String queryString; - HttpServletMapping httpServletMapping; - - // Have we been forwarded before? - requestURI = (String)getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); - if (requestURI != null) - { - contextPath = (String)getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); - servletPath = (String)getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); - pathInfo = (String)getAttribute(RequestDispatcher.FORWARD_PATH_INFO); - queryString = (String)getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); - httpServletMapping = (HttpServletMapping)getAttribute(RequestDispatcher.FORWARD_MAPPING); - } - else - { - requestURI = getRequestURI(); - contextPath = getContextPath(); - servletPath = getServletPath(); - pathInfo = getPathInfo(); - queryString = getQueryString(); - httpServletMapping = getHttpServletMapping(); - } - // Unwrap the _attributes to get the base attributes instance. Attributes baseAttributes; if (_attributes == null) - _attributes = baseAttributes = new ServletAttributes(); + baseAttributes = _attributes = new ServletAttributes(); else baseAttributes = Attributes.unwrap(_attributes); - if (baseAttributes instanceof ServletAttributes) + // We cannot use a apply AsyncAttribute via #setAttributes as that + // will wrap over any dispatch specific attribute wrappers (eg. + // Dispatcher#ForwardAttributes). Async attributes must persist + // after the current dispatch, so they must be set under any other + // wrappers. + + String fwdRequestURI = (String)getAttribute(RequestDispatcher.FORWARD_REQUEST_URI); + if (fwdRequestURI == null) { - // Set the AsyncAttributes on the ServletAttributes. - ServletAttributes servletAttributes = (ServletAttributes)baseAttributes; - servletAttributes.setAsyncAttributes(requestURI, contextPath, servletPath, pathInfo, queryString, httpServletMapping); + if (baseAttributes instanceof ServletAttributes) + { + // The baseAttributes map is our ServletAttributes, so we can set the async + // attributes there, under any other wrappers. + ((ServletAttributes)baseAttributes).setAsyncAttributes(getRequestURI(), + getContextPath(), + getPathInfo(), // TODO change to pathInContext when cheaply available + getServletPathMapping(), + getQueryString()); + } + else + { + // We cannot find our ServletAttributes instance, so just set directly and hope + // whatever non jetty wrappers that have been applied will do the right thing. + _attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, getRequestURI()); + _attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, getContextPath()); + _attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, getServletPath()); + _attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, getPathInfo()); + _attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, getQueryString()); + _attributes.setAttribute(AsyncContext.ASYNC_MAPPING, getHttpServletMapping()); + } } else { - // If ServletAttributes has been replaced just set them on the top level Attributes. - AsyncAttributes.applyAsyncAttributes(_attributes, requestURI, contextPath, servletPath, pathInfo, queryString, httpServletMapping); + if (baseAttributes instanceof ServletAttributes) + { + // The baseAttributes map is our ServletAttributes, so we can set the async + // attributes there, under any other wrappers. + ((ServletAttributes)baseAttributes).setAsyncAttributes(fwdRequestURI, + (String)getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH), + (String)getAttribute(RequestDispatcher.FORWARD_PATH_INFO), + (ServletPathMapping)getAttribute(RequestDispatcher.FORWARD_MAPPING), + (String)getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); + } + else + { + // We cannot find our ServletAttributes instance, so just set directly and hope + // whatever non jetty wrappers that have been applied will do the right thing. + _attributes.setAttribute(AsyncContext.ASYNC_REQUEST_URI, fwdRequestURI); + _attributes.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH, getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH)); + _attributes.setAttribute(AsyncContext.ASYNC_SERVLET_PATH, getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH)); + _attributes.setAttribute(AsyncContext.ASYNC_PATH_INFO, getAttribute(RequestDispatcher.FORWARD_PATH_INFO)); + _attributes.setAttribute(AsyncContext.ASYNC_QUERY_STRING, getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); + _attributes.setAttribute(AsyncContext.ASYNC_MAPPING, getAttribute(RequestDispatcher.FORWARD_MAPPING)); + } } } @@ -2411,19 +2345,34 @@ public class Request implements HttpServletRequest throw new ServletException("HttpServletRequest.upgrade() not supported in Jetty"); } - public void setPathSpec(PathSpec pathSpec) + /** + * Set the servletPathMapping, the servletPath and the pathInfo. + * TODO remove the side effect on servletPath and pathInfo by removing those fields. + * @param servletPathMapping The mapping used to return from {@link #getHttpServletMapping()} + */ + public void setServletPathMapping(ServletPathMapping servletPathMapping) { - _pathSpec = pathSpec; + _servletPathMapping = servletPathMapping; + if (servletPathMapping == null) + { + // TODO reset the servletPath and pathInfo, but currently cannot do that + // as we don't know the pathInContext. + } + else + { + _servletPath = servletPathMapping.getServletPath(); + _pathInfo = servletPathMapping.getPathInfo(); + } } - public PathSpec getPathSpec() + public ServletPathMapping getServletPathMapping() { - return _pathSpec; + return _servletPathMapping; } @Override public HttpServletMapping getHttpServletMapping() { - return Request.getServletMapping(_pathSpec, _servletPath, getServletName()); + return _servletPathMapping; } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java index d7126d189fa..cc25c125555 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletAttributes.java @@ -20,19 +20,24 @@ package org.eclipse.jetty.server; import java.util.Set; -import javax.servlet.http.HttpServletMapping; - import org.eclipse.jetty.util.Attributes; import org.eclipse.jetty.util.AttributesMap; +/** + * An implementation of Attributes that supports the standard async attributes. + * + * This implementation delegates to an internal {@link AttributesMap} instance, which + * can optionally be wrapped with a {@link AsyncAttributes} instance. This allows async + * attributes to be applied underneath any other attribute wrappers. + */ public class ServletAttributes implements Attributes { private final Attributes _attributes = new AttributesMap(); private AsyncAttributes _asyncAttributes; - public void setAsyncAttributes(String requestURI, String contextPath, String servletPath, String pathInfo, String queryString, HttpServletMapping httpServletMapping) + public void setAsyncAttributes(String requestURI, String contextPath, String pathInContext, ServletPathMapping servletPathMapping, String queryString) { - _asyncAttributes = new AsyncAttributes(_attributes, requestURI, contextPath, servletPath, pathInfo, queryString, httpServletMapping); + _asyncAttributes = new AsyncAttributes(_attributes, requestURI, contextPath, pathInContext, servletPathMapping, queryString); } private Attributes getAttributes() diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServletPathMapping.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletPathMapping.java new file mode 100644 index 00000000000..a1c5541088e --- /dev/null +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServletPathMapping.java @@ -0,0 +1,159 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0 +// +// This Source Code may also be made available under the following +// Secondary Licenses when the conditions for such availability set +// forth in the Eclipse Public License, v. 2.0 are satisfied: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.server; + +import javax.servlet.http.HttpServletMapping; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.MappingMatch; + +import org.eclipse.jetty.http.pathmap.PathSpec; +import org.eclipse.jetty.http.pathmap.ServletPathSpec; + +/** + * Implementation of HttpServletMapping. + * + * Represents the application of a {@link ServletPathSpec} to a specific path + * that resulted in a mapping to a {@link javax.servlet.Servlet}. + * As well as supporting the standard {@link HttpServletMapping} methods, this + * class also carries fields, which can be precomputed for the implementation + * of {@link HttpServletRequest#getServletPath()} and + * {@link HttpServletRequest#getPathInfo()} + */ +public class ServletPathMapping implements HttpServletMapping +{ + private final MappingMatch _mappingMatch; + private final String _matchValue; + private final String _pattern; + private final String _servletName; + private final String _servletPath; + private final String _pathInfo; + + public ServletPathMapping(PathSpec pathSpec, String servletName, String pathInContext) + { + _servletName = (servletName == null ? "" : servletName); + _pattern = pathSpec == null ? null : pathSpec.getDeclaration(); + + if (pathSpec instanceof ServletPathSpec && pathInContext != null) + { + switch (pathSpec.getGroup()) + { + case ROOT: + _mappingMatch = MappingMatch.CONTEXT_ROOT; + _matchValue = ""; + _servletPath = ""; + _pathInfo = "/"; + break; + + case DEFAULT: + _mappingMatch = MappingMatch.DEFAULT; + _matchValue = ""; + _servletPath = pathInContext; + _pathInfo = null; + break; + + case EXACT: + _mappingMatch = MappingMatch.EXACT; + _matchValue = _pattern.startsWith("/") ? _pattern.substring(1) : _pattern; + _servletPath = _pattern; + _pathInfo = null; + break; + + case PREFIX_GLOB: + _mappingMatch = MappingMatch.PATH; + _servletPath = pathSpec.getPrefix(); + // TODO avoid the substring on the known servletPath! + _matchValue = _servletPath.startsWith("/") ? _servletPath.substring(1) : _servletPath; + _pathInfo = pathSpec.getPathInfo(pathInContext); + break; + + case SUFFIX_GLOB: + _mappingMatch = MappingMatch.EXTENSION; + int dot = pathInContext.lastIndexOf('.'); + _matchValue = pathInContext.substring(pathInContext.startsWith("/") ? 1 : 0, dot); + _servletPath = pathInContext; + _pathInfo = null; + break; + + case MIDDLE_GLOB: + _mappingMatch = null; + _matchValue = ""; + _servletPath = pathInContext; + _pathInfo = null; + break; + + default: + throw new IllegalStateException(); + } + } + else + { + _mappingMatch = null; + _matchValue = ""; + _servletPath = pathInContext; + _pathInfo = null; + } + } + + @Override + public String getMatchValue() + { + return _matchValue; + } + + @Override + public String getPattern() + { + return _pattern; + } + + @Override + public String getServletName() + { + return _servletName; + } + + @Override + public MappingMatch getMappingMatch() + { + return _mappingMatch; + } + + public String getServletPath() + { + return _servletPath; + } + + public String getPathInfo() + { + return _pathInfo; + } + + @Override + public String toString() + { + return "ServletPathMapping{" + + "matchValue=" + _matchValue + + ", pattern=" + _pattern + + ", servletName=" + _servletName + + ", mappingMatch=" + _mappingMatch + + ", servletPath=" + _servletPath + + ", pathInfo=" + _pathInfo + + "}"; + } +} diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java index a23c4c8aef4..a38af17e0cb 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java @@ -47,6 +47,7 @@ import javax.servlet.http.HttpServletMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.servlet.http.MappingMatch; import javax.servlet.http.Part; import javax.servlet.http.PushBuilder; @@ -86,6 +87,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -1427,69 +1429,6 @@ public class RequestTest assertThat(response, containsString("Hello World")); } - @Test - public void testHttpServletMapping() throws Exception - { - String request = "GET / HTTP/1.1\n" + - "Host: whatever\n" + - "Connection: close\n" + - "\n"; - - _server.stop(); - PathMappingHandler handler = new PathMappingHandler(null, null, null); - _server.setHandler(handler); - _server.start(); - String response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=, pattern=, servletName=, mappingMatch=null}")); - _server.stop(); - - ServletPathSpec spec = new ServletPathSpec(""); - handler = new PathMappingHandler(spec, spec.getPathMatch("foo"), "Something"); - _server.setHandler(handler); - _server.start(); - response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=, pattern=, servletName=Something, mappingMatch=CONTEXT_ROOT}")); - _server.stop(); - - spec = new ServletPathSpec("/"); - handler = new PathMappingHandler(spec, "", "Default"); - _server.setHandler(handler); - _server.start(); - response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=/, pattern=/, servletName=Default, mappingMatch=DEFAULT}")); - _server.stop(); - - spec = new ServletPathSpec("/foo/*"); - handler = new PathMappingHandler(spec, spec.getPathMatch("/foo/bar"), "BarServlet"); - _server.setHandler(handler); - _server.start(); - response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=/foo, pattern=/foo/*, servletName=BarServlet, mappingMatch=PATH}")); - _server.stop(); - - spec = new ServletPathSpec("*.jsp"); - handler = new PathMappingHandler(spec, spec.getPathMatch("/foo/bar.jsp"), "JspServlet"); - _server.setHandler(handler); - _server.start(); - response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=/foo/bar, pattern=*.jsp, servletName=JspServlet, mappingMatch=EXTENSION}")); - _server.stop(); - - spec = new ServletPathSpec("/catalog"); - handler = new PathMappingHandler(spec, spec.getPathMatch("/catalog"), "CatalogServlet"); - _server.setHandler(handler); - _server.start(); - response = _connector.getResponse(request); - assertTrue(response.startsWith("HTTP/1.1 200 OK")); - assertThat("Response body content", response, containsString("HttpServletMapping{matchValue=catalog, pattern=/catalog, servletName=CatalogServlet, mappingMatch=EXACT}")); - _server.stop(); - } - @Test public void testCookies() throws Exception { @@ -1935,6 +1874,92 @@ public class RequestTest assertThat(builder.getHeader("Cookie"), not(containsString("bad"))); } + @Test + public void testServletPathMapping() throws Exception + { + ServletPathSpec spec; + String uri; + ServletPathMapping m; + + spec = null; + uri = null; + m = new ServletPathMapping(spec, null, uri); + assertThat(m.getMappingMatch(), nullValue()); + assertThat(m.getMatchValue(), is("")); + assertThat(m.getPattern(), nullValue()); + assertThat(m.getServletName(), is("")); + assertThat(m.getServletPath(), nullValue()); + assertThat(m.getPathInfo(), nullValue()); + + spec = new ServletPathSpec(""); + uri = "/"; + m = new ServletPathMapping(spec, "Something", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.CONTEXT_ROOT)); + assertThat(m.getMatchValue(), is("")); + assertThat(m.getPattern(), is("")); + assertThat(m.getServletName(), is("Something")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + spec = new ServletPathSpec("/"); + uri = "/some/path"; + m = new ServletPathMapping(spec, "Default", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.DEFAULT)); + assertThat(m.getMatchValue(), is("")); + assertThat(m.getPattern(), is("/")); + assertThat(m.getServletName(), is("Default")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + spec = new ServletPathSpec("/foo/*"); + uri = "/foo/bar"; + m = new ServletPathMapping(spec, "FooServlet", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.PATH)); + assertThat(m.getMatchValue(), is("foo")); + assertThat(m.getPattern(), is("/foo/*")); + assertThat(m.getServletName(), is("FooServlet")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + uri = "/foo/"; + m = new ServletPathMapping(spec, "FooServlet", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.PATH)); + assertThat(m.getMatchValue(), is("foo")); + assertThat(m.getPattern(), is("/foo/*")); + assertThat(m.getServletName(), is("FooServlet")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + uri = "/foo"; + m = new ServletPathMapping(spec, "FooServlet", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.PATH)); + assertThat(m.getMatchValue(), is("foo")); + assertThat(m.getPattern(), is("/foo/*")); + assertThat(m.getServletName(), is("FooServlet")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + spec = new ServletPathSpec("*.jsp"); + uri = "/foo/bar.jsp"; + m = new ServletPathMapping(spec, "JspServlet", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.EXTENSION)); + assertThat(m.getMatchValue(), is("foo/bar")); + assertThat(m.getPattern(), is("*.jsp")); + assertThat(m.getServletName(), is("JspServlet")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + + spec = new ServletPathSpec("/catalog"); + uri = "/catalog"; + m = new ServletPathMapping(spec, "CatalogServlet", uri); + assertThat(m.getMappingMatch(), is(MappingMatch.EXACT)); + assertThat(m.getMatchValue(), is("catalog")); + assertThat(m.getPattern(), is("/catalog")); + assertThat(m.getServletName(), is("CatalogServlet")); + assertThat(m.getServletPath(), is(spec.getPathMatch(uri))); + assertThat(m.getPathInfo(), is(spec.getPathInfo(uri))); + } + interface RequestTester { boolean check(HttpServletRequest request, HttpServletResponse response) throws IOException; @@ -2169,7 +2194,6 @@ public class RequestTest { ((Request)request).setHandled(true); baseRequest.setServletPath(_servletPath); - baseRequest.setPathSpec(_spec); if (_servletName != null) baseRequest.setUserIdentityScope(new TestUserIdentityScope(null, null, _servletName)); HttpServletMapping mapping = baseRequest.getHttpServletMapping(); diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java index 8db55db6ec0..57b9ae0d389 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java @@ -35,7 +35,6 @@ import org.eclipse.jetty.http.HttpContent; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.http.PreEncodedHttpField; -import org.eclipse.jetty.http.pathmap.MappedResource; import org.eclipse.jetty.server.CachedContentFactory; import org.eclipse.jetty.server.ResourceContentFactory; import org.eclipse.jetty.server.ResourceService; @@ -500,9 +499,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory, Welc if ((_welcomeServlets || _welcomeExactServlets) && welcomeServlet == null) { - MappedResource entry = _servletHandler.getMappedServlet(welcomeInContext); + ServletHandler.MappedServlet entry = _servletHandler.getMappedServlet(welcomeInContext); @SuppressWarnings("ReferenceEquality") - boolean isDefaultHolder = (entry.getResource() != _defaultHolder); + boolean isDefaultHolder = (entry.getServletHolder() != _defaultHolder); if (entry != null && isDefaultHolder && (_welcomeServlets || (_welcomeExactServlets && entry.getPathSpec().getDeclaration().equals(welcomeInContext)))) welcomeServlet = welcomeInContext; diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java index 75a77c9ed0a..17ae35dea14 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java @@ -31,7 +31,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.http.pathmap.MappedResource; import org.eclipse.jetty.server.Dispatcher; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; @@ -71,7 +70,7 @@ public class Invoker extends HttpServlet private ContextHandler _contextHandler; private ServletHandler _servletHandler; - private MappedResource _invokerEntry; + private ServletHandler.MappedServlet _invokerEntry; private Map _parameters; private boolean _nonContextServlets; private boolean _verbose; @@ -171,12 +170,12 @@ public class Invoker extends HttpServlet // Check for existing mapping (avoid threaded race). String path = URIUtil.addPaths(servletPath, servlet); - MappedResource entry = _servletHandler.getMappedServlet(path); + ServletHandler.MappedServlet entry = _servletHandler.getMappedServlet(path); if (entry != null && !entry.equals(_invokerEntry)) { // Use the holder - holder = (ServletHolder)entry.getResource(); + holder = (ServletHolder)entry.getServletHolder(); } else { diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java index 47570d37a4f..69c2340937f 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java @@ -26,7 +26,6 @@ import java.util.EnumSet; import java.util.EventListener; import java.util.HashMap; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.Queue; import java.util.Set; @@ -57,6 +56,7 @@ import org.eclipse.jetty.http.pathmap.ServletPathSpec; import org.eclipse.jetty.security.IdentityService; import org.eclipse.jetty.security.SecurityHandler; import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.ServletPathMapping; import org.eclipse.jetty.server.ServletRequestHttpWrapper; import org.eclipse.jetty.server.ServletResponseHttpWrapper; import org.eclipse.jetty.server.UserIdentity; @@ -92,8 +92,6 @@ public class ServletHandler extends ScopedHandler { private static final Logger LOG = LoggerFactory.getLogger(ServletHandler.class); - public static final String __DEFAULT_SERVLET = "default"; - private ServletContextHandler _contextHandler; private ServletContext _servletContext; private FilterHolder[] _filters = new FilterHolder[0]; @@ -113,8 +111,8 @@ public class ServletHandler extends ScopedHandler private List _filterPathMappings; private MultiMap _filterNameMappings; - private final Map _servletNameMap = new HashMap<>(); - private PathMappings _servletPathMap; + private final Map _servletNameMap = new HashMap<>(); + private PathMappings _servletPathMap; private ListenerHolder[] _listeners = new ListenerHolder[0]; private boolean _initialized = false; @@ -167,7 +165,7 @@ public class ServletHandler extends ScopedHandler LOG.debug("Adding Default404Servlet to {}", this); addServletWithMapping(Default404Servlet.class, "/"); updateMappings(); - getServletMapping("/").setDefault(true); + getServletMapping("/").setFromDefaultDescriptor(true); } if (isFilterChainsCached()) @@ -247,13 +245,7 @@ public class ServletHandler extends ScopedHandler //remove all of the mappings that were for non-embedded filters _filterNameMap.remove(filter.getName()); //remove any mappings associated with this filter - ListIterator fmitor = filterMappings.listIterator(); - while (fmitor.hasNext()) - { - FilterMapping fm = fmitor.next(); - if (fm.getFilterName().equals(filter.getName())) - fmitor.remove(); - } + filterMappings.removeIf(fm -> fm.getFilterName().equals(filter.getName())); } else filterHolders.add(filter); //only retain embedded @@ -261,10 +253,8 @@ public class ServletHandler extends ScopedHandler } //Retain only filters and mappings that were added using jetty api (ie Source.EMBEDDED) - FilterHolder[] fhs = (FilterHolder[])LazyList.toArray(filterHolders, FilterHolder.class); - _filters = fhs; - FilterMapping[] fms = (FilterMapping[])LazyList.toArray(filterMappings, FilterMapping.class); - _filterMappings = fms; + _filters = (FilterHolder[])LazyList.toArray(filterHolders, FilterHolder.class); + _filterMappings = (FilterMapping[])LazyList.toArray(filterMappings, FilterMapping.class); _matchAfterIndex = (_filterMappings == null || _filterMappings.length == 0 ? -1 : _filterMappings.length - 1); _matchBeforeIndex = -1; @@ -291,13 +281,7 @@ public class ServletHandler extends ScopedHandler //remove from servlet name map _servletNameMap.remove(servlet.getName()); //remove any mappings associated with this servlet - ListIterator smitor = servletMappings.listIterator(); - while (smitor.hasNext()) - { - ServletMapping sm = smitor.next(); - if (sm.getServletName().equals(servlet.getName())) - smitor.remove(); - } + servletMappings.removeIf(sm -> sm.getServletName().equals(servlet.getName())); } else servletHolders.add(servlet); //only retain embedded @@ -305,10 +289,8 @@ public class ServletHandler extends ScopedHandler } //Retain only Servlets and mappings added via jetty apis (ie Source.EMBEDDED) - ServletHolder[] shs = (ServletHolder[])LazyList.toArray(servletHolders, ServletHolder.class); - _servlets = shs; - ServletMapping[] sms = (ServletMapping[])LazyList.toArray(servletMappings, ServletMapping.class); - _servletMappings = sms; + _servlets = (ServletHolder[])LazyList.toArray(servletHolders, ServletHolder.class); + _servletMappings = (ServletMapping[])LazyList.toArray(servletMappings, ServletMapping.class); if (_contextHandler != null) _contextHandler.contextDestroyed(); @@ -332,8 +314,7 @@ public class ServletHandler extends ScopedHandler listenerHolders.add(listener); } } - ListenerHolder[] listeners = (ListenerHolder[])LazyList.toArray(listenerHolders, ListenerHolder.class); - _listeners = listeners; + _listeners = (ListenerHolder[])LazyList.toArray(listenerHolders, ListenerHolder.class); //will be regenerated on next start _filterPathMappings = null; @@ -425,50 +406,40 @@ public class ServletHandler extends ScopedHandler public ServletHolder getServlet(String name) { - return _servletNameMap.get(name); + MappedServlet mapped = _servletNameMap.get(name); + if (mapped != null) + return mapped.getServletHolder(); + return null; } @Override public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Get the base requests - final String old_servlet_path = baseRequest.getServletPath(); - final String old_path_info = baseRequest.getPathInfo(); - final PathSpec old_path_spec = baseRequest.getPathSpec(); + final ServletPathMapping old_servlet_path_mapping = baseRequest.getServletPathMapping(); DispatcherType type = baseRequest.getDispatcherType(); ServletHolder servletHolder = null; UserIdentity.Scope oldScope = null; - MappedResource mapping = getMappedServlet(target); - if (mapping != null) + MappedServlet mappedServlet = getMappedServlet(target); + if (mappedServlet != null) { - servletHolder = mapping.getResource(); - - if (mapping.getPathSpec() != null) + servletHolder = mappedServlet.getServletHolder(); + ServletPathMapping servletPathMapping = mappedServlet.getServletPathMapping(target); + if (servletPathMapping != null) { - PathSpec pathSpec = mapping.getPathSpec(); - String servletPath = pathSpec.getPathMatch(target); - String pathInfo = pathSpec.getPathInfo(target); - + // Setting the servletPathMapping also provides the servletPath and pathInfo if (DispatcherType.INCLUDE.equals(type)) - { - baseRequest.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, servletPath); - baseRequest.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, pathInfo); - baseRequest.setAttribute(RequestDispatcher.INCLUDE_MAPPING, Request.getServletMapping(pathSpec, servletPath, servletHolder.getName())); - } + baseRequest.setAttribute(RequestDispatcher.INCLUDE_MAPPING, servletPathMapping); else - { - baseRequest.setPathSpec(pathSpec); - baseRequest.setServletPath(servletPath); - baseRequest.setPathInfo(pathInfo); - } + baseRequest.setServletPathMapping(servletPathMapping); } } if (LOG.isDebugEnabled()) - LOG.debug("servlet {}|{}|{} -> {}", baseRequest.getContextPath(), baseRequest.getServletPath(), baseRequest.getPathInfo(), servletHolder); + LOG.debug("servlet {}|{}|{}|{} -> {}", baseRequest.getContextPath(), baseRequest.getServletPath(), baseRequest.getPathInfo(), baseRequest.getHttpServletMapping(), servletHolder); try { @@ -484,11 +455,7 @@ public class ServletHandler extends ScopedHandler baseRequest.setUserIdentityScope(oldScope); if (!(DispatcherType.INCLUDE.equals(type))) - { - baseRequest.setServletPath(old_servlet_path); - baseRequest.setPathInfo(old_path_info); - baseRequest.setPathSpec(old_path_spec); - } + baseRequest.setServletPathMapping(old_servlet_path_mapping); } } @@ -550,34 +517,33 @@ public class ServletHandler extends ScopedHandler } /** - * ServletHolder matching path. + * Get MappedServlet for target. * * @param target Path within _context or servlet name - * @return MappedResource to the ServletHolder. Named servlets have a null PathSpec + * @return MappedServlet matched by path or name. Named servlets have a null PathSpec */ - public MappedResource getMappedServlet(String target) + public MappedServlet getMappedServlet(String target) { if (target.startsWith("/")) { if (_servletPathMap == null) return null; - return _servletPathMap.getMatch(target); + + MappedResource match = _servletPathMap.getMatch(target); + if (match == null) + return null; + return match.getResource(); } - if (_servletNameMap == null) - return null; - ServletHolder holder = _servletNameMap.get(target); - if (holder == null) - return null; - return new MappedResource<>(null, holder); + return _servletNameMap.get(target); } - protected FilterChain getFilterChain(Request baseRequest, String pathInContext, ServletHolder servletHolder) + private FilterChain getFilterChain(Request baseRequest, String pathInContext, ServletHolder servletHolder) { String key = pathInContext == null ? servletHolder.getName() : pathInContext; int dispatch = FilterMapping.dispatch(baseRequest.getDispatcherType()); - if (_filterChainsCached && _chainCache != null) + if (_filterChainsCached) { FilterChain chain = _chainCache[dispatch].get(key); if (chain != null) @@ -624,8 +590,7 @@ public class ServletHandler extends ScopedHandler FilterChain chain = null; if (_filterChainsCached) { - if (!filters.isEmpty()) - chain = newCachedChain(filters, servletHolder); + chain = newCachedChain(filters, servletHolder); final Map cache = _chainCache[dispatch]; final Queue lru = _chainLRU[dispatch]; @@ -648,7 +613,7 @@ public class ServletHandler extends ScopedHandler cache.put(key, chain); lru.add(key); } - else if (!filters.isEmpty()) + else chain = new Chain(baseRequest, filters, servletHolder); return chain; @@ -1133,7 +1098,7 @@ public class ServletHandler extends ScopedHandler if (mappings == null || mappings.length == 0) { setFilterMappings(insertFilterMapping(mapping, 0, false)); - if (source != null && source == Source.JAVAX_API) + if (source == Source.JAVAX_API) _matchAfterIndex = 0; } else @@ -1141,7 +1106,7 @@ public class ServletHandler extends ScopedHandler //there are existing entries. If this is a programmatic filtermapping, it is added at the end of the list. //If this is a normal filtermapping, it is inserted after all the other filtermappings (matchBefores and normals), //but before the first matchAfter filtermapping. - if (source != null && Source.JAVAX_API == source) + if (Source.JAVAX_API == source) { setFilterMappings(insertFilterMapping(mapping, mappings.length - 1, false)); if (_matchAfterIndex < 0) @@ -1177,12 +1142,12 @@ public class ServletHandler extends ScopedHandler if (mappings == null || mappings.length == 0) { setFilterMappings(insertFilterMapping(mapping, 0, false)); - if (source != null && Source.JAVAX_API == source) + if (Source.JAVAX_API == source) _matchBeforeIndex = 0; } else { - if (source != null && Source.JAVAX_API == source) + if (Source.JAVAX_API == source) { //programmatically defined filter mappings are prepended to mapping list in the order //in which they were defined. In other words, insert this mapping at the tail of the @@ -1281,7 +1246,7 @@ public class ServletHandler extends ScopedHandler // update the maps for (ServletHolder servlet : _servlets) { - _servletNameMap.put(servlet.getName(), servlet); + _servletNameMap.put(servlet.getName(), new MappedServlet(null, servlet)); servlet.setServletHandler(this); } } @@ -1321,13 +1286,13 @@ public class ServletHandler extends ScopedHandler } // Map servlet paths to holders - if (_servletMappings == null || _servletNameMap == null) + if (_servletMappings == null) { _servletPathMap = null; } else { - PathMappings pm = new PathMappings<>(); + PathMappings pm = new PathMappings<>(); //create a map of paths to set of ServletMappings that define that mapping HashMap> sms = new HashMap<>(); @@ -1338,12 +1303,7 @@ public class ServletHandler extends ScopedHandler { for (String pathSpec : pathSpecs) { - List mappings = sms.get(pathSpec); - if (mappings == null) - { - mappings = new ArrayList<>(); - sms.put(pathSpec, mappings); - } + List mappings = sms.computeIfAbsent(pathSpec, k -> new ArrayList<>()); mappings.add(servletMapping); } } @@ -1360,7 +1320,7 @@ public class ServletHandler extends ScopedHandler for (ServletMapping mapping : mappings) { //Get servlet associated with the mapping and check it is enabled - ServletHolder servletHolder = _servletNameMap.get(mapping.getServletName()); + ServletHolder servletHolder = getServlet(mapping.getServletName()); if (servletHolder == null) throw new IllegalStateException("No such servlet: " + mapping.getServletName()); //if the servlet related to the mapping is not enabled, skip it from consideration @@ -1374,7 +1334,7 @@ public class ServletHandler extends ScopedHandler { //already have a candidate - only accept another one //if the candidate is a default, or we're allowing duplicate mappings - if (finalMapping.isDefault()) + if (finalMapping.isFromDefaultDescriptor()) finalMapping = mapping; else if (isAllowDuplicateMappings()) { @@ -1384,9 +1344,9 @@ public class ServletHandler extends ScopedHandler else { //existing candidate isn't a default, if the one we're looking at isn't a default either, then its an error - if (!mapping.isDefault()) + if (!mapping.isFromDefaultDescriptor()) { - ServletHolder finalMappedServlet = _servletNameMap.get(finalMapping.getServletName()); + ServletHolder finalMappedServlet = getServlet(finalMapping.getServletName()); throw new IllegalStateException("Multiple servlets map to path " + pathSpec + ": " + finalMappedServlet.getName() + "[mapped:" + finalMapping.getSource() + "]," + @@ -1403,22 +1363,21 @@ public class ServletHandler extends ScopedHandler pathSpec, finalMapping.getSource(), finalMapping.getServletName(), - _servletNameMap.get(finalMapping.getServletName()).getSource()); + getServlet(finalMapping.getServletName()).getSource()); - pm.put(new ServletPathSpec(pathSpec), _servletNameMap.get(finalMapping.getServletName())); + ServletPathSpec servletPathSpec = new ServletPathSpec(pathSpec); + MappedServlet mappedServlet = new MappedServlet(servletPathSpec, getServlet(finalMapping.getServletName())); + pm.put(servletPathSpec, mappedServlet); } _servletPathMap = pm; } // flush filter chain cache - if (_chainCache != null) + for (int i = _chainCache.length; i-- > 0; ) { - for (int i = _chainCache.length; i-- > 0; ) - { - if (_chainCache[i] != null) - _chainCache[i].clear(); - } + if (_chainCache[i] != null) + _chainCache[i].clear(); } if (LOG.isDebugEnabled()) @@ -1453,28 +1412,26 @@ public class ServletHandler extends ScopedHandler { if (_filters == null) return false; - boolean found = false; for (FilterHolder f : _filters) { if (f == holder) - found = true; + return true; } - return found; + return false; } protected synchronized boolean containsServletHolder(ServletHolder holder) { if (_servlets == null) return false; - boolean found = false; for (ServletHolder s : _servlets) { @SuppressWarnings("ReferenceEquality") boolean foundServletHolder = (s == holder); if (foundServletHolder) - found = true; + return true; } - return found; + return false; } /** @@ -1731,6 +1688,68 @@ public class ServletHandler extends ScopedHandler _contextHandler.destroyListener(listener); } + /** + * A mapping of a servlet by pathSpec or by name + */ + public static class MappedServlet + { + private final PathSpec _pathSpec; + private final ServletHolder _servletHolder; + private final ServletPathMapping _servletPathMapping; + + MappedServlet(PathSpec pathSpec, ServletHolder servletHolder) + { + _pathSpec = pathSpec; + _servletHolder = servletHolder; + + // Create the HttpServletMapping only once if possible. + if (pathSpec instanceof ServletPathSpec) + { + switch (pathSpec.getGroup()) + { + case EXACT: + case ROOT: + _servletPathMapping = new ServletPathMapping(_pathSpec, _servletHolder.getName(), _pathSpec.getPrefix()); + break; + default: + _servletPathMapping = null; + break; + } + } + else + { + _servletPathMapping = null; + } + } + + public PathSpec getPathSpec() + { + return _pathSpec; + } + + public ServletHolder getServletHolder() + { + return _servletHolder; + } + + public ServletPathMapping getServletPathMapping(String pathInContext) + { + if (_servletPathMapping != null) + return _servletPathMapping; + if (_pathSpec != null) + return new ServletPathMapping(_pathSpec, _servletHolder.getName(), pathInContext); + return null; + } + + @Override + public String toString() + { + return String.format("MappedServlet%x{%s->%s}", + hashCode(), _pathSpec == null ? null : _pathSpec.getDeclaration(), _servletHolder); + } + + } + @SuppressWarnings("serial") public static class Default404Servlet extends HttpServlet { diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index ad185ff6488..4e42bb6f014 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -918,7 +918,7 @@ public class ServletHolder extends Holder implements UserIdentity.Scope if (mapping != null) { //if the servlet mapping was from a default descriptor, then allow it to be overridden - if (!mapping.isDefault()) + if (!mapping.isFromDefaultDescriptor()) { if (clash == null) clash = new HashSet<>(); diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java index b4a9a2a68ae..8bd15c87492 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletMapping.java @@ -104,12 +104,12 @@ public class ServletMapping } @ManagedAttribute(value = "default", readonly = true) - public boolean isDefault() + public boolean isFromDefaultDescriptor() { return _default; } - public void setDefault(boolean fromDefault) + public void setFromDefaultDescriptor(boolean fromDefault) { _default = fromDefault; } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java index 48cf1380151..2c50289dfd8 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java @@ -257,7 +257,7 @@ public class AsyncContextTest assertThat("async run attr query string", responseBody, containsString("async:run:attr:queryString:dispatch=true")); assertThat("async run context path", responseBody, containsString("async:run:attr:contextPath:/ctx")); assertThat("async run request uri has correct encoding", responseBody, containsString("async:run:attr:requestURI:/ctx/test/hello%2fthere")); - assertThat("http servlet mapping matchValue is correct", responseBody, containsString("async:run:attr:mapping:matchValue:/test")); + assertThat("http servlet mapping matchValue is correct", responseBody, containsString("async:run:attr:mapping:matchValue:test")); assertThat("http servlet mapping pattern is correct", responseBody, containsString("async:run:attr:mapping:pattern:/test/*")); assertThat("http servlet mapping servletName is correct", responseBody, containsString("async:run:attr:mapping:servletName:")); assertThat("http servlet mapping mappingMatch is correct", responseBody, containsString("async:run:attr:mapping:mappingMatch:PATH")); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index 8c886a54149..a6dcb6e8a9f 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -170,6 +170,43 @@ public class DispatcherTest assertEquals(expected, responses); } + @Test + public void testNamedForward() throws Exception + { + _contextHandler.addServlet(NamedForwardServlet.class, "/forward/*"); + String echo = _contextHandler.addServlet(EchoURIServlet.class, "/echo/*").getName(); + + String expected = + "HTTP/1.1 200 OK\r\n" + + "Content-Type: text/plain\r\n" + + "Content-Length: 62\r\n" + + "\r\n" + + "/context\r\n" + + "/forward\r\n" + + "/info\r\n" + + "/context/forward/info;param=value\r\n"; + String responses = _connector.getResponse("GET /context/forward/info;param=value?name=" + echo + " HTTP/1.0\n\n"); + assertEquals(expected, responses); + } + + @Test + public void testNamedInclude() throws Exception + { + _contextHandler.addServlet(NamedIncludeServlet.class, "/include/*"); + String echo = _contextHandler.addServlet(EchoURIServlet.class, "/echo/*").getName(); + + String expected = + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 62\r\n" + + "\r\n" + + "/context\r\n" + + "/include\r\n" + + "/info\r\n" + + "/context/include/info;param=value\r\n"; + String responses = _connector.getResponse("GET /context/include/info;param=value?name=" + echo + " HTTP/1.0\n\n"); + assertEquals(expected, responses); + } + @Test public void testForwardWithBadParams() throws Exception { @@ -507,6 +544,24 @@ public class DispatcherTest } } + public static class NamedForwardServlet extends HttpServlet implements Servlet + { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + getServletContext().getNamedDispatcher(request.getParameter("name")).forward(request, response); + } + } + + public static class NamedIncludeServlet extends HttpServlet implements Servlet + { + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + getServletContext().getNamedDispatcher(request.getParameter("name")).include(request, response); + } + } + public static class ForwardNonUTF8Servlet extends HttpServlet implements Servlet { @Override @@ -734,7 +789,7 @@ public class DispatcherTest assertEquals("do=assertforward&do=more&test=1", request.getAttribute(Dispatcher.FORWARD_QUERY_STRING)); HttpServletMapping fwdMapping = (HttpServletMapping)request.getAttribute(Dispatcher.FORWARD_MAPPING); assertNotNull(fwdMapping); - assertEquals("/ForwardServlet", fwdMapping.getMatchValue()); + assertEquals("ForwardServlet", fwdMapping.getMatchValue()); List expectedAttributeNames = Arrays.asList(Dispatcher.FORWARD_REQUEST_URI, Dispatcher.FORWARD_CONTEXT_PATH, Dispatcher.FORWARD_SERVLET_PATH, Dispatcher.FORWARD_QUERY_STRING, Dispatcher.FORWARD_MAPPING); @@ -769,7 +824,7 @@ public class DispatcherTest assertEquals("do=assertforward&foreign=%d2%e5%ec%ef%e5%f0%e0%f2%f3%f0%e0&test=1", request.getAttribute(Dispatcher.FORWARD_QUERY_STRING)); HttpServletMapping fwdMapping = (HttpServletMapping)request.getAttribute(Dispatcher.FORWARD_MAPPING); assertNotNull(fwdMapping); - assertEquals("/ForwardServlet", fwdMapping.getMatchValue()); + assertEquals("ForwardServlet", fwdMapping.getMatchValue()); List expectedAttributeNames = Arrays.asList(Dispatcher.FORWARD_REQUEST_URI, Dispatcher.FORWARD_CONTEXT_PATH, Dispatcher.FORWARD_SERVLET_PATH, Dispatcher.FORWARD_QUERY_STRING, Dispatcher.FORWARD_MAPPING); @@ -818,7 +873,7 @@ public class DispatcherTest assertEquals("do=end&do=the", request.getAttribute(Dispatcher.INCLUDE_QUERY_STRING)); HttpServletMapping incMapping = (HttpServletMapping)request.getAttribute(Dispatcher.INCLUDE_MAPPING); assertNotNull(incMapping); - assertEquals("/AssertIncludeServlet", incMapping.getMatchValue()); + assertEquals("AssertIncludeServlet", incMapping.getMatchValue()); List expectedAttributeNames = Arrays.asList(Dispatcher.INCLUDE_REQUEST_URI, Dispatcher.INCLUDE_CONTEXT_PATH, Dispatcher.INCLUDE_SERVLET_PATH, Dispatcher.INCLUDE_QUERY_STRING, Dispatcher.INCLUDE_MAPPING); @@ -851,7 +906,7 @@ public class DispatcherTest assertEquals("do=include", request.getAttribute(Dispatcher.FORWARD_QUERY_STRING)); HttpServletMapping fwdMapping = (HttpServletMapping)request.getAttribute(Dispatcher.FORWARD_MAPPING); assertNotNull(fwdMapping); - assertEquals("/ForwardServlet", fwdMapping.getMatchValue()); + assertEquals("ForwardServlet", fwdMapping.getMatchValue()); assertEquals("/context/AssertForwardIncludeServlet/assertpath", request.getAttribute(Dispatcher.INCLUDE_REQUEST_URI)); assertEquals("/context", request.getAttribute(Dispatcher.INCLUDE_CONTEXT_PATH)); @@ -860,7 +915,7 @@ public class DispatcherTest assertEquals("do=end", request.getAttribute(Dispatcher.INCLUDE_QUERY_STRING)); HttpServletMapping incMapping = (HttpServletMapping)request.getAttribute(Dispatcher.INCLUDE_MAPPING); assertNotNull(incMapping); - assertEquals("/AssertForwardIncludeServlet", incMapping.getMatchValue()); + assertEquals("AssertForwardIncludeServlet", incMapping.getMatchValue()); List expectedAttributeNames = Arrays.asList(Dispatcher.FORWARD_REQUEST_URI, Dispatcher.FORWARD_CONTEXT_PATH, Dispatcher.FORWARD_SERVLET_PATH, Dispatcher.FORWARD_PATH_INFO, Dispatcher.FORWARD_QUERY_STRING, Dispatcher.FORWARD_MAPPING, @@ -902,7 +957,7 @@ public class DispatcherTest assertEquals("do=forward", request.getAttribute(Dispatcher.FORWARD_QUERY_STRING)); HttpServletMapping fwdMapping = (HttpServletMapping)request.getAttribute(Dispatcher.FORWARD_MAPPING); assertNotNull(fwdMapping); - assertEquals("/IncludeServlet", fwdMapping.getMatchValue()); + assertEquals("IncludeServlet", fwdMapping.getMatchValue()); List expectedAttributeNames = Arrays.asList(Dispatcher.FORWARD_REQUEST_URI, Dispatcher.FORWARD_CONTEXT_PATH, Dispatcher.FORWARD_SERVLET_PATH, Dispatcher.FORWARD_PATH_INFO, Dispatcher.FORWARD_QUERY_STRING, Dispatcher.FORWARD_MAPPING); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java index bef8ceef9a4..643fd6bc65c 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java @@ -62,7 +62,6 @@ import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionIdListener; import javax.servlet.http.HttpSessionListener; -import org.eclipse.jetty.http.pathmap.MappedResource; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.RoleInfo; @@ -1376,9 +1375,9 @@ public class ServletContextHandlerTest root.addBean(new MySCIStarter(root.getServletContext(), new JSPAddingSCI()), true); _server.start(); - MappedResource mappedServlet = root.getServletHandler().getMappedServlet("/somejsp/xxx"); - assertNotNull(mappedServlet.getResource()); - assertEquals("some.jsp", mappedServlet.getResource().getName()); + ServletHandler.MappedServlet mappedServlet = root.getServletHandler().getMappedServlet("/somejsp/xxx"); + assertNotNull(mappedServlet.getServletHolder()); + assertEquals("some.jsp", mappedServlet.getServletHolder().getName()); } @Test @@ -1452,9 +1451,9 @@ public class ServletContextHandlerTest root.addBean(new MySCIStarter(root.getServletContext(), new JSPAddingSCI()), true); _server.start(); - MappedResource mappedServlet = root.getServletHandler().getMappedServlet("/bar/xxx"); - assertNotNull(mappedServlet.getResource()); - assertEquals("some.jsp", mappedServlet.getResource().getName()); + ServletHandler.MappedServlet mappedServlet = root.getServletHandler().getMappedServlet("/bar/xxx"); + assertNotNull(mappedServlet.getServletHolder()); + assertEquals("some.jsp", mappedServlet.getServletHolder().getName()); } @Test diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletHandlerTest.java index fa5736a2619..25d635f66c6 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletHandlerTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletHandlerTest.java @@ -21,7 +21,6 @@ package org.eclipse.jetty.servlet; import java.util.EnumSet; import javax.servlet.DispatcherType; -import org.eclipse.jetty.http.pathmap.MappedResource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -79,17 +78,17 @@ public class ServletHandlerTest fm5.setFilterHolder(fh5); sh1.setName("s1"); - sm1.setDefault(false); + sm1.setFromDefaultDescriptor(false); sm1.setPathSpec("/foo/*"); sm1.setServletName("s1"); sh2.setName("s2"); - sm2.setDefault(false); + sm2.setFromDefaultDescriptor(false); sm2.setPathSpec("/foo/*"); sm2.setServletName("s2"); sh3.setName("s3"); - sm3.setDefault(true); + sm3.setFromDefaultDescriptor(true); sm3.setPathSpec("/foo/*"); sm3.setServletName("s3"); } @@ -251,9 +250,9 @@ public class ServletHandlerTest handler.updateMappings(); - MappedResource entry = handler.getMappedServlet("/foo/*"); + ServletHandler.MappedServlet entry = handler.getMappedServlet("/foo/*"); assertNotNull(entry); - assertEquals("s1", entry.getResource().getName()); + assertEquals("s1", entry.getServletHolder().getName()); } @Test @@ -292,9 +291,9 @@ public class ServletHandlerTest handler.addServletMapping(sm2); handler.updateMappings(); - MappedResource entry = handler.getMappedServlet("/foo/*"); + ServletHandler.MappedServlet entry = handler.getMappedServlet("/foo/*"); assertNotNull(entry); - assertEquals("s2", entry.getResource().getName()); + assertEquals("s2", entry.getServletHolder().getName()); } @Test diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index 44e4e411463..ca6942a810a 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -1200,7 +1200,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor { ServletMapping mapping = new ServletMapping(new Source(Source.Origin.DESCRIPTOR, descriptor.getResource().toString())); mapping.setServletName(servletName); - mapping.setDefault(descriptor instanceof DefaultsDescriptor); + mapping.setFromDefaultDescriptor(descriptor instanceof DefaultsDescriptor); List paths = new ArrayList(); Iterator iter = node.iterator("url-pattern"); @@ -1221,9 +1221,9 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor { //The same path has been mapped multiple times, either to a different servlet or the same servlet. //If its a different servlet, this is only valid to do if the old mapping was from a default descriptor. - if (p.equals(ps) && (sm.isDefault() || servletName.equals(sm.getServletName()))) + if (p.equals(ps) && (sm.isFromDefaultDescriptor() || servletName.equals(sm.getServletName()))) { - if (sm.isDefault()) + if (sm.isFromDefaultDescriptor()) { if (LOG.isDebugEnabled()) LOG.debug("{} in mapping {} from defaults descriptor is overridden by ", ps, sm, servletName); From e588a1bd9da8e4cc6131ad2fac672b8feeff750e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 20 May 2020 16:14:05 +0200 Subject: [PATCH 54/77] Fixes #4892 - Non-blocking JSON parser. Added parse(byte[], int, int). Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/util/ajax/AsyncJSON.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java index 9899258cfac..83087aa38db 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -203,10 +203,25 @@ public class AsyncJSON * * @param bytes the bytes to parse * @return whether the JSON parsing was complete + * @throws IllegalArgumentException if the JSON is malformed */ public boolean parse(byte[] bytes) { - return parse(ByteBuffer.wrap(bytes)); + return parse(bytes, 0, bytes.length); + } + + /** + *

    Feeds the parser with the given bytes chunk.

    + * + * @param bytes the bytes to parse + * @param offset the offset to start parsing from + * @param length the number of bytes to parse + * @return whether the JSON parsing was complete + * @throws IllegalArgumentException if the JSON is malformed + */ + public boolean parse(byte[] bytes, int offset, int length) + { + return parse(ByteBuffer.wrap(bytes, offset, length)); } /** From 52e7dd487344283cd44922c61b702b38c3237fa6 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 20 May 2020 23:05:53 +0200 Subject: [PATCH 55/77] Issue #4895 SessionCache flushOnResponseCommit with invalid session (#4896) Signed-off-by: Jan Bartel --- .../eclipse/jetty/server/session/AbstractSessionCache.java | 2 +- .../eclipse/jetty/server/session/RemoveSessionTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java index 2029098e3f5..d684ad13dce 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java @@ -479,7 +479,7 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements { //only write the session out at this point if the attributes changed. If only //the lastAccess/expiry time changed defer the write until the last request exits - if (session.getSessionData().isDirty() && _flushOnResponseCommit) + if (session.isValid() && session.getSessionData().isDirty() && _flushOnResponseCommit) { if (LOG.isDebugEnabled()) LOG.debug("Flush session {} on response commit", session); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java index 31b94bf4c83..670060c3832 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java @@ -54,6 +54,7 @@ public class RemoveSessionTest String servletMapping = "/server"; DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory(); + cacheFactory.setFlushOnResponseCommit(true); cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT); SessionDataStoreFactory storeFactory = new TestSessionDataStoreFactory(); @@ -93,6 +94,9 @@ public class RemoveSessionTest assertEquals(0, ((DefaultSessionCache)m.getSessionCache()).getSessionsCurrent()); assertEquals(1, ((DefaultSessionCache)m.getSessionCache()).getSessionsMax()); assertEquals(1, ((DefaultSessionCache)m.getSessionCache()).getSessionsTotal()); + + //check the session is no longer in the cache + assertFalse(((AbstractSessionCache)m.getSessionCache()).contains(TestServer.extractSessionId(sessionCookie))); //check the session is not persisted any more assertFalse(m.getSessionCache().getSessionDataStore().exists(TestServer.extractSessionId(sessionCookie))); @@ -125,7 +129,8 @@ public class RemoveSessionTest String action = request.getParameter("action"); if ("create".equals(action)) { - request.getSession(true); + HttpSession s = request.getSession(true); + s.setAttribute("foo", "bar"); } else if ("delete".equals(action)) { From d16ce1234998e5dc29057267b843cd6d57d37fd7 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 21 May 2020 00:35:31 +0200 Subject: [PATCH 56/77] Fixes #4892 - Non-blocking JSON parser. Updates after review. Signed-off-by: Simone Bordet --- .../eclipse/jetty/util/ajax/AsyncJSON.java | 40 +++++++++++++------ .../jetty/util/ajax/AsyncJSONTest.java | 40 +++++++++---------- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java index 83087aa38db..be701f3ca6a 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -47,9 +47,9 @@ import org.eclipse.jetty.util.ajax.JSON.Convertor; * * // Tell the parser that the JSON string content * // is terminated and get the JSON object back. - * Map<String, Object> object = parser.eof(); + * Map<String, Object> object = parser.complete(); * - *

    After the call to {@link #eof()} the parser can be reused to parse + *

    After the call to {@link #complete()} the parser can be reused to parse * another JSON string.

    *

    Custom objects can be created by specifying a {@code "class"} or * {@code "x-class"} field:

    @@ -64,7 +64,7 @@ import org.eclipse.jetty.util.ajax.JSON.Convertor; * """ * * parser.parse(json); - * com.acme.Person person = parser.eof(); + * com.acme.Person person = parser.complete(); * *

    Class {@code com.acme.Person} must either implement {@link Convertible}, * or be mapped with a {@link Convertor} via {@link Factory#putConvertor(String, Convertor)}.

    @@ -119,7 +119,7 @@ public class AsyncJSON * @param buffer the buffer to lookup the string from * @return a cached string or {@code null} */ - public String cached(ByteBuffer buffer) + private String cached(ByteBuffer buffer) { if (cache != null) { @@ -270,7 +270,7 @@ public class AsyncJSON { int position = buffer.position(); byte peek = buffer.get(position); - if (Character.isWhitespace((char)peek)) + if (isWhitespace(peek)) buffer.position(position + 1); else throw newInvalidJSON(buffer, "invalid character after JSON data"); @@ -374,7 +374,7 @@ public class AsyncJSON * @throws IllegalArgumentException if the JSON is malformed * @throws IllegalStateException if the no JSON was passed to the {@code parse()} methods */ - public R eof() + public R complete() { try { @@ -397,7 +397,7 @@ public class AsyncJSON { if (stack.peek().value == UNSET) throw new IllegalStateException("invalid state " + state); - return (R)complete(); + return (R)end(); } default: { @@ -439,7 +439,7 @@ public class AsyncJSON return new ArrayList<>(); } - private Object complete() + private Object end() { Object result = stack.peek().value; reset(); @@ -498,7 +498,7 @@ public class AsyncJSON return true; break; default: - if (Character.isWhitespace(peek)) + if (isWhitespace(peek)) { buffer.get(); break; @@ -854,7 +854,7 @@ public class AsyncJSON } default: { - if (Character.isWhitespace(peek)) + if (isWhitespace(peek)) { buffer.get(); break; @@ -904,7 +904,7 @@ public class AsyncJSON } default: { - if (Character.isWhitespace(currentByte)) + if (isWhitespace(currentByte)) { break; } @@ -947,7 +947,7 @@ public class AsyncJSON } default: { - if (Character.isWhitespace(peek)) + if (isWhitespace(peek)) { buffer.get(); break; @@ -1002,7 +1002,7 @@ public class AsyncJSON } default: { - if (Character.isWhitespace(peek)) + if (isWhitespace(peek)) { buffer.get(); break; @@ -1115,6 +1115,20 @@ public class AsyncJSON return new IllegalArgumentException(builder.toString()); } + private static boolean isWhitespace(byte ws) + { + switch (ws) + { + case ' ': + case '\n': + case '\r': + case '\t': + return true; + default: + return false; + } + } + /** *

    The state of JSON parsing.

    */ diff --git a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java index d808ea400c4..fa93463b1f5 100644 --- a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java +++ b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java @@ -78,7 +78,7 @@ public class AsyncJSONTest // Parse the whole input. assertTrue(parser.parse(bytes)); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); // Parse byte by byte. @@ -90,7 +90,7 @@ public class AsyncJSONTest else assertFalse(parser.parse(new byte[]{b})); } - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); } @@ -140,12 +140,12 @@ public class AsyncJSONTest // Parse the whole input. assertTrue(parser.parse(bytes)); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); ByteBuffer buffer = ByteBuffer.wrap(bytes); assertTrue(parser.parse(buffer)); assertFalse(buffer.hasRemaining()); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); // Parse byte by byte. @@ -153,7 +153,7 @@ public class AsyncJSONTest { parser.parse(new byte[]{b}); } - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); } @@ -195,7 +195,7 @@ public class AsyncJSONTest assertThrows(IllegalArgumentException.class, () -> { parser.parse(bytes); - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); @@ -206,7 +206,7 @@ public class AsyncJSONTest { parser.parse(new byte[]{b}); } - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); } @@ -220,7 +220,7 @@ public class AsyncJSONTest // Parse the whole input. assertTrue(parser.parse(bytes)); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); // Parse byte by byte. @@ -236,7 +236,7 @@ public class AsyncJSONTest assertFalse(parser.parse(new byte[]{b})); } } - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); } @@ -278,7 +278,7 @@ public class AsyncJSONTest assertThrows(IllegalArgumentException.class, () -> { parser.parse(bytes); - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); @@ -289,7 +289,7 @@ public class AsyncJSONTest { parser.parse(new byte[]{b}); } - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); } @@ -303,11 +303,11 @@ public class AsyncJSONTest // Parse the whole input. parser.parse(bytes); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); ByteBuffer buffer = ByteBuffer.wrap(bytes); parser.parse(buffer); - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertFalse(buffer.hasRemaining()); assertTrue(parser.isEmpty()); @@ -316,7 +316,7 @@ public class AsyncJSONTest { parser.parse(new byte[]{b}); } - assertEquals(expected, parser.eof()); + assertEquals(expected, parser.complete()); assertTrue(parser.isEmpty()); } @@ -349,7 +349,7 @@ public class AsyncJSONTest assertThrows(IllegalArgumentException.class, () -> { parser.parse(bytes); - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); @@ -360,7 +360,7 @@ public class AsyncJSONTest { parser.parse(new byte[]{b}); } - parser.eof(); + parser.complete(); }); assertTrue(parser.isEmpty()); } @@ -379,7 +379,7 @@ public class AsyncJSONTest AsyncJSON parser = factory.newAsyncJSON(); assertTrue(parser.parse(UTF_8.encode(json))); - Map result = parser.eof(); + Map result = parser.complete(); Object value1 = result.get("f1"); assertTrue(value1 instanceof CustomConvertible); @@ -389,7 +389,7 @@ public class AsyncJSONTest assertSame(convertor, factory.removeConvertor(CustomConvertor.class.getName())); assertTrue(parser.parse(UTF_8.encode(json))); - result = parser.eof(); + result = parser.complete(); value1 = result.get("f1"); assertTrue(value1 instanceof CustomConvertible); @@ -467,7 +467,7 @@ public class AsyncJSONTest "}]"; assertTrue(parser.parse(UTF_8.encode(json))); - List messages = parser.eof(); + List messages = parser.complete(); for (CustomMap message : messages) { @@ -491,7 +491,7 @@ public class AsyncJSONTest String json = "{\"foo\": [\"foo\", \"foo\"]}"; parser.parse(UTF_8.encode(json)); - Map object = parser.eof(); + Map object = parser.complete(); Map.Entry entry = object.entrySet().iterator().next(); assertSame(foo, entry.getKey()); From b9466823c8b7dc9e4a01b78ee8eec900b24f201b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 21 May 2020 11:44:30 +0200 Subject: [PATCH 57/77] Issue #4892 Async JSON Handle encoded cached strings (or not). Signed-off-by: Greg Wilkins --- .../eclipse/jetty/util/ajax/AsyncJSON.java | 45 ++++++++++++++++--- .../jetty/util/ajax/AsyncJSONTest.java | 23 ++++++++++ .../eclipse/jetty/util/ArrayTernaryTrie.java | 2 +- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java index be701f3ca6a..444fc25b223 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/AsyncJSON.java @@ -79,7 +79,7 @@ public class AsyncJSON */ public static class Factory { - private Trie cache; + private Trie cache; private Map convertors; private boolean detailedParseException; @@ -101,12 +101,20 @@ public class AsyncJSON /** * @param value the string to cache + * @return whether the value can be cached */ - public void cache(String value) + public boolean cache(String value) { if (cache == null) cache = new ArrayTernaryTrie.Growing<>(false, 64, 64); - cache.put("\"" + value + "\"", value); + + CachedString cached = new CachedString(value); + if (cached.isCacheable()) + { + cache.put(cached.encoded, cached); + return true; + } + return false; } /** @@ -119,15 +127,15 @@ public class AsyncJSON * @param buffer the buffer to lookup the string from * @return a cached string or {@code null} */ - private String cached(ByteBuffer buffer) + protected String cached(ByteBuffer buffer) { if (cache != null) { - String result = cache.getBest(buffer, 0, buffer.remaining()); + CachedString result = cache.getBest(buffer, 0, buffer.remaining()); if (result != null) { - buffer.position(buffer.position() + result.length() + 2); - return result; + buffer.position(buffer.position() + result.encoded.length()); + return result.value; } } return null; @@ -177,6 +185,29 @@ public class AsyncJSON { return convertors == null ? null : convertors.get(className); } + + private static class CachedString + { + private final String encoded; + private final String value; + + private CachedString(String value) + { + this.encoded = JSON.toString(value); + this.value = value; + } + + private boolean isCacheable() + { + for (int i = encoded.length(); i-- > 0;) + { + char c = encoded.charAt(i); + if (c > 127) + return false; + } + return true; + } + } } private static final Object UNSET = new Object(); diff --git a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java index fa93463b1f5..af66f6aae98 100644 --- a/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java +++ b/jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java @@ -502,4 +502,27 @@ public class AsyncJSONTest assertSame(foo, item); } } + + @Test + public void testEncodedCaching() + { + AsyncJSON.Factory factory = new AsyncJSON.Factory(); + assertFalse(factory.cache("yèck")); + String foo = "foo\\yuck"; + assertTrue(factory.cache(foo)); + AsyncJSON parser = factory.newAsyncJSON(); + + String json = "{\"foo\\\\yuck\": [\"foo\\\\yuck\", \"foo\\\\yuck\"]}"; + parser.parse(UTF_8.encode(json)); + Map object = parser.complete(); + + Map.Entry entry = object.entrySet().iterator().next(); + assertSame(foo, entry.getKey()); + @SuppressWarnings("unchecked") + List array = (List)entry.getValue(); + for (String item : array) + { + assertSame(foo, item); + } + } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java index fa63c727ae9..a1eecc1846c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java @@ -632,7 +632,7 @@ public class ArrayTernaryTrie extends AbstractTrie boolean added = _trie.put(s, v); while (!added && _growby > 0) { - ArrayTernaryTrie bigger = new ArrayTernaryTrie<>(_trie._key.length + _growby); + ArrayTernaryTrie bigger = new ArrayTernaryTrie<>(_trie.isCaseInsensitive(), _trie._key.length + _growby); for (Map.Entry entry : _trie.entrySet()) { bigger.put(entry.getKey(), entry.getValue()); From 77c232aed8a45c818fd27232278d9f95a021095e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 21 May 2020 12:04:14 -0500 Subject: [PATCH 58/77] Updating to version 9.4.29.v20200521 --- VERSION.txt | 28 +++- aggregates/jetty-all-compact3/pom.xml | 2 +- aggregates/jetty-all/pom.xml | 2 +- apache-jsp/pom.xml | 2 +- apache-jstl/pom.xml | 2 +- build-resources/pom.xml | 2 +- examples/async-rest/async-rest-jar/pom.xml | 2 +- examples/async-rest/async-rest-webapp/pom.xml | 2 +- examples/async-rest/pom.xml | 2 +- examples/embedded/pom.xml | 2 +- examples/pom.xml | 2 +- jetty-alpn/jetty-alpn-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-java-client/pom.xml | 2 +- jetty-alpn/jetty-alpn-java-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-openjdk8-client/pom.xml | 2 +- jetty-alpn/jetty-alpn-openjdk8-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-server/pom.xml | 2 +- jetty-alpn/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-ant/pom.xml | 2 +- jetty-bom/pom.xml | 134 +++++++++--------- jetty-cdi/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-documentation/pom.xml | 2 +- jetty-fcgi/fcgi-client/pom.xml | 2 +- jetty-fcgi/fcgi-server/pom.xml | 2 +- jetty-fcgi/pom.xml | 2 +- .../jetty-gcloud-session-manager/pom.xml | 2 +- jetty-gcloud/pom.xml | 2 +- jetty-hazelcast/pom.xml | 2 +- jetty-home/pom.xml | 2 +- jetty-http-spi/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-http2/http2-alpn-tests/pom.xml | 2 +- jetty-http2/http2-client/pom.xml | 2 +- jetty-http2/http2-common/pom.xml | 2 +- jetty-http2/http2-hpack/pom.xml | 2 +- .../http2-http-client-transport/pom.xml | 2 +- jetty-http2/http2-server/pom.xml | 2 +- jetty-http2/pom.xml | 2 +- jetty-infinispan/infinispan-common/pom.xml | 2 +- .../infinispan-embedded-query/pom.xml | 2 +- jetty-infinispan/infinispan-embedded/pom.xml | 2 +- .../infinispan-remote-query/pom.xml | 2 +- jetty-infinispan/infinispan-remote/pom.xml | 2 +- jetty-infinispan/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaas/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmh/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jspc-maven-plugin/pom.xml | 2 +- jetty-maven-plugin/pom.xml | 2 +- .../jetty-memcached-sessions/pom.xml | 2 +- jetty-memcached/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-openid/pom.xml | 2 +- jetty-osgi/jetty-osgi-alpn/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-context/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-fragment/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-server/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-webapp/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-proxy/pom.xml | 2 +- jetty-quickstart/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-runner/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-spring/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-unixsocket/pom.xml | 2 +- jetty-util-ajax/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- .../javax-websocket-client-impl/pom.xml | 2 +- .../javax-websocket-server-impl/pom.xml | 2 +- jetty-websocket/jetty-websocket-tests/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-websocket/websocket-api/pom.xml | 2 +- jetty-websocket/websocket-client/pom.xml | 2 +- jetty-websocket/websocket-common/pom.xml | 2 +- jetty-websocket/websocket-server/pom.xml | 2 +- jetty-websocket/websocket-servlet/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-continuation/pom.xml | 2 +- tests/test-distribution/pom.xml | 2 +- tests/test-http-client-transport/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-jmx/jmx-webapp-it/pom.xml | 2 +- tests/test-jmx/jmx-webapp/pom.xml | 2 +- tests/test-jmx/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-quickstart/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- .../test-sessions/test-file-sessions/pom.xml | 2 +- .../test-gcloud-sessions/pom.xml | 2 +- .../test-hazelcast-sessions/pom.xml | 2 +- .../test-infinispan-sessions/pom.xml | 2 +- .../test-sessions/test-jdbc-sessions/pom.xml | 2 +- .../test-memcached-sessions/pom.xml | 2 +- .../test-mongodb-sessions/pom.xml | 2 +- .../test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- .../test-cdi-common-webapp/pom.xml | 2 +- tests/test-webapps/test-felix-webapp/pom.xml | 2 +- tests/test-webapps/test-http2-webapp/pom.xml | 2 +- tests/test-webapps/test-jaas-webapp/pom.xml | 2 +- tests/test-webapps/test-jetty-webapp/pom.xml | 2 +- tests/test-webapps/test-jndi-webapp/pom.xml | 2 +- .../test-webapps/test-mock-resources/pom.xml | 2 +- .../test-webapps/test-owb-cdi-webapp/pom.xml | 2 +- tests/test-webapps/test-proxy-webapp/pom.xml | 2 +- tests/test-webapps/test-servlet-spec/pom.xml | 2 +- .../test-container-initializer/pom.xml | 2 +- .../test-spec-webapp/pom.xml | 2 +- .../test-web-fragment/pom.xml | 2 +- tests/test-webapps/test-simple-webapp/pom.xml | 2 +- .../test-webapps/test-webapp-rfc2616/pom.xml | 2 +- .../test-webapps/test-weld-cdi-webapp/pom.xml | 2 +- 136 files changed, 227 insertions(+), 203 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index c5f5ce782ea..009f6013f1a 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,28 @@ -jetty-9.4.29-SNAPSHOT +jetty-9.4.29.v20200521 - 21 May 2020 + + 2188 Lock contention creating HTTP/2 streams + + 4235 communicate the reason of failure to the OpenID error page + + 4695 HttpChannel recycling in h2 + + 4764 HTTP2 Jetty Server does not send back content-length + + 4778 Enforcing SNI when there are only non-wildcards certificates + + 4787 Make org.eclipse.jetty.client.HttpRequest's host name writable + + 4789 org.eclipse.jetty.util.thread.ShutdownThread should use an appropriate + name to identify itself in Thread dump + + 4798 Better handling of fatal Selector failures + + 4814 Allow a ConnectionFactory (eg SslConnectionFactory) to automatically + add a Customizer + + 4820 Jetty OSGi DefaultJettyAtJettyHomeHelper refers to non-existent + config file + + 4824 WebSocket server outgoing message queue memory growth + + 4828 NIO ByteBuffer corruption in embedded Jetty server + + 4835 GzipHandler and GzipHttpOutputInterceptor do not flush response when + body is empty + + 4860 org.eclipse.jetty.server.HttpChannel busyloop on HttpFields + NullPointerException + + 4861 Combine `AttributesMap` and `Attributes.Wrapper` + + 4868 Update to asm 7.3.1 + + 4892 Non-blocking JSON parser + + 4895 AbstractSessionCache.setFlushOnResponseCommit(true) can write an + invalid session to the backing store jetty-9.4.28.v20200408 - 08 April 2020 + 847 Setting async timeout on WebSocketClient does not seem to timeout writes @@ -8,7 +32,7 @@ jetty-9.4.28.v20200408 - 08 April 2020 + 4529 ErrorHandler showing servlet info, can not be disabled unless overriding most of its functionality + 4542 servlet context root mapping incorrect - + 4619 Inconsistent library versions notice. + + 4619 Inconsistent library versions notice + 4620 Using console-capture with StdErrLog results in empty log file + 4621 jetty-jaspi in jetty-all uber aggregate artifact requires javax.security.auth.message.AuthException which cannot be included diff --git a/aggregates/jetty-all-compact3/pom.xml b/aggregates/jetty-all-compact3/pom.xml index 9aa8de61f7d..5a27d149698 100644 --- a/aggregates/jetty-all-compact3/pom.xml +++ b/aggregates/jetty-all-compact3/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../../pom.xml 4.0.0 diff --git a/aggregates/jetty-all/pom.xml b/aggregates/jetty-all/pom.xml index c7ba43155b5..1524b48dfc3 100644 --- a/aggregates/jetty-all/pom.xml +++ b/aggregates/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../../pom.xml 4.0.0 diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml index d65d9fbcbcc..2d75087709a 100644 --- a/apache-jsp/pom.xml +++ b/apache-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 apache-jsp diff --git a/apache-jstl/pom.xml b/apache-jstl/pom.xml index 7ddb0b852a2..295b9f53d9c 100644 --- a/apache-jstl/pom.xml +++ b/apache-jstl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 apache-jstl diff --git a/build-resources/pom.xml b/build-resources/pom.xml index 2c9845d2625..46b88407b79 100644 --- a/build-resources/pom.xml +++ b/build-resources/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.eclipse.jetty build-resources - 9.4.29-SNAPSHOT + 9.4.29.v20200521 jar Jetty :: Build Resources diff --git a/examples/async-rest/async-rest-jar/pom.xml b/examples/async-rest/async-rest-jar/pom.xml index 85d69939487..288785f42d5 100644 --- a/examples/async-rest/async-rest-jar/pom.xml +++ b/examples/async-rest/async-rest-jar/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty example-async-rest - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/examples/async-rest/async-rest-webapp/pom.xml b/examples/async-rest/async-rest-webapp/pom.xml index 19486ffe653..040aaec8303 100644 --- a/examples/async-rest/async-rest-webapp/pom.xml +++ b/examples/async-rest/async-rest-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty example-async-rest - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/examples/async-rest/pom.xml b/examples/async-rest/pom.xml index 799db801363..f40892d591d 100644 --- a/examples/async-rest/pom.xml +++ b/examples/async-rest/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.examples examples-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index ef0b4eba461..17734a264f4 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.examples examples-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/examples/pom.xml b/examples/pom.xml index 284ef573fee..8d3fc417bc6 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-client/pom.xml b/jetty-alpn/jetty-alpn-client/pom.xml index 8886bd3d421..bccf8a700db 100644 --- a/jetty-alpn/jetty-alpn-client/pom.xml +++ b/jetty-alpn/jetty-alpn-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-alpn-client diff --git a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml index a6f273200ae..daef0477762 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml index 585cfcec66d..2f395f4d1ed 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-java-client/pom.xml b/jetty-alpn/jetty-alpn-java-client/pom.xml index 17a626e7e11..c790d1ff1ae 100644 --- a/jetty-alpn/jetty-alpn-java-client/pom.xml +++ b/jetty-alpn/jetty-alpn-java-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-java-server/pom.xml b/jetty-alpn/jetty-alpn-java-server/pom.xml index af2f2fbe46e..341d8b1a99a 100644 --- a/jetty-alpn/jetty-alpn-java-server/pom.xml +++ b/jetty-alpn/jetty-alpn-java-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml b/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml index e7b25f6c49f..423ff07e2ab 100644 --- a/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml +++ b/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml b/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml index 4a646c4078a..59e1fdfc687 100644 --- a/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml +++ b/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-alpn/jetty-alpn-server/pom.xml b/jetty-alpn/jetty-alpn-server/pom.xml index 9d79ac35845..268321da26b 100644 --- a/jetty-alpn/jetty-alpn-server/pom.xml +++ b/jetty-alpn/jetty-alpn-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-alpn-server diff --git a/jetty-alpn/pom.xml b/jetty-alpn/pom.xml index 5744bbbbf71..dd35154f804 100644 --- a/jetty-alpn/pom.xml +++ b/jetty-alpn/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-alpn-parent diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index fe43d65faeb..6f0b05fad28 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-annotations diff --git a/jetty-ant/pom.xml b/jetty-ant/pom.xml index 5bb1b54ea29..f6cb9787b3f 100644 --- a/jetty-ant/pom.xml +++ b/jetty-ant/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-ant diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index 25fb9d37eb3..24841e21d35 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -9,7 +9,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 @@ -53,336 +53,336 @@ org.eclipse.jetty apache-jsp - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty apache-jstl - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-java-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-java-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-openjdk8-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-openjdk8-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-conscrypt-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-conscrypt-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-alpn-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-annotations - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-ant - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-continuation - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-deploy - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-distribution - 9.4.29-SNAPSHOT + 9.4.29.v20200521 zip org.eclipse.jetty jetty-distribution - 9.4.29-SNAPSHOT + 9.4.29.v20200521 tar.gz org.eclipse.jetty.fcgi fcgi-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.fcgi fcgi-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.gcloud jetty-gcloud-session-manager - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-home - 9.4.29-SNAPSHOT + 9.4.29.v20200521 zip org.eclipse.jetty jetty-home - 9.4.29-SNAPSHOT + 9.4.29.v20200521 tar.gz org.eclipse.jetty jetty-http - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.http2 http2-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.http2 http2-common - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.http2 http2-hpack - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.http2 http2-http-client-transport - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.http2 http2-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-http-spi - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty infinispan-common - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty infinispan-remote-query - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty infinispan-embedded-query - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-hazelcast - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-io - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-jaas - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-jaspi - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-jmx - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-jndi - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.memcached jetty-memcached-sessions - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-nosql - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.osgi jetty-osgi-boot - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.osgi jetty-osgi-boot-jsp - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.osgi jetty-osgi-boot-warurl - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.osgi jetty-httpservice - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-plus - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-proxy - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-quickstart - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-rewrite - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-security - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-openid - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-servlet - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-servlets - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-spring - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-unixsocket - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-util - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-util-ajax - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-webapp - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket javax-websocket-client-impl - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket javax-websocket-server-impl - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket websocket-api - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket websocket-client - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket websocket-common - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket websocket-server - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty.websocket websocket-servlet - 9.4.29-SNAPSHOT + 9.4.29.v20200521 org.eclipse.jetty jetty-xml - 9.4.29-SNAPSHOT + 9.4.29.v20200521 diff --git a/jetty-cdi/pom.xml b/jetty-cdi/pom.xml index 192eeba6002..be078af41ce 100644 --- a/jetty-cdi/pom.xml +++ b/jetty-cdi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 org.eclipse.jetty diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 76409b9bfa7..801de2fc76e 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index 0c1e7a6540d..9a4b6cc34ae 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index aac2955999a..b70712b0529 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 1e60b7b3190..82f2400494d 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-distribution diff --git a/jetty-documentation/pom.xml b/jetty-documentation/pom.xml index 62da69a54b1..48c07479ec4 100644 --- a/jetty-documentation/pom.xml +++ b/jetty-documentation/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 jetty-documentation Jetty :: Documentation diff --git a/jetty-fcgi/fcgi-client/pom.xml b/jetty-fcgi/fcgi-client/pom.xml index 8519df4d6f2..a0ccde50b09 100644 --- a/jetty-fcgi/fcgi-client/pom.xml +++ b/jetty-fcgi/fcgi-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.fcgi fcgi-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-fcgi/fcgi-server/pom.xml b/jetty-fcgi/fcgi-server/pom.xml index 72775eaae08..82e1cd52e70 100644 --- a/jetty-fcgi/fcgi-server/pom.xml +++ b/jetty-fcgi/fcgi-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.fcgi fcgi-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-fcgi/pom.xml b/jetty-fcgi/pom.xml index 93483624a72..3aa17095190 100644 --- a/jetty-fcgi/pom.xml +++ b/jetty-fcgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index 07bc061d319..32ff10ac7da 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.gcloud gcloud-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-gcloud/pom.xml b/jetty-gcloud/pom.xml index db7045d9a4a..f3132c971e9 100644 --- a/jetty-gcloud/pom.xml +++ b/jetty-gcloud/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-hazelcast/pom.xml b/jetty-hazelcast/pom.xml index 33fc3863baa..d00416504c7 100644 --- a/jetty-hazelcast/pom.xml +++ b/jetty-hazelcast/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-home/pom.xml b/jetty-home/pom.xml index e97c7dbf02f..520e3f1e95f 100644 --- a/jetty-home/pom.xml +++ b/jetty-home/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-home diff --git a/jetty-http-spi/pom.xml b/jetty-http-spi/pom.xml index bc4f4b040bd..7dd188ad63a 100644 --- a/jetty-http-spi/pom.xml +++ b/jetty-http-spi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-http-spi diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index d5c97ec4f16..db7ec5c5644 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-http diff --git a/jetty-http2/http2-alpn-tests/pom.xml b/jetty-http2/http2-alpn-tests/pom.xml index d397a5e22d1..db20cb8218b 100644 --- a/jetty-http2/http2-alpn-tests/pom.xml +++ b/jetty-http2/http2-alpn-tests/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/http2-client/pom.xml b/jetty-http2/http2-client/pom.xml index b57b00b5a24..bb8ca86c719 100644 --- a/jetty-http2/http2-client/pom.xml +++ b/jetty-http2/http2-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/http2-common/pom.xml b/jetty-http2/http2-common/pom.xml index a8e58c545b7..2a40e987988 100644 --- a/jetty-http2/http2-common/pom.xml +++ b/jetty-http2/http2-common/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/http2-hpack/pom.xml b/jetty-http2/http2-hpack/pom.xml index add16c2afd1..331304ce56b 100644 --- a/jetty-http2/http2-hpack/pom.xml +++ b/jetty-http2/http2-hpack/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/http2-http-client-transport/pom.xml b/jetty-http2/http2-http-client-transport/pom.xml index 3f8490b9ab8..2c82b6989c6 100644 --- a/jetty-http2/http2-http-client-transport/pom.xml +++ b/jetty-http2/http2-http-client-transport/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/http2-server/pom.xml b/jetty-http2/http2-server/pom.xml index 77eb61f3b35..d94ebad7d88 100644 --- a/jetty-http2/http2-server/pom.xml +++ b/jetty-http2/http2-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-http2/pom.xml b/jetty-http2/pom.xml index d11f82a9f25..c1726a2f61b 100644 --- a/jetty-http2/pom.xml +++ b/jetty-http2/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-infinispan/infinispan-common/pom.xml b/jetty-infinispan/infinispan-common/pom.xml index 620748bdb67..aad511097ac 100644 --- a/jetty-infinispan/infinispan-common/pom.xml +++ b/jetty-infinispan/infinispan-common/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 infinispan-common diff --git a/jetty-infinispan/infinispan-embedded-query/pom.xml b/jetty-infinispan/infinispan-embedded-query/pom.xml index d2555f9d845..587d3364dd4 100644 --- a/jetty-infinispan/infinispan-embedded-query/pom.xml +++ b/jetty-infinispan/infinispan-embedded-query/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 infinispan-embedded-query diff --git a/jetty-infinispan/infinispan-embedded/pom.xml b/jetty-infinispan/infinispan-embedded/pom.xml index f33d4474e97..04602741f6e 100644 --- a/jetty-infinispan/infinispan-embedded/pom.xml +++ b/jetty-infinispan/infinispan-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 infinispan-embedded diff --git a/jetty-infinispan/infinispan-remote-query/pom.xml b/jetty-infinispan/infinispan-remote-query/pom.xml index 4cb8d9bbb6a..5d6d55913b4 100644 --- a/jetty-infinispan/infinispan-remote-query/pom.xml +++ b/jetty-infinispan/infinispan-remote-query/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 infinispan-remote-query diff --git a/jetty-infinispan/infinispan-remote/pom.xml b/jetty-infinispan/infinispan-remote/pom.xml index 63235a66170..f16050564b7 100644 --- a/jetty-infinispan/infinispan-remote/pom.xml +++ b/jetty-infinispan/infinispan-remote/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 infinispan-remote diff --git a/jetty-infinispan/pom.xml b/jetty-infinispan/pom.xml index 75103e182df..82db4ae4350 100644 --- a/jetty-infinispan/pom.xml +++ b/jetty-infinispan/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index 5efa95c6c7e..b8eaed018b3 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-io diff --git a/jetty-jaas/pom.xml b/jetty-jaas/pom.xml index 72b221acfc5..72f5c92c068 100644 --- a/jetty-jaas/pom.xml +++ b/jetty-jaas/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-jaas diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index eb3f6deedc1..e25bd8a11f3 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-jmh/pom.xml b/jetty-jmh/pom.xml index ab479d23d85..46f52e8664e 100644 --- a/jetty-jmh/pom.xml +++ b/jetty-jmh/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 3a650bd610b..2e44b2b53c5 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 5a8c24718a2..74b8408491f 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-jndi diff --git a/jetty-jspc-maven-plugin/pom.xml b/jetty-jspc-maven-plugin/pom.xml index c75714cf367..8c3cbb29e86 100644 --- a/jetty-jspc-maven-plugin/pom.xml +++ b/jetty-jspc-maven-plugin/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-jspc-maven-plugin diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml index ff00b926c2d..55d955a5a99 100644 --- a/jetty-maven-plugin/pom.xml +++ b/jetty-maven-plugin/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-maven-plugin diff --git a/jetty-memcached/jetty-memcached-sessions/pom.xml b/jetty-memcached/jetty-memcached-sessions/pom.xml index 270f026712a..74e2b10d10c 100644 --- a/jetty-memcached/jetty-memcached-sessions/pom.xml +++ b/jetty-memcached/jetty-memcached-sessions/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.memcached memcached-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-memcached/pom.xml b/jetty-memcached/pom.xml index e96cf2d6061..a2ed70b2435 100644 --- a/jetty-memcached/pom.xml +++ b/jetty-memcached/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 8b6c28b4465..15504b4d1d9 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-nosql diff --git a/jetty-openid/pom.xml b/jetty-openid/pom.xml index 32f4dda6715..4f9c95e5683 100644 --- a/jetty-openid/pom.xml +++ b/jetty-openid/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-osgi/jetty-osgi-alpn/pom.xml b/jetty-osgi/jetty-osgi-alpn/pom.xml index 921e25a3a70..6cef6fc11aa 100644 --- a/jetty-osgi/jetty-osgi-alpn/pom.xml +++ b/jetty-osgi/jetty-osgi-alpn/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-osgi-alpn diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index f9214dab3b1..8744773dc2f 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-osgi-boot-jsp diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index ba3721467c0..fd55cc944d5 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index e31b62d64d7..bce0accc623 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-osgi-boot diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index 4d20c4f092a..dd763ba3568 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-httpservice diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index eade9567f7e..4492f1321f6 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml index 5cc2e8d5fea..6ad1567e934 100644 --- a/jetty-osgi/test-jetty-osgi-context/pom.xml +++ b/jetty-osgi/test-jetty-osgi-context/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 test-jetty-osgi-context diff --git a/jetty-osgi/test-jetty-osgi-fragment/pom.xml b/jetty-osgi/test-jetty-osgi-fragment/pom.xml index ff6c269a776..ce7125e8387 100644 --- a/jetty-osgi/test-jetty-osgi-fragment/pom.xml +++ b/jetty-osgi/test-jetty-osgi-fragment/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi-server/pom.xml b/jetty-osgi/test-jetty-osgi-server/pom.xml index 1ca62e2f40f..56cc7c511d0 100644 --- a/jetty-osgi/test-jetty-osgi-server/pom.xml +++ b/jetty-osgi/test-jetty-osgi-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 test-jetty-osgi-server diff --git a/jetty-osgi/test-jetty-osgi-webapp/pom.xml b/jetty-osgi/test-jetty-osgi-webapp/pom.xml index a2c965a77a2..582bb496d37 100644 --- a/jetty-osgi/test-jetty-osgi-webapp/pom.xml +++ b/jetty-osgi/test-jetty-osgi-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 4bfcd4ea4f8..2b5dc1438c0 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index 40959c65258..aa2283f5580 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-plus diff --git a/jetty-proxy/pom.xml b/jetty-proxy/pom.xml index 43cc78553d8..b2d3a2f10bb 100644 --- a/jetty-proxy/pom.xml +++ b/jetty-proxy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-proxy diff --git a/jetty-quickstart/pom.xml b/jetty-quickstart/pom.xml index 8b9619227d0..a4af19179ba 100644 --- a/jetty-quickstart/pom.xml +++ b/jetty-quickstart/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 org.eclipse.jetty diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index 2d9265edf06..d51e608017b 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-rewrite diff --git a/jetty-runner/pom.xml b/jetty-runner/pom.xml index 4bd67315249..68087d1dee4 100644 --- a/jetty-runner/pom.xml +++ b/jetty-runner/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-runner diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index 8a74827cb50..9f7e054a745 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index 8e549a01400..cde53f550cf 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index 54eee174c55..5ee46f24f08 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index 4a97a896d45..55b095ec4cb 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-servlets diff --git a/jetty-spring/pom.xml b/jetty-spring/pom.xml index 6bbbbfb8752..050098239eb 100644 --- a/jetty-spring/pom.xml +++ b/jetty-spring/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-spring diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index e4f9c8adda1..9c34bcd1078 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-start diff --git a/jetty-unixsocket/pom.xml b/jetty-unixsocket/pom.xml index 5f7bfe1722d..1cc142a97cf 100644 --- a/jetty-unixsocket/pom.xml +++ b/jetty-unixsocket/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-unixsocket diff --git a/jetty-util-ajax/pom.xml b/jetty-util-ajax/pom.xml index bb793877902..53bdcca695e 100644 --- a/jetty-util-ajax/pom.xml +++ b/jetty-util-ajax/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-util-ajax diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index 8c4eed9715e..cf98fb8566b 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index f405910ae23..275c5febb47 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-webapp diff --git a/jetty-websocket/javax-websocket-client-impl/pom.xml b/jetty-websocket/javax-websocket-client-impl/pom.xml index 045ef095e7b..b7df9e27860 100644 --- a/jetty-websocket/javax-websocket-client-impl/pom.xml +++ b/jetty-websocket/javax-websocket-client-impl/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/javax-websocket-server-impl/pom.xml b/jetty-websocket/javax-websocket-server-impl/pom.xml index abeb0bc434e..42b3700471c 100644 --- a/jetty-websocket/javax-websocket-server-impl/pom.xml +++ b/jetty-websocket/javax-websocket-server-impl/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/jetty-websocket-tests/pom.xml b/jetty-websocket/jetty-websocket-tests/pom.xml index ac4e5befd7b..cf211116780 100644 --- a/jetty-websocket/jetty-websocket-tests/pom.xml +++ b/jetty-websocket/jetty-websocket-tests/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 1215318c6c7..d64de08be04 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/websocket-api/pom.xml b/jetty-websocket/websocket-api/pom.xml index 975d700d283..1917cc3671e 100644 --- a/jetty-websocket/websocket-api/pom.xml +++ b/jetty-websocket/websocket-api/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/websocket-client/pom.xml b/jetty-websocket/websocket-client/pom.xml index a5c7894f114..0339ce5e92d 100644 --- a/jetty-websocket/websocket-client/pom.xml +++ b/jetty-websocket/websocket-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/websocket-common/pom.xml b/jetty-websocket/websocket-common/pom.xml index ced91037eab..a8225873a0b 100644 --- a/jetty-websocket/websocket-common/pom.xml +++ b/jetty-websocket/websocket-common/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/websocket-server/pom.xml b/jetty-websocket/websocket-server/pom.xml index 48ec0c302cc..fc81d4f36f3 100644 --- a/jetty-websocket/websocket-server/pom.xml +++ b/jetty-websocket/websocket-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-websocket/websocket-servlet/pom.xml b/jetty-websocket/websocket-servlet/pom.xml index 52759d5c128..a2bea8efcf4 100644 --- a/jetty-websocket/websocket-servlet/pom.xml +++ b/jetty-websocket/websocket-servlet/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 5c1653c42cd..405b0843332 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index b8986db6a86..b7d0a991c73 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 Jetty :: Project The Eclipse Jetty Project pom diff --git a/tests/pom.xml b/tests/pom.xml index c13d4db6ea4..2c399a0c77e 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml org.eclipse.jetty.tests diff --git a/tests/test-continuation/pom.xml b/tests/test-continuation/pom.xml index 1494e53b224..384786bac12 100644 --- a/tests/test-continuation/pom.xml +++ b/tests/test-continuation/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/tests/test-distribution/pom.xml b/tests/test-distribution/pom.xml index 85d592e07c6..1bbcd8b131c 100644 --- a/tests/test-distribution/pom.xml +++ b/tests/test-distribution/pom.xml @@ -2,7 +2,7 @@ tests-parent org.eclipse.jetty.tests - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-http-client-transport/pom.xml b/tests/test-http-client-transport/pom.xml index 55fc990bddc..2d2acd0842e 100644 --- a/tests/test-http-client-transport/pom.xml +++ b/tests/test-http-client-transport/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 6a1feabddbc..6dc699bae03 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 test-integration diff --git a/tests/test-jmx/jmx-webapp-it/pom.xml b/tests/test-jmx/jmx-webapp-it/pom.xml index 5046fcdde62..918bae001ef 100644 --- a/tests/test-jmx/jmx-webapp-it/pom.xml +++ b/tests/test-jmx/jmx-webapp-it/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-jmx-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 jmx-webapp-it diff --git a/tests/test-jmx/jmx-webapp/pom.xml b/tests/test-jmx/jmx-webapp/pom.xml index 01c5fdc2fe0..2f0f3d49346 100644 --- a/tests/test-jmx/jmx-webapp/pom.xml +++ b/tests/test-jmx/jmx-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-jmx-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 jmx-webapp war diff --git a/tests/test-jmx/pom.xml b/tests/test-jmx/pom.xml index 0604c93a4c9..33a2fab6a66 100644 --- a/tests/test-jmx/pom.xml +++ b/tests/test-jmx/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 test-jmx-parent diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index e64495991a7..4cf3f85e9e5 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-quickstart/pom.xml b/tests/test-quickstart/pom.xml index a748977848b..3e4cfbfd78c 100644 --- a/tests/test-quickstart/pom.xml +++ b/tests/test-quickstart/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index 0ca22dcd1c2..e2a353c045d 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-file-sessions/pom.xml b/tests/test-sessions/test-file-sessions/pom.xml index b828eb93c93..febc24f80b3 100644 --- a/tests/test-sessions/test-file-sessions/pom.xml +++ b/tests/test-sessions/test-file-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-file-sessions Jetty Tests :: Sessions :: File diff --git a/tests/test-sessions/test-gcloud-sessions/pom.xml b/tests/test-sessions/test-gcloud-sessions/pom.xml index ae19f2de755..e740ea941b6 100644 --- a/tests/test-sessions/test-gcloud-sessions/pom.xml +++ b/tests/test-sessions/test-gcloud-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-gcloud-sessions Jetty Tests :: Sessions :: GCloud diff --git a/tests/test-sessions/test-hazelcast-sessions/pom.xml b/tests/test-sessions/test-hazelcast-sessions/pom.xml index 56db185935a..a4164dc4f62 100644 --- a/tests/test-sessions/test-hazelcast-sessions/pom.xml +++ b/tests/test-sessions/test-hazelcast-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-hazelcast-sessions Jetty Tests :: Sessions :: Hazelcast diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index ba31c16285f..f42af52e40c 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-infinispan-sessions Jetty Tests :: Sessions :: Infinispan diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 1b60ce85229..fe2c887e8d4 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-memcached-sessions/pom.xml b/tests/test-sessions/test-memcached-sessions/pom.xml index 2a691adc0f6..f8964fce9b3 100644 --- a/tests/test-sessions/test-memcached-sessions/pom.xml +++ b/tests/test-sessions/test-memcached-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-memcached-sessions Jetty Tests :: Sessions :: Memcached diff --git a/tests/test-sessions/test-mongodb-sessions/pom.xml b/tests/test-sessions/test-mongodb-sessions/pom.xml index ade0d5a343b..9bacbc7d259 100644 --- a/tests/test-sessions/test-mongodb-sessions/pom.xml +++ b/tests/test-sessions/test-mongodb-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-mongodb-sessions Jetty Tests :: Sessions :: Mongo diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index aa45c63cc2a..a534e5df8ee 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index e69c4c8566a..4bb674b1469 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml test-webapps-parent diff --git a/tests/test-webapps/test-cdi-common-webapp/pom.xml b/tests/test-webapps/test-cdi-common-webapp/pom.xml index 7a10f068c71..be0ad0aeae3 100644 --- a/tests/test-webapps/test-cdi-common-webapp/pom.xml +++ b/tests/test-webapps/test-cdi-common-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-webapps/test-felix-webapp/pom.xml b/tests/test-webapps/test-felix-webapp/pom.xml index e170509eff9..ed58abb0fbe 100644 --- a/tests/test-webapps/test-felix-webapp/pom.xml +++ b/tests/test-webapps/test-felix-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-webapps/test-http2-webapp/pom.xml b/tests/test-webapps/test-http2-webapp/pom.xml index a7e2a1c358c..a3b84d89b4f 100644 --- a/tests/test-webapps/test-http2-webapp/pom.xml +++ b/tests/test-webapps/test-http2-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-webapps/test-jaas-webapp/pom.xml b/tests/test-webapps/test-jaas-webapp/pom.xml index 82adc28bbfc..d6f2251b982 100644 --- a/tests/test-webapps/test-jaas-webapp/pom.xml +++ b/tests/test-webapps/test-jaas-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-jaas-webapp Jetty Tests :: WebApp :: JAAS diff --git a/tests/test-webapps/test-jetty-webapp/pom.xml b/tests/test-webapps/test-jetty-webapp/pom.xml index e37b5b22de6..c7383f610fd 100644 --- a/tests/test-webapps/test-jetty-webapp/pom.xml +++ b/tests/test-webapps/test-jetty-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/tests/test-webapps/test-jndi-webapp/pom.xml b/tests/test-webapps/test-jndi-webapp/pom.xml index 07c04f866e9..848eae6c11e 100644 --- a/tests/test-webapps/test-jndi-webapp/pom.xml +++ b/tests/test-webapps/test-jndi-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-jndi-webapp Jetty Tests :: WebApp :: JNDI diff --git a/tests/test-webapps/test-mock-resources/pom.xml b/tests/test-webapps/test-mock-resources/pom.xml index 0607935a35f..c9db8291d53 100644 --- a/tests/test-webapps/test-mock-resources/pom.xml +++ b/tests/test-webapps/test-mock-resources/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 Jetty Tests :: WebApp :: Mock Resources test-mock-resources diff --git a/tests/test-webapps/test-owb-cdi-webapp/pom.xml b/tests/test-webapps/test-owb-cdi-webapp/pom.xml index a673347d33e..c6819695b22 100644 --- a/tests/test-webapps/test-owb-cdi-webapp/pom.xml +++ b/tests/test-webapps/test-owb-cdi-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 diff --git a/tests/test-webapps/test-proxy-webapp/pom.xml b/tests/test-webapps/test-proxy-webapp/pom.xml index 884d0b1afab..acae710987a 100644 --- a/tests/test-webapps/test-proxy-webapp/pom.xml +++ b/tests/test-webapps/test-proxy-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 ../pom.xml 4.0.0 diff --git a/tests/test-webapps/test-servlet-spec/pom.xml b/tests/test-webapps/test-servlet-spec/pom.xml index 2dec350ab6c..1e44e3e3581 100644 --- a/tests/test-webapps/test-servlet-spec/pom.xml +++ b/tests/test-webapps/test-servlet-spec/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-servlet-spec-parent Jetty Tests :: Spec Test WebApp :: Parent diff --git a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml index efd55e56e25..229b3e9558f 100644 --- a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-container-initializer jar diff --git a/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml b/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml index 71aa95c4066..ede32dfcc05 100644 --- a/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 Jetty Tests :: Webapps :: Spec Webapp test-spec-webapp diff --git a/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml b/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml index a225644e50c..a5e54b009e7 100644 --- a/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 Jetty Tests :: WebApp :: Servlet Spec :: Fragment Jar diff --git a/tests/test-webapps/test-simple-webapp/pom.xml b/tests/test-webapps/test-simple-webapp/pom.xml index ddea1b73710..16289299d84 100644 --- a/tests/test-webapps/test-simple-webapp/pom.xml +++ b/tests/test-webapps/test-simple-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-simple-webapp diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 11f24e990bd..3dbc91e7436 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 diff --git a/tests/test-webapps/test-weld-cdi-webapp/pom.xml b/tests/test-webapps/test-weld-cdi-webapp/pom.xml index 32013b4fe89..69164f00955 100644 --- a/tests/test-webapps/test-weld-cdi-webapp/pom.xml +++ b/tests/test-webapps/test-weld-cdi-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29-SNAPSHOT + 9.4.29.v20200521 4.0.0 From 5d6f3e2ddc0832e6107543dfd9858c9c6b0c8d6e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 21 May 2020 13:42:25 -0500 Subject: [PATCH 59/77] Updating to version 9.4.30-SNAPSHOT --- VERSION.txt | 2 + aggregates/jetty-all-compact3/pom.xml | 2 +- aggregates/jetty-all/pom.xml | 2 +- apache-jsp/pom.xml | 2 +- apache-jstl/pom.xml | 2 +- build-resources/pom.xml | 2 +- examples/async-rest/async-rest-jar/pom.xml | 2 +- examples/async-rest/async-rest-webapp/pom.xml | 2 +- examples/async-rest/pom.xml | 2 +- examples/embedded/pom.xml | 2 +- examples/pom.xml | 2 +- jetty-alpn/jetty-alpn-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-client/pom.xml | 2 +- .../jetty-alpn-conscrypt-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-java-client/pom.xml | 2 +- jetty-alpn/jetty-alpn-java-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-openjdk8-client/pom.xml | 2 +- jetty-alpn/jetty-alpn-openjdk8-server/pom.xml | 2 +- jetty-alpn/jetty-alpn-server/pom.xml | 2 +- jetty-alpn/pom.xml | 2 +- jetty-annotations/pom.xml | 2 +- jetty-ant/pom.xml | 2 +- jetty-bom/pom.xml | 134 +++++++++--------- jetty-cdi/pom.xml | 2 +- jetty-client/pom.xml | 2 +- jetty-continuation/pom.xml | 2 +- jetty-deploy/pom.xml | 2 +- jetty-distribution/pom.xml | 2 +- jetty-documentation/pom.xml | 2 +- jetty-fcgi/fcgi-client/pom.xml | 2 +- jetty-fcgi/fcgi-server/pom.xml | 2 +- jetty-fcgi/pom.xml | 2 +- .../jetty-gcloud-session-manager/pom.xml | 2 +- jetty-gcloud/pom.xml | 2 +- jetty-hazelcast/pom.xml | 2 +- jetty-home/pom.xml | 2 +- jetty-http-spi/pom.xml | 2 +- jetty-http/pom.xml | 2 +- jetty-http2/http2-alpn-tests/pom.xml | 2 +- jetty-http2/http2-client/pom.xml | 2 +- jetty-http2/http2-common/pom.xml | 2 +- jetty-http2/http2-hpack/pom.xml | 2 +- .../http2-http-client-transport/pom.xml | 2 +- jetty-http2/http2-server/pom.xml | 2 +- jetty-http2/pom.xml | 2 +- jetty-infinispan/infinispan-common/pom.xml | 2 +- .../infinispan-embedded-query/pom.xml | 2 +- jetty-infinispan/infinispan-embedded/pom.xml | 2 +- .../infinispan-remote-query/pom.xml | 2 +- jetty-infinispan/infinispan-remote/pom.xml | 2 +- jetty-infinispan/pom.xml | 2 +- jetty-io/pom.xml | 2 +- jetty-jaas/pom.xml | 2 +- jetty-jaspi/pom.xml | 2 +- jetty-jmh/pom.xml | 2 +- jetty-jmx/pom.xml | 2 +- jetty-jndi/pom.xml | 2 +- jetty-jspc-maven-plugin/pom.xml | 2 +- jetty-maven-plugin/pom.xml | 2 +- .../jetty-memcached-sessions/pom.xml | 2 +- jetty-memcached/pom.xml | 2 +- jetty-nosql/pom.xml | 2 +- jetty-openid/pom.xml | 2 +- jetty-osgi/jetty-osgi-alpn/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 2 +- jetty-osgi/jetty-osgi-boot/pom.xml | 2 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 2 +- jetty-osgi/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-context/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-fragment/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-server/pom.xml | 2 +- jetty-osgi/test-jetty-osgi-webapp/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- jetty-plus/pom.xml | 2 +- jetty-proxy/pom.xml | 2 +- jetty-quickstart/pom.xml | 2 +- jetty-rewrite/pom.xml | 2 +- jetty-runner/pom.xml | 2 +- jetty-security/pom.xml | 2 +- jetty-server/pom.xml | 2 +- jetty-servlet/pom.xml | 2 +- jetty-servlets/pom.xml | 2 +- jetty-spring/pom.xml | 2 +- jetty-start/pom.xml | 2 +- jetty-unixsocket/pom.xml | 2 +- jetty-util-ajax/pom.xml | 2 +- jetty-util/pom.xml | 2 +- jetty-webapp/pom.xml | 2 +- .../javax-websocket-client-impl/pom.xml | 2 +- .../javax-websocket-server-impl/pom.xml | 2 +- jetty-websocket/jetty-websocket-tests/pom.xml | 2 +- jetty-websocket/pom.xml | 2 +- jetty-websocket/websocket-api/pom.xml | 2 +- jetty-websocket/websocket-client/pom.xml | 2 +- jetty-websocket/websocket-common/pom.xml | 2 +- jetty-websocket/websocket-server/pom.xml | 2 +- jetty-websocket/websocket-servlet/pom.xml | 2 +- jetty-xml/pom.xml | 2 +- pom.xml | 2 +- tests/pom.xml | 2 +- tests/test-continuation/pom.xml | 2 +- tests/test-distribution/pom.xml | 2 +- tests/test-http-client-transport/pom.xml | 2 +- tests/test-integration/pom.xml | 2 +- tests/test-jmx/jmx-webapp-it/pom.xml | 2 +- tests/test-jmx/jmx-webapp/pom.xml | 2 +- tests/test-jmx/pom.xml | 2 +- tests/test-loginservice/pom.xml | 2 +- tests/test-quickstart/pom.xml | 2 +- tests/test-sessions/pom.xml | 2 +- .../test-sessions/test-file-sessions/pom.xml | 2 +- .../test-gcloud-sessions/pom.xml | 2 +- .../test-hazelcast-sessions/pom.xml | 2 +- .../test-infinispan-sessions/pom.xml | 2 +- .../test-sessions/test-jdbc-sessions/pom.xml | 2 +- .../test-memcached-sessions/pom.xml | 2 +- .../test-mongodb-sessions/pom.xml | 2 +- .../test-sessions-common/pom.xml | 2 +- tests/test-webapps/pom.xml | 2 +- .../test-cdi-common-webapp/pom.xml | 2 +- tests/test-webapps/test-felix-webapp/pom.xml | 2 +- tests/test-webapps/test-http2-webapp/pom.xml | 2 +- tests/test-webapps/test-jaas-webapp/pom.xml | 2 +- tests/test-webapps/test-jetty-webapp/pom.xml | 2 +- tests/test-webapps/test-jndi-webapp/pom.xml | 2 +- .../test-webapps/test-mock-resources/pom.xml | 2 +- .../test-webapps/test-owb-cdi-webapp/pom.xml | 2 +- tests/test-webapps/test-proxy-webapp/pom.xml | 2 +- tests/test-webapps/test-servlet-spec/pom.xml | 2 +- .../test-container-initializer/pom.xml | 2 +- .../test-spec-webapp/pom.xml | 2 +- .../test-web-fragment/pom.xml | 2 +- tests/test-webapps/test-simple-webapp/pom.xml | 2 +- .../test-webapps/test-webapp-rfc2616/pom.xml | 2 +- .../test-webapps/test-weld-cdi-webapp/pom.xml | 2 +- 136 files changed, 203 insertions(+), 201 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 009f6013f1a..ec0c39fc05d 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,3 +1,5 @@ +jetty-9.4.30-SNAPSHOT + jetty-9.4.29.v20200521 - 21 May 2020 + 2188 Lock contention creating HTTP/2 streams + 4235 communicate the reason of failure to the OpenID error page diff --git a/aggregates/jetty-all-compact3/pom.xml b/aggregates/jetty-all-compact3/pom.xml index 5a27d149698..19627dc1a0a 100644 --- a/aggregates/jetty-all-compact3/pom.xml +++ b/aggregates/jetty-all-compact3/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/aggregates/jetty-all/pom.xml b/aggregates/jetty-all/pom.xml index 1524b48dfc3..a44bf82d2d7 100644 --- a/aggregates/jetty-all/pom.xml +++ b/aggregates/jetty-all/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml index 2d75087709a..e67340f0561 100644 --- a/apache-jsp/pom.xml +++ b/apache-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 apache-jsp diff --git a/apache-jstl/pom.xml b/apache-jstl/pom.xml index 295b9f53d9c..ab6f8643902 100644 --- a/apache-jstl/pom.xml +++ b/apache-jstl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 apache-jstl diff --git a/build-resources/pom.xml b/build-resources/pom.xml index 46b88407b79..2c0b4401442 100644 --- a/build-resources/pom.xml +++ b/build-resources/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.eclipse.jetty build-resources - 9.4.29.v20200521 + 9.4.30-SNAPSHOT jar Jetty :: Build Resources diff --git a/examples/async-rest/async-rest-jar/pom.xml b/examples/async-rest/async-rest-jar/pom.xml index 288785f42d5..0d8656fcd47 100644 --- a/examples/async-rest/async-rest-jar/pom.xml +++ b/examples/async-rest/async-rest-jar/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty example-async-rest - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/examples/async-rest/async-rest-webapp/pom.xml b/examples/async-rest/async-rest-webapp/pom.xml index 040aaec8303..531495d6d6f 100644 --- a/examples/async-rest/async-rest-webapp/pom.xml +++ b/examples/async-rest/async-rest-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty example-async-rest - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/examples/async-rest/pom.xml b/examples/async-rest/pom.xml index f40892d591d..f90ea27236c 100644 --- a/examples/async-rest/pom.xml +++ b/examples/async-rest/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.examples examples-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index 17734a264f4..c9882987422 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.examples examples-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/examples/pom.xml b/examples/pom.xml index 8d3fc417bc6..b5985e89716 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-client/pom.xml b/jetty-alpn/jetty-alpn-client/pom.xml index bccf8a700db..38192c766fa 100644 --- a/jetty-alpn/jetty-alpn-client/pom.xml +++ b/jetty-alpn/jetty-alpn-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-alpn-client diff --git a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml index daef0477762..ecb9f6e1ea5 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml index 2f395f4d1ed..363ef215ea9 100644 --- a/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml +++ b/jetty-alpn/jetty-alpn-conscrypt-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-java-client/pom.xml b/jetty-alpn/jetty-alpn-java-client/pom.xml index c790d1ff1ae..bfe7c9adbfb 100644 --- a/jetty-alpn/jetty-alpn-java-client/pom.xml +++ b/jetty-alpn/jetty-alpn-java-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-java-server/pom.xml b/jetty-alpn/jetty-alpn-java-server/pom.xml index 341d8b1a99a..f86286c2739 100644 --- a/jetty-alpn/jetty-alpn-java-server/pom.xml +++ b/jetty-alpn/jetty-alpn-java-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml b/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml index 423ff07e2ab..b96b43e811a 100644 --- a/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml +++ b/jetty-alpn/jetty-alpn-openjdk8-client/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml b/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml index 59e1fdfc687..25b68c8b2df 100644 --- a/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml +++ b/jetty-alpn/jetty-alpn-openjdk8-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-alpn/jetty-alpn-server/pom.xml b/jetty-alpn/jetty-alpn-server/pom.xml index 268321da26b..8abaae6142d 100644 --- a/jetty-alpn/jetty-alpn-server/pom.xml +++ b/jetty-alpn/jetty-alpn-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-alpn-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-alpn-server diff --git a/jetty-alpn/pom.xml b/jetty-alpn/pom.xml index dd35154f804..5f64c50f1a2 100644 --- a/jetty-alpn/pom.xml +++ b/jetty-alpn/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-alpn-parent diff --git a/jetty-annotations/pom.xml b/jetty-annotations/pom.xml index 6f0b05fad28..5307e86146c 100644 --- a/jetty-annotations/pom.xml +++ b/jetty-annotations/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-annotations diff --git a/jetty-ant/pom.xml b/jetty-ant/pom.xml index f6cb9787b3f..2c9cc5878c4 100644 --- a/jetty-ant/pom.xml +++ b/jetty-ant/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-ant diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index 24841e21d35..88250c98eef 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -9,7 +9,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT @@ -53,336 +53,336 @@ org.eclipse.jetty apache-jsp - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty apache-jstl - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-java-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-java-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-openjdk8-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-openjdk8-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-conscrypt-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-conscrypt-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-alpn-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-annotations - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-ant - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-continuation - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-deploy - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-distribution - 9.4.29.v20200521 + 9.4.30-SNAPSHOT zip org.eclipse.jetty jetty-distribution - 9.4.29.v20200521 + 9.4.30-SNAPSHOT tar.gz org.eclipse.jetty.fcgi fcgi-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.fcgi fcgi-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.gcloud jetty-gcloud-session-manager - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-home - 9.4.29.v20200521 + 9.4.30-SNAPSHOT zip org.eclipse.jetty jetty-home - 9.4.29.v20200521 + 9.4.30-SNAPSHOT tar.gz org.eclipse.jetty jetty-http - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.http2 http2-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.http2 http2-common - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.http2 http2-hpack - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.http2 http2-http-client-transport - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.http2 http2-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-http-spi - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty infinispan-common - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty infinispan-remote-query - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty infinispan-embedded-query - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-hazelcast - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-io - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-jaas - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-jaspi - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-jmx - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-jndi - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.memcached jetty-memcached-sessions - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-nosql - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.osgi jetty-osgi-boot - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.osgi jetty-osgi-boot-jsp - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.osgi jetty-osgi-boot-warurl - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.osgi jetty-httpservice - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-plus - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-proxy - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-quickstart - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-rewrite - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-security - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-openid - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-servlet - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-servlets - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-spring - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-unixsocket - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-util - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-util-ajax - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-webapp - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket javax-websocket-client-impl - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket javax-websocket-server-impl - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket websocket-api - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket websocket-client - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket websocket-common - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket websocket-server - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty.websocket websocket-servlet - 9.4.29.v20200521 + 9.4.30-SNAPSHOT org.eclipse.jetty jetty-xml - 9.4.29.v20200521 + 9.4.30-SNAPSHOT diff --git a/jetty-cdi/pom.xml b/jetty-cdi/pom.xml index be078af41ce..5f195a05203 100644 --- a/jetty-cdi/pom.xml +++ b/jetty-cdi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 801de2fc76e..4994894d4e4 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-continuation/pom.xml b/jetty-continuation/pom.xml index 9a4b6cc34ae..f7df28c549a 100644 --- a/jetty-continuation/pom.xml +++ b/jetty-continuation/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-continuation diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index b70712b0529..ad8277204f0 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-deploy diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 82f2400494d..2c0fc3a9ecd 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-distribution diff --git a/jetty-documentation/pom.xml b/jetty-documentation/pom.xml index 48c07479ec4..949077cc623 100644 --- a/jetty-documentation/pom.xml +++ b/jetty-documentation/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT jetty-documentation Jetty :: Documentation diff --git a/jetty-fcgi/fcgi-client/pom.xml b/jetty-fcgi/fcgi-client/pom.xml index a0ccde50b09..6eeba32210b 100644 --- a/jetty-fcgi/fcgi-client/pom.xml +++ b/jetty-fcgi/fcgi-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.fcgi fcgi-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-fcgi/fcgi-server/pom.xml b/jetty-fcgi/fcgi-server/pom.xml index 82e1cd52e70..2c3d43fa56f 100644 --- a/jetty-fcgi/fcgi-server/pom.xml +++ b/jetty-fcgi/fcgi-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.fcgi fcgi-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-fcgi/pom.xml b/jetty-fcgi/pom.xml index 3aa17095190..c7722607f1e 100644 --- a/jetty-fcgi/pom.xml +++ b/jetty-fcgi/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index 32ff10ac7da..6f06e4603bc 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.gcloud gcloud-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-gcloud/pom.xml b/jetty-gcloud/pom.xml index f3132c971e9..22461b9c5e0 100644 --- a/jetty-gcloud/pom.xml +++ b/jetty-gcloud/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-hazelcast/pom.xml b/jetty-hazelcast/pom.xml index d00416504c7..a1929600e04 100644 --- a/jetty-hazelcast/pom.xml +++ b/jetty-hazelcast/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-home/pom.xml b/jetty-home/pom.xml index 520e3f1e95f..f6c1602642a 100644 --- a/jetty-home/pom.xml +++ b/jetty-home/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-home diff --git a/jetty-http-spi/pom.xml b/jetty-http-spi/pom.xml index 7dd188ad63a..f967c5b06cb 100644 --- a/jetty-http-spi/pom.xml +++ b/jetty-http-spi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-http-spi diff --git a/jetty-http/pom.xml b/jetty-http/pom.xml index db7ec5c5644..ebd567b29b1 100644 --- a/jetty-http/pom.xml +++ b/jetty-http/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-http diff --git a/jetty-http2/http2-alpn-tests/pom.xml b/jetty-http2/http2-alpn-tests/pom.xml index db20cb8218b..b2ab4bc423d 100644 --- a/jetty-http2/http2-alpn-tests/pom.xml +++ b/jetty-http2/http2-alpn-tests/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/http2-client/pom.xml b/jetty-http2/http2-client/pom.xml index bb8ca86c719..f4ada14f09e 100644 --- a/jetty-http2/http2-client/pom.xml +++ b/jetty-http2/http2-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/http2-common/pom.xml b/jetty-http2/http2-common/pom.xml index 2a40e987988..01058c481ca 100644 --- a/jetty-http2/http2-common/pom.xml +++ b/jetty-http2/http2-common/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/http2-hpack/pom.xml b/jetty-http2/http2-hpack/pom.xml index 331304ce56b..94de2632c00 100644 --- a/jetty-http2/http2-hpack/pom.xml +++ b/jetty-http2/http2-hpack/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/http2-http-client-transport/pom.xml b/jetty-http2/http2-http-client-transport/pom.xml index 2c82b6989c6..e0c85976e60 100644 --- a/jetty-http2/http2-http-client-transport/pom.xml +++ b/jetty-http2/http2-http-client-transport/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/http2-server/pom.xml b/jetty-http2/http2-server/pom.xml index d94ebad7d88..55226c52499 100644 --- a/jetty-http2/http2-server/pom.xml +++ b/jetty-http2/http2-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.http2 http2-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-http2/pom.xml b/jetty-http2/pom.xml index c1726a2f61b..fc8972c2c68 100644 --- a/jetty-http2/pom.xml +++ b/jetty-http2/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-infinispan/infinispan-common/pom.xml b/jetty-infinispan/infinispan-common/pom.xml index aad511097ac..46ec6df09c6 100644 --- a/jetty-infinispan/infinispan-common/pom.xml +++ b/jetty-infinispan/infinispan-common/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 infinispan-common diff --git a/jetty-infinispan/infinispan-embedded-query/pom.xml b/jetty-infinispan/infinispan-embedded-query/pom.xml index 587d3364dd4..6c9f367aed1 100644 --- a/jetty-infinispan/infinispan-embedded-query/pom.xml +++ b/jetty-infinispan/infinispan-embedded-query/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 infinispan-embedded-query diff --git a/jetty-infinispan/infinispan-embedded/pom.xml b/jetty-infinispan/infinispan-embedded/pom.xml index 04602741f6e..5130dd2f6ef 100644 --- a/jetty-infinispan/infinispan-embedded/pom.xml +++ b/jetty-infinispan/infinispan-embedded/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 infinispan-embedded diff --git a/jetty-infinispan/infinispan-remote-query/pom.xml b/jetty-infinispan/infinispan-remote-query/pom.xml index 5d6d55913b4..0003b9c67c4 100644 --- a/jetty-infinispan/infinispan-remote-query/pom.xml +++ b/jetty-infinispan/infinispan-remote-query/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 infinispan-remote-query diff --git a/jetty-infinispan/infinispan-remote/pom.xml b/jetty-infinispan/infinispan-remote/pom.xml index f16050564b7..30796a0c9e5 100644 --- a/jetty-infinispan/infinispan-remote/pom.xml +++ b/jetty-infinispan/infinispan-remote/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty infinispan-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 infinispan-remote diff --git a/jetty-infinispan/pom.xml b/jetty-infinispan/pom.xml index 82db4ae4350..fa12d193a1e 100644 --- a/jetty-infinispan/pom.xml +++ b/jetty-infinispan/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-io/pom.xml b/jetty-io/pom.xml index b8eaed018b3..6228d3a57c0 100644 --- a/jetty-io/pom.xml +++ b/jetty-io/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-io diff --git a/jetty-jaas/pom.xml b/jetty-jaas/pom.xml index 72f5c92c068..af4099f1476 100644 --- a/jetty-jaas/pom.xml +++ b/jetty-jaas/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-jaas diff --git a/jetty-jaspi/pom.xml b/jetty-jaspi/pom.xml index e25bd8a11f3..d221e40df71 100644 --- a/jetty-jaspi/pom.xml +++ b/jetty-jaspi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-jmh/pom.xml b/jetty-jmh/pom.xml index 46f52e8664e..aaf78a8c53b 100644 --- a/jetty-jmh/pom.xml +++ b/jetty-jmh/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-jmx/pom.xml b/jetty-jmx/pom.xml index 2e44b2b53c5..6c16e0b42b8 100644 --- a/jetty-jmx/pom.xml +++ b/jetty-jmx/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-jmx diff --git a/jetty-jndi/pom.xml b/jetty-jndi/pom.xml index 74b8408491f..6cf3c478b65 100644 --- a/jetty-jndi/pom.xml +++ b/jetty-jndi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-jndi diff --git a/jetty-jspc-maven-plugin/pom.xml b/jetty-jspc-maven-plugin/pom.xml index 8c3cbb29e86..ac255f8fa55 100644 --- a/jetty-jspc-maven-plugin/pom.xml +++ b/jetty-jspc-maven-plugin/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-jspc-maven-plugin diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml index 55d955a5a99..9c12c55e8a0 100644 --- a/jetty-maven-plugin/pom.xml +++ b/jetty-maven-plugin/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-maven-plugin diff --git a/jetty-memcached/jetty-memcached-sessions/pom.xml b/jetty-memcached/jetty-memcached-sessions/pom.xml index 74e2b10d10c..fef40a31bd1 100644 --- a/jetty-memcached/jetty-memcached-sessions/pom.xml +++ b/jetty-memcached/jetty-memcached-sessions/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.memcached memcached-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-memcached/pom.xml b/jetty-memcached/pom.xml index a2ed70b2435..83ed94f59b8 100644 --- a/jetty-memcached/pom.xml +++ b/jetty-memcached/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 15504b4d1d9..cc4aa30c88d 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-nosql diff --git a/jetty-openid/pom.xml b/jetty-openid/pom.xml index 4f9c95e5683..dd494834763 100644 --- a/jetty-openid/pom.xml +++ b/jetty-openid/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-osgi/jetty-osgi-alpn/pom.xml b/jetty-osgi/jetty-osgi-alpn/pom.xml index 6cef6fc11aa..2d768ec7e67 100644 --- a/jetty-osgi/jetty-osgi-alpn/pom.xml +++ b/jetty-osgi/jetty-osgi-alpn/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-osgi-alpn diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 8744773dc2f..d851f8ab19b 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-osgi-boot-jsp diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index fd55cc944d5..05422b44eed 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index bce0accc623..e7fcf5c539c 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-osgi-boot diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index dd763ba3568..0cdb74deb14 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-httpservice diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index 4492f1321f6..db1c9237515 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml index 6ad1567e934..bd7d5e5e1e5 100644 --- a/jetty-osgi/test-jetty-osgi-context/pom.xml +++ b/jetty-osgi/test-jetty-osgi-context/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 test-jetty-osgi-context diff --git a/jetty-osgi/test-jetty-osgi-fragment/pom.xml b/jetty-osgi/test-jetty-osgi-fragment/pom.xml index ce7125e8387..1a520f830a3 100644 --- a/jetty-osgi/test-jetty-osgi-fragment/pom.xml +++ b/jetty-osgi/test-jetty-osgi-fragment/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi-server/pom.xml b/jetty-osgi/test-jetty-osgi-server/pom.xml index 56cc7c511d0..a8671e31435 100644 --- a/jetty-osgi/test-jetty-osgi-server/pom.xml +++ b/jetty-osgi/test-jetty-osgi-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 test-jetty-osgi-server diff --git a/jetty-osgi/test-jetty-osgi-webapp/pom.xml b/jetty-osgi/test-jetty-osgi-webapp/pom.xml index 582bb496d37..d80ca168896 100644 --- a/jetty-osgi/test-jetty-osgi-webapp/pom.xml +++ b/jetty-osgi/test-jetty-osgi-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 2b5dc1438c0..0cb455e6644 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty.osgi jetty-osgi-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/jetty-plus/pom.xml b/jetty-plus/pom.xml index aa2283f5580..96d84003b6f 100644 --- a/jetty-plus/pom.xml +++ b/jetty-plus/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-plus diff --git a/jetty-proxy/pom.xml b/jetty-proxy/pom.xml index b2d3a2f10bb..787ddf6b7cb 100644 --- a/jetty-proxy/pom.xml +++ b/jetty-proxy/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-proxy diff --git a/jetty-quickstart/pom.xml b/jetty-quickstart/pom.xml index a4af19179ba..1e8ffe21677 100644 --- a/jetty-quickstart/pom.xml +++ b/jetty-quickstart/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 org.eclipse.jetty diff --git a/jetty-rewrite/pom.xml b/jetty-rewrite/pom.xml index d51e608017b..a02ef67dff8 100644 --- a/jetty-rewrite/pom.xml +++ b/jetty-rewrite/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-rewrite diff --git a/jetty-runner/pom.xml b/jetty-runner/pom.xml index 68087d1dee4..47ee5853da7 100644 --- a/jetty-runner/pom.xml +++ b/jetty-runner/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-runner diff --git a/jetty-security/pom.xml b/jetty-security/pom.xml index 9f7e054a745..4ebda80383d 100644 --- a/jetty-security/pom.xml +++ b/jetty-security/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-security diff --git a/jetty-server/pom.xml b/jetty-server/pom.xml index cde53f550cf..d571f5a0cc4 100644 --- a/jetty-server/pom.xml +++ b/jetty-server/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-server diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml index 5ee46f24f08..287f82b64cb 100644 --- a/jetty-servlet/pom.xml +++ b/jetty-servlet/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-servlet diff --git a/jetty-servlets/pom.xml b/jetty-servlets/pom.xml index 55b095ec4cb..3d90f75be85 100644 --- a/jetty-servlets/pom.xml +++ b/jetty-servlets/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-servlets diff --git a/jetty-spring/pom.xml b/jetty-spring/pom.xml index 050098239eb..2451c70c63d 100644 --- a/jetty-spring/pom.xml +++ b/jetty-spring/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-spring diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 9c34bcd1078..fb15e4e7a92 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-start diff --git a/jetty-unixsocket/pom.xml b/jetty-unixsocket/pom.xml index 1cc142a97cf..454ee582bcf 100644 --- a/jetty-unixsocket/pom.xml +++ b/jetty-unixsocket/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-unixsocket diff --git a/jetty-util-ajax/pom.xml b/jetty-util-ajax/pom.xml index 53bdcca695e..cf1cd084c11 100644 --- a/jetty-util-ajax/pom.xml +++ b/jetty-util-ajax/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-util-ajax diff --git a/jetty-util/pom.xml b/jetty-util/pom.xml index cf98fb8566b..a428ec6e985 100644 --- a/jetty-util/pom.xml +++ b/jetty-util/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-util diff --git a/jetty-webapp/pom.xml b/jetty-webapp/pom.xml index 275c5febb47..516df08336b 100644 --- a/jetty-webapp/pom.xml +++ b/jetty-webapp/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-webapp diff --git a/jetty-websocket/javax-websocket-client-impl/pom.xml b/jetty-websocket/javax-websocket-client-impl/pom.xml index b7df9e27860..1d5bd11f43c 100644 --- a/jetty-websocket/javax-websocket-client-impl/pom.xml +++ b/jetty-websocket/javax-websocket-client-impl/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/javax-websocket-server-impl/pom.xml b/jetty-websocket/javax-websocket-server-impl/pom.xml index 42b3700471c..4f830672efe 100644 --- a/jetty-websocket/javax-websocket-server-impl/pom.xml +++ b/jetty-websocket/javax-websocket-server-impl/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/jetty-websocket-tests/pom.xml b/jetty-websocket/jetty-websocket-tests/pom.xml index cf211116780..427ca3f6d71 100644 --- a/jetty-websocket/jetty-websocket-tests/pom.xml +++ b/jetty-websocket/jetty-websocket-tests/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index d64de08be04..c68098170c1 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -3,7 +3,7 @@ jetty-project org.eclipse.jetty - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/websocket-api/pom.xml b/jetty-websocket/websocket-api/pom.xml index 1917cc3671e..caef2d7427c 100644 --- a/jetty-websocket/websocket-api/pom.xml +++ b/jetty-websocket/websocket-api/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/websocket-client/pom.xml b/jetty-websocket/websocket-client/pom.xml index 0339ce5e92d..a6d3e0926c7 100644 --- a/jetty-websocket/websocket-client/pom.xml +++ b/jetty-websocket/websocket-client/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/websocket-common/pom.xml b/jetty-websocket/websocket-common/pom.xml index a8225873a0b..e301836b307 100644 --- a/jetty-websocket/websocket-common/pom.xml +++ b/jetty-websocket/websocket-common/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/websocket-server/pom.xml b/jetty-websocket/websocket-server/pom.xml index fc81d4f36f3..0f24a948577 100644 --- a/jetty-websocket/websocket-server/pom.xml +++ b/jetty-websocket/websocket-server/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-websocket/websocket-servlet/pom.xml b/jetty-websocket/websocket-servlet/pom.xml index a2bea8efcf4..3b3402d140d 100644 --- a/jetty-websocket/websocket-servlet/pom.xml +++ b/jetty-websocket/websocket-servlet/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.websocket websocket-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/jetty-xml/pom.xml b/jetty-xml/pom.xml index 405b0843332..32836152bab 100644 --- a/jetty-xml/pom.xml +++ b/jetty-xml/pom.xml @@ -2,7 +2,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jetty-xml diff --git a/pom.xml b/pom.xml index b7d0a991c73..f46bfd8e471 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT Jetty :: Project The Eclipse Jetty Project pom diff --git a/tests/pom.xml b/tests/pom.xml index 2c399a0c77e..7f484aea18c 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty jetty-project - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml org.eclipse.jetty.tests diff --git a/tests/test-continuation/pom.xml b/tests/test-continuation/pom.xml index 384786bac12..bb383b3426b 100644 --- a/tests/test-continuation/pom.xml +++ b/tests/test-continuation/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/tests/test-distribution/pom.xml b/tests/test-distribution/pom.xml index 1bbcd8b131c..f488019325a 100644 --- a/tests/test-distribution/pom.xml +++ b/tests/test-distribution/pom.xml @@ -2,7 +2,7 @@ tests-parent org.eclipse.jetty.tests - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-http-client-transport/pom.xml b/tests/test-http-client-transport/pom.xml index 2d2acd0842e..2b8a2fd9324 100644 --- a/tests/test-http-client-transport/pom.xml +++ b/tests/test-http-client-transport/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml index 6dc699bae03..fe6cf597a5d 100644 --- a/tests/test-integration/pom.xml +++ b/tests/test-integration/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 test-integration diff --git a/tests/test-jmx/jmx-webapp-it/pom.xml b/tests/test-jmx/jmx-webapp-it/pom.xml index 918bae001ef..f3837572a1d 100644 --- a/tests/test-jmx/jmx-webapp-it/pom.xml +++ b/tests/test-jmx/jmx-webapp-it/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-jmx-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 jmx-webapp-it diff --git a/tests/test-jmx/jmx-webapp/pom.xml b/tests/test-jmx/jmx-webapp/pom.xml index 2f0f3d49346..f07e5ae684b 100644 --- a/tests/test-jmx/jmx-webapp/pom.xml +++ b/tests/test-jmx/jmx-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-jmx-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT jmx-webapp war diff --git a/tests/test-jmx/pom.xml b/tests/test-jmx/pom.xml index 33a2fab6a66..e4f40c7901b 100644 --- a/tests/test-jmx/pom.xml +++ b/tests/test-jmx/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 test-jmx-parent diff --git a/tests/test-loginservice/pom.xml b/tests/test-loginservice/pom.xml index 4cf3f85e9e5..cefcc7dfcee 100644 --- a/tests/test-loginservice/pom.xml +++ b/tests/test-loginservice/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-loginservice Jetty Tests :: Login Service diff --git a/tests/test-quickstart/pom.xml b/tests/test-quickstart/pom.xml index 3e4cfbfd78c..53402a35c5b 100644 --- a/tests/test-quickstart/pom.xml +++ b/tests/test-quickstart/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/tests/test-sessions/pom.xml b/tests/test-sessions/pom.xml index e2a353c045d..cc5fa73ee31 100644 --- a/tests/test-sessions/pom.xml +++ b/tests/test-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-sessions-parent Jetty Tests :: Sessions :: Parent diff --git a/tests/test-sessions/test-file-sessions/pom.xml b/tests/test-sessions/test-file-sessions/pom.xml index febc24f80b3..05e9cf030ce 100644 --- a/tests/test-sessions/test-file-sessions/pom.xml +++ b/tests/test-sessions/test-file-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-file-sessions Jetty Tests :: Sessions :: File diff --git a/tests/test-sessions/test-gcloud-sessions/pom.xml b/tests/test-sessions/test-gcloud-sessions/pom.xml index e740ea941b6..b09b7bc8179 100644 --- a/tests/test-sessions/test-gcloud-sessions/pom.xml +++ b/tests/test-sessions/test-gcloud-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-gcloud-sessions Jetty Tests :: Sessions :: GCloud diff --git a/tests/test-sessions/test-hazelcast-sessions/pom.xml b/tests/test-sessions/test-hazelcast-sessions/pom.xml index a4164dc4f62..b38e8961233 100644 --- a/tests/test-sessions/test-hazelcast-sessions/pom.xml +++ b/tests/test-sessions/test-hazelcast-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-hazelcast-sessions Jetty Tests :: Sessions :: Hazelcast diff --git a/tests/test-sessions/test-infinispan-sessions/pom.xml b/tests/test-sessions/test-infinispan-sessions/pom.xml index f42af52e40c..e51920e3276 100644 --- a/tests/test-sessions/test-infinispan-sessions/pom.xml +++ b/tests/test-sessions/test-infinispan-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-infinispan-sessions Jetty Tests :: Sessions :: Infinispan diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index fe2c887e8d4..5afd5a55d69 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-jdbc-sessions Jetty Tests :: Sessions :: JDBC diff --git a/tests/test-sessions/test-memcached-sessions/pom.xml b/tests/test-sessions/test-memcached-sessions/pom.xml index f8964fce9b3..015264a0c81 100644 --- a/tests/test-sessions/test-memcached-sessions/pom.xml +++ b/tests/test-sessions/test-memcached-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-memcached-sessions Jetty Tests :: Sessions :: Memcached diff --git a/tests/test-sessions/test-mongodb-sessions/pom.xml b/tests/test-sessions/test-mongodb-sessions/pom.xml index 9bacbc7d259..7ca4b0311e5 100644 --- a/tests/test-sessions/test-mongodb-sessions/pom.xml +++ b/tests/test-sessions/test-mongodb-sessions/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-mongodb-sessions Jetty Tests :: Sessions :: Mongo diff --git a/tests/test-sessions/test-sessions-common/pom.xml b/tests/test-sessions/test-sessions-common/pom.xml index a534e5df8ee..f4dcbc820cd 100644 --- a/tests/test-sessions/test-sessions-common/pom.xml +++ b/tests/test-sessions/test-sessions-common/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-sessions-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-sessions-common Jetty Tests :: Sessions :: Common diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 4bb674b1469..f28bb41696e 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests tests-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml test-webapps-parent diff --git a/tests/test-webapps/test-cdi-common-webapp/pom.xml b/tests/test-webapps/test-cdi-common-webapp/pom.xml index be0ad0aeae3..cfbce8e433e 100644 --- a/tests/test-webapps/test-cdi-common-webapp/pom.xml +++ b/tests/test-webapps/test-cdi-common-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-webapps/test-felix-webapp/pom.xml b/tests/test-webapps/test-felix-webapp/pom.xml index ed58abb0fbe..921d8b8a20c 100644 --- a/tests/test-webapps/test-felix-webapp/pom.xml +++ b/tests/test-webapps/test-felix-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-webapps/test-http2-webapp/pom.xml b/tests/test-webapps/test-http2-webapp/pom.xml index a3b84d89b4f..6124c78844d 100644 --- a/tests/test-webapps/test-http2-webapp/pom.xml +++ b/tests/test-webapps/test-http2-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-webapps/test-jaas-webapp/pom.xml b/tests/test-webapps/test-jaas-webapp/pom.xml index d6f2251b982..0bf1980f984 100644 --- a/tests/test-webapps/test-jaas-webapp/pom.xml +++ b/tests/test-webapps/test-jaas-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-jaas-webapp Jetty Tests :: WebApp :: JAAS diff --git a/tests/test-webapps/test-jetty-webapp/pom.xml b/tests/test-webapps/test-jetty-webapp/pom.xml index c7383f610fd..dde6c38cee8 100644 --- a/tests/test-webapps/test-jetty-webapp/pom.xml +++ b/tests/test-webapps/test-jetty-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/tests/test-webapps/test-jndi-webapp/pom.xml b/tests/test-webapps/test-jndi-webapp/pom.xml index 848eae6c11e..5926d0c191b 100644 --- a/tests/test-webapps/test-jndi-webapp/pom.xml +++ b/tests/test-webapps/test-jndi-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-jndi-webapp Jetty Tests :: WebApp :: JNDI diff --git a/tests/test-webapps/test-mock-resources/pom.xml b/tests/test-webapps/test-mock-resources/pom.xml index c9db8291d53..83f0ccf406b 100644 --- a/tests/test-webapps/test-mock-resources/pom.xml +++ b/tests/test-webapps/test-mock-resources/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT Jetty Tests :: WebApp :: Mock Resources test-mock-resources diff --git a/tests/test-webapps/test-owb-cdi-webapp/pom.xml b/tests/test-webapps/test-owb-cdi-webapp/pom.xml index c6819695b22..38fa5d0084b 100644 --- a/tests/test-webapps/test-owb-cdi-webapp/pom.xml +++ b/tests/test-webapps/test-owb-cdi-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 diff --git a/tests/test-webapps/test-proxy-webapp/pom.xml b/tests/test-webapps/test-proxy-webapp/pom.xml index acae710987a..9af777ed222 100644 --- a/tests/test-webapps/test-proxy-webapp/pom.xml +++ b/tests/test-webapps/test-proxy-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT ../pom.xml 4.0.0 diff --git a/tests/test-webapps/test-servlet-spec/pom.xml b/tests/test-webapps/test-servlet-spec/pom.xml index 1e44e3e3581..021892c725c 100644 --- a/tests/test-webapps/test-servlet-spec/pom.xml +++ b/tests/test-webapps/test-servlet-spec/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-servlet-spec-parent Jetty Tests :: Spec Test WebApp :: Parent diff --git a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml index 229b3e9558f..4a0fcbd86f8 100644 --- a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-container-initializer jar diff --git a/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml b/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml index ede32dfcc05..b5090948173 100644 --- a/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-spec-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT Jetty Tests :: Webapps :: Spec Webapp test-spec-webapp diff --git a/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml b/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml index a5e54b009e7..90973abebb1 100644 --- a/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-web-fragment/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-servlet-spec-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT Jetty Tests :: WebApp :: Servlet Spec :: Fragment Jar diff --git a/tests/test-webapps/test-simple-webapp/pom.xml b/tests/test-webapps/test-simple-webapp/pom.xml index 16289299d84..83f80b9470b 100644 --- a/tests/test-webapps/test-simple-webapp/pom.xml +++ b/tests/test-webapps/test-simple-webapp/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-simple-webapp diff --git a/tests/test-webapps/test-webapp-rfc2616/pom.xml b/tests/test-webapps/test-webapp-rfc2616/pom.xml index 3dbc91e7436..aade486f5d9 100644 --- a/tests/test-webapps/test-webapp-rfc2616/pom.xml +++ b/tests/test-webapps/test-webapp-rfc2616/pom.xml @@ -4,7 +4,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT test-webapp-rfc2616 Jetty Tests :: WebApp :: RFC2616 diff --git a/tests/test-webapps/test-weld-cdi-webapp/pom.xml b/tests/test-webapps/test-weld-cdi-webapp/pom.xml index 69164f00955..473d90e6011 100644 --- a/tests/test-webapps/test-weld-cdi-webapp/pom.xml +++ b/tests/test-webapps/test-weld-cdi-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.tests test-webapps-parent - 9.4.29.v20200521 + 9.4.30-SNAPSHOT 4.0.0 From 74f9b464a6a7c3ddbb026988a0e490607f171870 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Fri, 22 May 2020 10:49:42 +1000 Subject: [PATCH 60/77] Issue #4873 - generalize test for all ThreadPools Signed-off-by: Lachlan Roberts --- .../util/thread/AbstractThreadPoolTest.java | 28 +++++++++++++++++++ .../util/thread/ExecutorThreadPoolTest.java | 24 ---------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java index cfdd556f063..c321d4f4aa5 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java @@ -18,7 +18,11 @@ package org.eclipse.jetty.util.thread; +import java.time.Duration; + import org.eclipse.jetty.util.ProcessorUtils; +import org.eclipse.jetty.util.component.ContainerLifeCycle; +import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterAll; @@ -26,6 +30,8 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.fail; public abstract class AbstractThreadPoolTest @@ -87,4 +93,26 @@ public abstract class AbstractThreadPoolTest assertThat(pool.getMaxThreads(), Matchers.is(3)); } + + @Test + public void testJoinWithStopTimeout() + { + // ThreadPool must be an implement ContainerLifeCycle for this test to be valid. + SizedThreadPool threadPool = newPool(3); + if (!(threadPool instanceof ContainerLifeCycle)) + return; + + final long stopTimeout = 100; + ((ContainerLifeCycle)threadPool).setStopTimeout(100); + LifeCycle.start(threadPool); + + // Verify that join does not timeout after waiting twice the stopTimeout. + assertThrows(Throwable.class, () -> + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), threadPool::join) + ); + + // After stopping the ThreadPool join should unblock. + LifeCycle.stop(threadPool); + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), threadPool::join); + } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java index a495d719bb0..95ab6a22aab 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ExecutorThreadPoolTest.java @@ -18,13 +18,7 @@ package org.eclipse.jetty.util.thread; -import java.time.Duration; - import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; public class ExecutorThreadPoolTest extends AbstractThreadPoolTest { @@ -33,22 +27,4 @@ public class ExecutorThreadPoolTest extends AbstractThreadPoolTest { return new ExecutorThreadPool(max); } - - @Test - public void testJoin() throws Exception - { - final long stopTimeout = 100; - ExecutorThreadPool executorThreadPool = new ExecutorThreadPool(10); - executorThreadPool.setStopTimeout(stopTimeout); - executorThreadPool.start(); - - // Verify that join does not timeout after waiting twice the stopTimeout. - assertThrows(Throwable.class, () -> - assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), executorThreadPool::join) - ); - - // After stopping the ThreadPool join should unblock. - executorThreadPool.stop(); - assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), executorThreadPool::join); - } } From 28a588b8bd7c08499c9a695e822b961919ab443a Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 25 May 2020 12:27:49 +1000 Subject: [PATCH 61/77] Issue #4903 - Better errors for non public endpoints Signed-off-by: Lachlan Roberts --- .../websocket/jsr356/server/JsrCreator.java | 3 +- .../jsr356/server/ServerContainer.java | 55 ++++--- .../jsr356/server/PrivateEndpointTest.java | 147 ++++++++++++++++++ 3 files changed, 178 insertions(+), 27 deletions(-) create mode 100644 jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java index aa5341d7ffe..990ebc25ef0 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java @@ -159,8 +159,7 @@ public class JsrCreator implements WebSocketCreator } catch (InstantiationException e) { - if (LOG.isDebugEnabled()) - LOG.debug("Unable to create websocket: " + config.getEndpointClass().getName(), e); + LOG.warn("Unable to create websocket: " + config.getEndpointClass().getName(), e); return null; } } diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index 9db239b7905..6365d92be71 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.websocket.jsr356.server; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; @@ -137,6 +138,9 @@ public class ServerContainer extends ClientContainer implements javax.websocket. private void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException { + if (!Modifier.isPublic(metadata.getEndpointClass().getModifiers())) + throw new DeploymentException("Class modifier must be public"); + JsrCreator creator = new JsrCreator(this, metadata, this.configuration.getFactory().getExtensionFactory()); this.configuration.addMapping("uri-template|" + metadata.getPath(), creator); } @@ -191,35 +195,36 @@ public class ServerContainer extends ClientContainer implements javax.websocket. public ServerEndpointMetadata getServerEndpointMetadata(final Class endpoint, final ServerEndpointConfig config) throws DeploymentException { - ServerEndpointMetadata metadata = null; + try + { + ServerEndpointMetadata metadata; + ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class); + if (anno != null) + { + // Annotated takes precedence here + AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(this, endpoint, config); + AnnotatedEndpointScanner scanner = new AnnotatedEndpointScanner<>(ametadata); + metadata = ametadata; + scanner.scan(); + } + else if (Endpoint.class.isAssignableFrom(endpoint)) + { + // extends Endpoint + @SuppressWarnings("unchecked") + Class eendpoint = (Class)endpoint; + metadata = new SimpleServerEndpointMetadata(eendpoint, config); + } + else + { + throw new DeploymentException("Unable to identify as valid Endpoint: " + endpoint); + } - ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class); - if (anno != null) - { - // Annotated takes precedence here - AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(this, endpoint, config); - AnnotatedEndpointScanner scanner = new AnnotatedEndpointScanner<>(ametadata); - metadata = ametadata; - scanner.scan(); + return metadata; } - else if (Endpoint.class.isAssignableFrom(endpoint)) + catch (RuntimeException e) { - // extends Endpoint - @SuppressWarnings("unchecked") - Class eendpoint = (Class)endpoint; - metadata = new SimpleServerEndpointMetadata(eendpoint, config); + throw new DeploymentException(e.getMessage(), e); } - else - { - StringBuilder err = new StringBuilder(); - err.append("Not a recognized websocket ["); - err.append(endpoint.getName()); - err.append("] does not extend @").append(ServerEndpoint.class.getName()); - err.append(" or extend from ").append(Endpoint.class.getName()); - throw new DeploymentException("Unable to identify as valid Endpoint: " + endpoint); - } - - return metadata; } @Override diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java new file mode 100644 index 00000000000..79d7b771664 --- /dev/null +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java @@ -0,0 +1,147 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.websocket.jsr356.server; + +import javax.websocket.ContainerProvider; +import javax.websocket.DeploymentException; +import javax.websocket.Endpoint; +import javax.websocket.EndpointConfig; +import javax.websocket.MessageHandler; +import javax.websocket.OnMessage; +import javax.websocket.Session; +import javax.websocket.WebSocketContainer; +import javax.websocket.server.ServerEndpoint; +import javax.websocket.server.ServerEndpointConfig; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.util.component.LifeCycle; +import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.instanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class PrivateEndpointTest +{ + private Server server; + private WebSocketContainer client; + private ServletContextHandler contextHandler; + + @BeforeEach + public void before() + { + server = new Server(); + ServerConnector connector = new ServerConnector(server); + server.addConnector(connector); + + contextHandler = new ServletContextHandler(); + contextHandler.setContextPath("/"); + server.setHandler(contextHandler); + client = ContainerProvider.getWebSocketContainer(); + } + + @AfterEach + public void after() throws Exception + { + LifeCycle.stop(client); + server.stop(); + } + + public interface CheckedConsumer + { + void accept(T t) throws DeploymentException; + } + + public void start(CheckedConsumer containerConsumer) throws Exception + { + WebSocketServerContainerInitializer.configure(contextHandler, (context, container) -> containerConsumer.accept(container)); + server.start(); + } + + private static class ServerSocket extends Endpoint implements MessageHandler.Whole + { + @Override + public void onOpen(Session session, EndpointConfig config) + { + session.addMessageHandler(this); + } + + @Override + public void onMessage(String message) + { + } + } + + @ServerEndpoint("/annotated") + private static class AnnotatedServerSocket + { + @OnMessage + public void onMessage(String message) + { + } + } + + @ServerEndpoint("/annotatedMethod") + public static class AnnotatedServerMethod + { + @OnMessage + private void onMessage(String message) + { + } + } + + @Test + public void testEndpoint() + { + RuntimeException error = assertThrows(RuntimeException.class, () -> + start(container -> container.addEndpoint(ServerEndpointConfig.Builder.create(ServerSocket.class, "/").build()))); + + assertThat(error.getCause(), instanceOf(DeploymentException.class)); + DeploymentException deploymentException = (DeploymentException)error.getCause(); + assertThat(deploymentException.getMessage(), containsString("Class modifier must be public")); + } + + @Test + public void testAnnotatedEndpoint() + { + RuntimeException error = assertThrows(RuntimeException.class, () -> + start(container -> container.addEndpoint(AnnotatedServerSocket.class))); + + assertThat(error.getCause(), instanceOf(DeploymentException.class)); + DeploymentException deploymentException = (DeploymentException)error.getCause(); + assertThat(deploymentException.getMessage(), containsString("Class modifier must be public")); + } + + @Test + public void testAnnotatedMethod() + { + RuntimeException error = assertThrows(RuntimeException.class, () -> + start(container -> container.addEndpoint(AnnotatedServerMethod.class))); + + assertThat(error.getCause(), instanceOf(DeploymentException.class)); + DeploymentException deploymentException = (DeploymentException)error.getCause(); + assertThat(deploymentException.getMessage(), containsString("Method modifier must be public")); + } +} From add00c9dd8750c4e97508ac0ab6fbe84f9d0b82a Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 25 May 2020 13:57:41 +1000 Subject: [PATCH 62/77] Issue #4903 - check endpoint class is default constructable Signed-off-by: Lachlan Roberts --- .../jsr356/server/ServerContainer.java | 6 ++-- .../jsr356/server/PrivateEndpointTest.java | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index 6365d92be71..f0cca5e66af 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -18,7 +18,6 @@ package org.eclipse.jetty.websocket.jsr356.server; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; @@ -35,6 +34,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.common.events.EventDriverFactory; +import org.eclipse.jetty.websocket.common.util.ReflectUtils; import org.eclipse.jetty.websocket.jsr356.ClientContainer; import org.eclipse.jetty.websocket.jsr356.JsrSessionFactory; import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner; @@ -138,8 +138,8 @@ public class ServerContainer extends ClientContainer implements javax.websocket. private void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException { - if (!Modifier.isPublic(metadata.getEndpointClass().getModifiers())) - throw new DeploymentException("Class modifier must be public"); + if (!ReflectUtils.isDefaultConstructable(metadata.getEndpointClass())) + throw new DeploymentException("Cannot access default constructor for the Endpoint class"); JsrCreator creator = new JsrCreator(this, metadata, this.configuration.getFactory().getExtensionFactory()); this.configuration.addMapping("uri-template|" + metadata.getPath(), creator); diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java index 79d7b771664..33e7b349590 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PrivateEndpointTest.java @@ -94,6 +94,21 @@ public class PrivateEndpointTest } } + @SuppressWarnings("InnerClassMayBeStatic") + public class ServerSocketNonStatic extends Endpoint implements MessageHandler.Whole + { + @Override + public void onOpen(Session session, EndpointConfig config) + { + session.addMessageHandler(this); + } + + @Override + public void onMessage(String message) + { + } + } + @ServerEndpoint("/annotated") private static class AnnotatedServerSocket { @@ -120,7 +135,18 @@ public class PrivateEndpointTest assertThat(error.getCause(), instanceOf(DeploymentException.class)); DeploymentException deploymentException = (DeploymentException)error.getCause(); - assertThat(deploymentException.getMessage(), containsString("Class modifier must be public")); + assertThat(deploymentException.getMessage(), containsString("Cannot access default constructor for the Endpoint class")); + } + + @Test + public void testInnerEndpoint() + { + RuntimeException error = assertThrows(RuntimeException.class, () -> + start(container -> container.addEndpoint(ServerEndpointConfig.Builder.create(ServerSocketNonStatic.class, "/").build()))); + + assertThat(error.getCause(), instanceOf(DeploymentException.class)); + DeploymentException deploymentException = (DeploymentException)error.getCause(); + assertThat(deploymentException.getMessage(), containsString("Cannot access default constructor for the Endpoint class")); } @Test @@ -131,7 +157,7 @@ public class PrivateEndpointTest assertThat(error.getCause(), instanceOf(DeploymentException.class)); DeploymentException deploymentException = (DeploymentException)error.getCause(); - assertThat(deploymentException.getMessage(), containsString("Class modifier must be public")); + assertThat(deploymentException.getMessage(), containsString("Cannot access default constructor for the Endpoint class")); } @Test @@ -144,4 +170,4 @@ public class PrivateEndpointTest DeploymentException deploymentException = (DeploymentException)error.getCause(); assertThat(deploymentException.getMessage(), containsString("Method modifier must be public")); } -} +} \ No newline at end of file From 470d948504daef688da39a8038a5ee8da6ff43e4 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 26 May 2020 09:35:17 +1000 Subject: [PATCH 63/77] Issue #4903 - changes from review Signed-off-by: Lachlan Roberts --- .../jetty/websocket/jsr356/server/ServerContainer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index f0cca5e66af..167c4e2befe 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -130,7 +130,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket. { if (deferredEndpointClasses == null) { - deferredEndpointClasses = new ArrayList>(); + deferredEndpointClasses = new ArrayList<>(); } deferredEndpointClasses.add(endpointClass); } @@ -161,7 +161,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket. { if (deferredEndpointConfigs == null) { - deferredEndpointConfigs = new ArrayList(); + deferredEndpointConfigs = new ArrayList<>(); } deferredEndpointConfigs.add(config); } @@ -216,7 +216,10 @@ public class ServerContainer extends ClientContainer implements javax.websocket. } else { - throw new DeploymentException("Unable to identify as valid Endpoint: " + endpoint); + String err = "Not a recognized websocket [" + endpoint.getName() + + "] does not extend @" + ServerEndpoint.class.getName() + + " or extend from " + Endpoint.class.getName(); + throw new DeploymentException(err); } return metadata; From c41560c7cd30f9ce5e79fd307763b1e6f9072817 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 26 May 2020 15:35:39 +1000 Subject: [PATCH 64/77] Issue #4903 - add cause to Exception when creating endpoint instance Signed-off-by: Lachlan Roberts --- .../jsr356/server/ContainerDefaultConfigurator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java index e25916d5170..0fc08fe2622 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java @@ -72,7 +72,10 @@ public final class ContainerDefaultConfigurator extends Configurator } catch (Exception e) { - throw new InstantiationException(String.format("%s: %s", e.getClass().getName(), e.getMessage())); + String errorMsg = String.format("%s: %s", e.getClass().getName(), e.getMessage()); + InstantiationException instantiationException = new InstantiationException(errorMsg); + instantiationException.initCause(e); + throw instantiationException; } } From 5c63b0ef7810634378a977fb9d198558da07d657 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 26 May 2020 17:37:04 +1000 Subject: [PATCH 65/77] Issue #4903 - catch Throwable instead of RuntimeException Signed-off-by: Lachlan Roberts --- .../jetty/websocket/jsr356/server/ServerContainer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index 167c4e2befe..3e2f3492873 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -224,9 +224,11 @@ public class ServerContainer extends ClientContainer implements javax.websocket. return metadata; } - catch (RuntimeException e) + catch (Throwable t) { - throw new DeploymentException(e.getMessage(), e); + if (t instanceof DeploymentException) + throw t; + throw new DeploymentException(t.getMessage(), t); } } From a11c7f554c50dc26d29b4b1d69ee5aabded80960 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 27 May 2020 09:42:44 +1000 Subject: [PATCH 66/77] Issue #4903 - cleanup catch statement from review Signed-off-by: Lachlan Roberts --- .../jetty/websocket/jsr356/server/ServerContainer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java index 3e2f3492873..4e79073c34f 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java @@ -224,10 +224,12 @@ public class ServerContainer extends ClientContainer implements javax.websocket. return metadata; } + catch (DeploymentException e) + { + throw e; + } catch (Throwable t) { - if (t instanceof DeploymentException) - throw t; throw new DeploymentException(t.getMessage(), t); } } From c05bd6c26d036aced86defad8294a3dccd9f8f17 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Sat, 23 May 2020 15:09:28 +1000 Subject: [PATCH 67/77] use testcontainers/docker to run jdbc sessions tests with Mariadb remote Signed-off-by: olivier lamy --- .../jetty/server/session/DatabaseAdaptor.java | 25 +++- pom.xml | 5 +- .../test-sessions/test-jdbc-sessions/pom.xml | 63 +++++++++- .../jetty/server/session/JdbcTestHelper.java | 112 ++++++++++++------ .../session/SessionTableSchemaTest.java | 47 +++++--- .../test/resources/simplelogger.properties | 3 + 6 files changed, 202 insertions(+), 53 deletions(-) create mode 100644 tests/test-sessions/test-jdbc-sessions/src/test/resources/simplelogger.properties diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java index 82f39cf081c..4bcf2217530 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java @@ -60,6 +60,8 @@ public class DatabaseAdaptor private String _connectionUrl; private Driver _driver; private DataSource _datasource; + private String _username; + private String _password; private String _jndiName; @@ -257,6 +259,26 @@ public class DatabaseAdaptor return _connectionUrl; } + public String getUsername() + { + return _username; + } + + public void setUsername(String username) + { + this._username = username; + } + + public String getPassword() + { + return _password; + } + + public void setPassword(String password) + { + this._password = password; + } + public void initialize() throws Exception { @@ -302,7 +324,8 @@ public class DatabaseAdaptor if (_datasource != null) return _datasource.getConnection(); else - return DriverManager.getConnection(_connectionUrl); + return _username == null ? DriverManager.getConnection(_connectionUrl) + : DriverManager.getConnection(_connectionUrl, _username, _password); } /** diff --git a/pom.xml b/pom.xml index f46bfd8e471..91559f53c20 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,7 @@ ${project.build.directory}/local-repo src/it/settings.xml 0 + 1.14.2 @@ -1083,12 +1084,12 @@ org.testcontainers testcontainers - 1.14.1 + ${testcontainers.version} org.testcontainers junit-jupiter - 1.14.1 + ${testcontainers.version} diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 5afd5a55d69..3bec9345b71 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -8,9 +8,9 @@ test-jdbc-sessions Jetty Tests :: Sessions :: JDBC - http://www.eclipse.org/jetty ${project.groupId}.sessions.jdbc + 10.3.6 @@ -22,6 +22,15 @@ true + + org.apache.maven.plugins + maven-surefire-plugin + + + false + + + @@ -60,5 +69,57 @@ jetty-test-helper test + + org.testcontainers + testcontainers + test + + + org.testcontainers + mariadb + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + test + + + org.slf4j + slf4j-simple + test + + + org.mariadb.jdbc + mariadb-java-client + 2.6.0 + test + + + + remote-session-tests + + + mariadb.enabled + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${mariadb.docker.version} + true + + + + + + + diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java index ec9b2235e99..0affc485e3f 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java @@ -33,6 +33,11 @@ import java.util.Set; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.MariaDBContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -42,9 +47,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class JdbcTestHelper { - public static final String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; - public static final String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true"; - public static final String DEFAULT_SHUTDOWN_URL = "jdbc:derby:memory:sessions;drop=true"; + public static final boolean USE_MARIADB = Boolean.getBoolean("mariadb.enabled"); + + private static final Logger LOG = LoggerFactory.getLogger(JdbcTestHelper.class); + private static final Logger MARIADB_LOG = LoggerFactory.getLogger("org.eclipse.jetty.server.session.MariaDbLogs"); + + public static String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; + public static String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true"; + public static String DEFAULT_SHUTDOWN_URL = "jdbc:derby:memory:sessions;drop=true"; public static final int STALE_INTERVAL = 1; public static final String EXPIRY_COL = "extime"; @@ -60,6 +70,33 @@ public class JdbcTestHelper public static final String COOKIE_COL = "cooktime"; public static final String CREATE_COL = "ctime"; + static MariaDBContainer MARIAD_DB = + new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6")) + .withDatabaseName("sessions"); + + static + { + if (USE_MARIADB) + { + try + { + long start = System.currentTimeMillis(); + MARIAD_DB.withLogConsumer(new Slf4jLogConsumer(MARIADB_LOG)).start(); + String containerIpAddress = MARIAD_DB.getContainerIpAddress(); + int mariadbPort = MARIAD_DB.getMappedPort(3306); + DEFAULT_CONNECTION_URL = MARIAD_DB.getJdbcUrl(); + DRIVER_CLASS = MARIAD_DB.getDriverClassName(); + LOG.info("Mariadb container started for {}:{} - {}ms", containerIpAddress, mariadbPort, + System.currentTimeMillis() - start); + } + catch (Exception e) + { + LOG.error(e.getMessage(), e); + throw new RuntimeException(e.getMessage(), e); + } + } + } + static { System.setProperty("derby.system.home", MavenTestingUtils.getTargetFile("test-derby").getAbsolutePath()); @@ -68,6 +105,14 @@ public class JdbcTestHelper public static void shutdown(String connectionUrl) throws Exception { + if (USE_MARIADB) + { + try (Connection connection = getConnection()) + { + connection.prepareStatement("truncate table " + TABLE).executeUpdate(); + } + return; + } if (connectionUrl == null) connectionUrl = DEFAULT_SHUTDOWN_URL; @@ -84,14 +129,34 @@ public class JdbcTestHelper } } + public static DatabaseAdaptor buildDatabaseAdaptor() + { + DatabaseAdaptor da = new DatabaseAdaptor(); + if (USE_MARIADB) + { + da.setUsername(MARIAD_DB.getUsername()); + da.setPassword(MARIAD_DB.getPassword()); + } + da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL); + return da; + } + + public static Connection getConnection() + throws Exception + { + Class.forName(DRIVER_CLASS); + return USE_MARIADB ? DriverManager.getConnection(DEFAULT_CONNECTION_URL, + MARIAD_DB.getUsername(), + MARIAD_DB.getPassword()) + : DriverManager.getConnection(DEFAULT_CONNECTION_URL); + } + /** * @return a fresh JDBCSessionDataStoreFactory */ public static SessionDataStoreFactory newSessionDataStoreFactory() { - DatabaseAdaptor da = new DatabaseAdaptor(); - da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL); - return newSessionDataStoreFactory(da); + return newSessionDataStoreFactory(buildDatabaseAdaptor()); } public static SessionDataStoreFactory newSessionDataStoreFactory(DatabaseAdaptor da) @@ -123,8 +188,7 @@ public class JdbcTestHelper public static void prepareTables() throws SQLException { - DatabaseAdaptor da = new DatabaseAdaptor(); - da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL); + DatabaseAdaptor da = buildDatabaseAdaptor(); JDBCSessionDataStore.SessionTableSchema sessionTableSchema = newSessionTableSchema(); sessionTableSchema.setDatabaseAdaptor(da); @@ -163,11 +227,8 @@ public class JdbcTestHelper public static boolean existsInSessionTable(String id, boolean verbose) throws Exception { - Class.forName(DRIVER_CLASS); - Connection con = null; - try + try (Connection con = getConnection()) { - con = DriverManager.getConnection(DEFAULT_CONNECTION_URL); PreparedStatement statement = con.prepareStatement("select * from " + TABLE + " where " + ID_COL + " = ?"); @@ -186,21 +247,15 @@ public class JdbcTestHelper else return result.next(); } - finally - { - if (con != null) - con.close(); - } } @SuppressWarnings("unchecked") public static boolean checkSessionPersisted(SessionData data) throws Exception { - Class.forName(DRIVER_CLASS); PreparedStatement statement = null; ResultSet result = null; - try (Connection con = DriverManager.getConnection(DEFAULT_CONNECTION_URL);) + try (Connection con = getConnection()) { statement = con.prepareStatement("select * from " + TABLE + " where " + ID_COL + " = ? and " + CONTEXT_COL + @@ -264,9 +319,7 @@ public class JdbcTestHelper public static void insertSession(SessionData data) throws Exception { - - Class.forName(DRIVER_CLASS); - try (Connection con = DriverManager.getConnection(DEFAULT_CONNECTION_URL);) + try (Connection con = getConnection()) { PreparedStatement statement = con.prepareStatement("insert into " + TABLE + " (" + ID_COL + ", " + CONTEXT_COL + ", virtualHost, " + LAST_NODE_COL + @@ -310,8 +363,7 @@ public class JdbcTestHelper long cookieSet, long lastSaved) throws Exception { - Class.forName(DRIVER_CLASS); - try (Connection con = DriverManager.getConnection(DEFAULT_CONNECTION_URL);) + try (Connection con = getConnection()) { PreparedStatement statement = con.prepareStatement("insert into " + TABLE + " (" + ID_COL + ", " + CONTEXT_COL + ", virtualHost, " + LAST_NODE_COL + @@ -343,12 +395,9 @@ public class JdbcTestHelper public static Set getSessionIds() throws Exception { - HashSet ids = new HashSet(); - Class.forName(DRIVER_CLASS); - Connection con = null; - try + HashSet ids = new HashSet<>(); + try (Connection con = getConnection()) { - con = DriverManager.getConnection(DEFAULT_CONNECTION_URL); PreparedStatement statement = con.prepareStatement("select " + ID_COL + " from " + TABLE); ResultSet result = statement.executeQuery(); while (result.next()) @@ -357,10 +406,5 @@ public class JdbcTestHelper } return ids; } - finally - { - if (con != null) - con.close(); - } } } diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java index a6755e7754f..09f8e728c8d 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.eclipse.jetty.server.session.JdbcTestHelper.USE_MARIADB; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -60,6 +61,11 @@ public class SessionTableSchemaTest return true; //test special handling for oracle } }; + if (USE_MARIADB) + { + _da.setUsername(JdbcTestHelper.MARIAD_DB.getUsername()); + _da.setPassword(JdbcTestHelper.MARIAD_DB.getPassword()); + } _da.setDriverInfo(JdbcTestHelper.DRIVER_CLASS, JdbcTestHelper.DEFAULT_CONNECTION_URL); _tableSchema = JdbcTestHelper.newSessionTableSchema(); _tableSchema.setDatabaseAdaptor(_da); @@ -84,8 +90,7 @@ public class SessionTableSchemaTest public static void insertSessionWithoutAttributes(String id, String contextPath, String vhost) throws Exception { - Class.forName(JdbcTestHelper.DRIVER_CLASS); - try (Connection con = DriverManager.getConnection(JdbcTestHelper.DEFAULT_CONNECTION_URL);) + try (Connection con = JdbcTestHelper.getConnection()) { PreparedStatement statement = con.prepareStatement("insert into " + JdbcTestHelper.TABLE + " (" + JdbcTestHelper.ID_COL + ", " + JdbcTestHelper.CONTEXT_COL + ", virtualHost, " + JdbcTestHelper.LAST_NODE_COL + @@ -119,8 +124,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); //test if it can be seen try (Connection con = _da.getConnection()) @@ -130,7 +137,7 @@ public class SessionTableSchemaTest handler.setContextPath("/"); SessionContext sc = new SessionContext("0", handler.getServletContext()); //test the load statement - PreparedStatement s = _tableSchema.getLoadStatement(con, "1234", sc); + PreparedStatement s = _tableSchema.getLoadStatement(con, id, sc); ResultSet rs = s.executeQuery(); assertTrue(rs.next()); } @@ -144,8 +151,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); //test if it can be seen try (Connection con = _da.getConnection()) @@ -154,7 +163,7 @@ public class SessionTableSchemaTest handler.setContextPath("/"); SessionContext sc = new SessionContext("0", handler.getServletContext()); PreparedStatement s = _tableSchema.getCheckSessionExistsStatement(con, sc); - s.setString(1, "1234"); + s.setString(1, id); ResultSet rs = s.executeQuery(); assertTrue(rs.next()); } @@ -168,8 +177,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); //test if it can be deleted try (Connection con = _da.getConnection()) @@ -177,10 +188,10 @@ public class SessionTableSchemaTest ContextHandler handler = new ContextHandler(); handler.setContextPath("/"); SessionContext sc = new SessionContext("0", handler.getServletContext()); - PreparedStatement s = _tableSchema.getDeleteStatement(con, "1234", sc); + PreparedStatement s = _tableSchema.getDeleteStatement(con, id, sc); assertEquals(1, s.executeUpdate()); - assertFalse(JdbcTestHelper.existsInSessionTable("1234", false)); + assertFalse(JdbcTestHelper.existsInSessionTable(id, false)); } } @@ -192,8 +203,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); try (Connection con = _da.getConnection()) { @@ -206,7 +219,7 @@ public class SessionTableSchemaTest (System.currentTimeMillis() + 100L)); ResultSet rs = s.executeQuery(); assertTrue(rs.next()); - assertEquals("1234", rs.getString(1)); + assertEquals(id, rs.getString(1)); } } @@ -218,8 +231,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); try (Connection con = _da.getConnection()) { @@ -231,7 +246,7 @@ public class SessionTableSchemaTest (System.currentTimeMillis() + 100L)); ResultSet rs = s.executeQuery(); assertTrue(rs.next()); - assertEquals("1234", rs.getString(1)); + assertEquals(id, rs.getString(1)); } } @@ -243,8 +258,10 @@ public class SessionTableSchemaTest _da.initialize(); _tableSchema.prepareTables(); + String id = Long.toString(System.nanoTime()); + //insert a fake session at the root context - insertSessionWithoutAttributes("1234", "/", "0.0.0.0"); + insertSessionWithoutAttributes(id, "/", "0.0.0.0"); try (Connection con = _da.getConnection()) { @@ -252,7 +269,7 @@ public class SessionTableSchemaTest handler.setContextPath("/"); SessionContext sc = new SessionContext("0", handler.getServletContext()); PreparedStatement s = _tableSchema.getUpdateStatement(con, - "1234", + id, sc); s.setString(1, "0");//should be my node id diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/resources/simplelogger.properties b/tests/test-sessions/test-jdbc-sessions/src/test/resources/simplelogger.properties new file mode 100644 index 00000000000..6f00400db97 --- /dev/null +++ b/tests/test-sessions/test-jdbc-sessions/src/test/resources/simplelogger.properties @@ -0,0 +1,3 @@ +org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.MariaDbLogs=error +org.slf4j.simpleLogger.log.org.eclipse.jetty.server.session.JdbcTestHelper=info From 1249763aadaea73e64cfefad123ef6237000b936 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Tue, 26 May 2020 15:58:38 +1000 Subject: [PATCH 68/77] remove changes to DatabaseAdaptor with new fields username/password, use our own username/password in maria_db tests Signed-off-by: olivier lamy --- .../jetty/server/session/DatabaseAdaptor.java | 25 +------------------ .../jetty/server/session/JdbcTestHelper.java | 25 ++++++++++--------- .../session/SessionTableSchemaTest.java | 5 ---- 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java index 4bcf2217530..82f39cf081c 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DatabaseAdaptor.java @@ -60,8 +60,6 @@ public class DatabaseAdaptor private String _connectionUrl; private Driver _driver; private DataSource _datasource; - private String _username; - private String _password; private String _jndiName; @@ -259,26 +257,6 @@ public class DatabaseAdaptor return _connectionUrl; } - public String getUsername() - { - return _username; - } - - public void setUsername(String username) - { - this._username = username; - } - - public String getPassword() - { - return _password; - } - - public void setPassword(String password) - { - this._password = password; - } - public void initialize() throws Exception { @@ -324,8 +302,7 @@ public class DatabaseAdaptor if (_datasource != null) return _datasource.getConnection(); else - return _username == null ? DriverManager.getConnection(_connectionUrl) - : DriverManager.getConnection(_connectionUrl, _username, _password); + return DriverManager.getConnection(_connectionUrl); } /** diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java index 0affc485e3f..f4172c24c39 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java @@ -70,9 +70,10 @@ public class JdbcTestHelper public static final String COOKIE_COL = "cooktime"; public static final String CREATE_COL = "ctime"; - static MariaDBContainer MARIAD_DB = - new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6")) - .withDatabaseName("sessions"); + static MariaDBContainer MARIAD_DB; + + static final String MARIA_DB_USER = "beer"; + static final String MARIA_DB_PASSWORD = "pacific_ale"; static { @@ -81,6 +82,11 @@ public class JdbcTestHelper try { long start = System.currentTimeMillis(); + MARIAD_DB = + new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6")) + .withUsername(MARIA_DB_USER) + .withPassword(MARIA_DB_PASSWORD) + .withDatabaseName("sessions"); MARIAD_DB.withLogConsumer(new Slf4jLogConsumer(MARIADB_LOG)).start(); String containerIpAddress = MARIAD_DB.getContainerIpAddress(); int mariadbPort = MARIAD_DB.getMappedPort(3306); @@ -88,6 +94,9 @@ public class JdbcTestHelper DRIVER_CLASS = MARIAD_DB.getDriverClassName(); LOG.info("Mariadb container started for {}:{} - {}ms", containerIpAddress, mariadbPort, System.currentTimeMillis() - start); + DEFAULT_CONNECTION_URL = DEFAULT_CONNECTION_URL + "?user=" + MARIA_DB_USER + + "&password=" + MARIA_DB_PASSWORD; + LOG.info("DEFAULT_CONNECTION_URL: {}", DEFAULT_CONNECTION_URL); } catch (Exception e) { @@ -132,11 +141,6 @@ public class JdbcTestHelper public static DatabaseAdaptor buildDatabaseAdaptor() { DatabaseAdaptor da = new DatabaseAdaptor(); - if (USE_MARIADB) - { - da.setUsername(MARIAD_DB.getUsername()); - da.setPassword(MARIAD_DB.getPassword()); - } da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL); return da; } @@ -145,10 +149,7 @@ public class JdbcTestHelper throws Exception { Class.forName(DRIVER_CLASS); - return USE_MARIADB ? DriverManager.getConnection(DEFAULT_CONNECTION_URL, - MARIAD_DB.getUsername(), - MARIAD_DB.getPassword()) - : DriverManager.getConnection(DEFAULT_CONNECTION_URL); + return DriverManager.getConnection(DEFAULT_CONNECTION_URL); } /** diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java index 09f8e728c8d..4bbd29561b4 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java @@ -61,11 +61,6 @@ public class SessionTableSchemaTest return true; //test special handling for oracle } }; - if (USE_MARIADB) - { - _da.setUsername(JdbcTestHelper.MARIAD_DB.getUsername()); - _da.setPassword(JdbcTestHelper.MARIAD_DB.getPassword()); - } _da.setDriverInfo(JdbcTestHelper.DRIVER_CLASS, JdbcTestHelper.DEFAULT_CONNECTION_URL); _tableSchema = JdbcTestHelper.newSessionTableSchema(); _tableSchema.setDatabaseAdaptor(_da); From 389f46c8263464754489a8675f19f6b0d856412c Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Tue, 26 May 2020 18:32:14 +1000 Subject: [PATCH 69/77] bye bye Derby tests, only use mariadb via container Signed-off-by: olivier lamy --- .../test-sessions/test-jdbc-sessions/pom.xml | 16 +--- .../jetty/server/session/JdbcTestHelper.java | 77 +++++++------------ .../session/SessionTableSchemaTest.java | 2 - 3 files changed, 29 insertions(+), 66 deletions(-) diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index 3bec9345b71..d6fe28174ab 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -26,9 +26,7 @@ org.apache.maven.plugins maven-surefire-plugin - - false - + true @@ -54,16 +52,6 @@ test-sessions-common ${project.version} - - org.apache.derby - derby - test - - - org.apache.derby - derbytools - test - org.eclipse.jetty.toolchain jetty-test-helper @@ -112,9 +100,9 @@ org.apache.maven.plugins maven-surefire-plugin + false ${mariadb.docker.version} - true diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java index f4172c24c39..541f43c69c4 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java @@ -47,14 +47,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class JdbcTestHelper { - public static final boolean USE_MARIADB = Boolean.getBoolean("mariadb.enabled"); - private static final Logger LOG = LoggerFactory.getLogger(JdbcTestHelper.class); private static final Logger MARIADB_LOG = LoggerFactory.getLogger("org.eclipse.jetty.server.session.MariaDbLogs"); - public static String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; - public static String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true"; - public static String DEFAULT_SHUTDOWN_URL = "jdbc:derby:memory:sessions;drop=true"; + public static String DRIVER_CLASS; + public static String DEFAULT_CONNECTION_URL; + public static final int STALE_INTERVAL = 1; public static final String EXPIRY_COL = "extime"; @@ -77,32 +75,29 @@ public class JdbcTestHelper static { - if (USE_MARIADB) + try { - try - { - long start = System.currentTimeMillis(); - MARIAD_DB = - new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6")) - .withUsername(MARIA_DB_USER) - .withPassword(MARIA_DB_PASSWORD) - .withDatabaseName("sessions"); - MARIAD_DB.withLogConsumer(new Slf4jLogConsumer(MARIADB_LOG)).start(); - String containerIpAddress = MARIAD_DB.getContainerIpAddress(); - int mariadbPort = MARIAD_DB.getMappedPort(3306); - DEFAULT_CONNECTION_URL = MARIAD_DB.getJdbcUrl(); - DRIVER_CLASS = MARIAD_DB.getDriverClassName(); - LOG.info("Mariadb container started for {}:{} - {}ms", containerIpAddress, mariadbPort, - System.currentTimeMillis() - start); - DEFAULT_CONNECTION_URL = DEFAULT_CONNECTION_URL + "?user=" + MARIA_DB_USER + - "&password=" + MARIA_DB_PASSWORD; - LOG.info("DEFAULT_CONNECTION_URL: {}", DEFAULT_CONNECTION_URL); - } - catch (Exception e) - { - LOG.error(e.getMessage(), e); - throw new RuntimeException(e.getMessage(), e); - } + long start = System.currentTimeMillis(); + MARIAD_DB = + new MariaDBContainer("mariadb:" + System.getProperty("mariadb.docker.version", "10.3.6")) + .withUsername(MARIA_DB_USER) + .withPassword(MARIA_DB_PASSWORD) + .withDatabaseName("sessions"); + MARIAD_DB.withLogConsumer(new Slf4jLogConsumer(MARIADB_LOG)).start(); + String containerIpAddress = MARIAD_DB.getContainerIpAddress(); + int mariadbPort = MARIAD_DB.getMappedPort(3306); + DEFAULT_CONNECTION_URL = MARIAD_DB.getJdbcUrl(); + DRIVER_CLASS = MARIAD_DB.getDriverClassName(); + LOG.info("Mariadb container started for {}:{} - {}ms", containerIpAddress, mariadbPort, + System.currentTimeMillis() - start); + DEFAULT_CONNECTION_URL = DEFAULT_CONNECTION_URL + "?user=" + MARIA_DB_USER + + "&password=" + MARIA_DB_PASSWORD; + LOG.info("DEFAULT_CONNECTION_URL: {}", DEFAULT_CONNECTION_URL); + } + catch (Exception e) + { + LOG.error(e.getMessage(), e); + throw new RuntimeException(e.getMessage(), e); } } @@ -114,27 +109,9 @@ public class JdbcTestHelper public static void shutdown(String connectionUrl) throws Exception { - if (USE_MARIADB) + try (Connection connection = getConnection()) { - try (Connection connection = getConnection()) - { - connection.prepareStatement("truncate table " + TABLE).executeUpdate(); - } - return; - } - if (connectionUrl == null) - connectionUrl = DEFAULT_SHUTDOWN_URL; - - try - { - DriverManager.getConnection(connectionUrl); - } - catch (SQLException expected) - { - if (!"08006".equals(expected.getSQLState())) - { - throw expected; - } + connection.prepareStatement("truncate table " + TABLE).executeUpdate(); } } diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java index 4bbd29561b4..224d93cde7d 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java @@ -20,7 +20,6 @@ package org.eclipse.jetty.server.session; import java.io.ByteArrayInputStream; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -29,7 +28,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.eclipse.jetty.server.session.JdbcTestHelper.USE_MARIADB; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; From 7cc3573ceb69e52eff272e746050201b03828eeb Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 27 May 2020 07:29:15 +1000 Subject: [PATCH 70/77] remove derby system property Signed-off-by: olivier lamy --- .../org/eclipse/jetty/server/session/JdbcTestHelper.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java index 541f43c69c4..ae951339e36 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestHelper.java @@ -101,11 +101,6 @@ public class JdbcTestHelper } } - static - { - System.setProperty("derby.system.home", MavenTestingUtils.getTargetFile("test-derby").getAbsolutePath()); - } - public static void shutdown(String connectionUrl) throws Exception { From 2b1fa80b63e5e0491830c9871fc67e3d41154d3d Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 27 May 2020 07:35:32 +1000 Subject: [PATCH 71/77] always run the test except if Docker not available Signed-off-by: olivier lamy --- .../test-sessions/test-jdbc-sessions/pom.xml | 29 ++----------------- .../ClusteredInvalidationSessionTest.java | 2 ++ .../session/ClusteredOrphanedSessionTest.java | 2 ++ .../ClusteredSessionMigrationTest.java | 2 ++ .../ClusteredSessionScavengingTest.java | 2 ++ .../session/JDBCSessionDataStoreTest.java | 2 ++ .../ReloadedSessionMissingClassTest.java | 2 ++ .../session/SessionTableSchemaTest.java | 2 ++ .../session/WebAppObjectInSessionTest.java | 2 ++ 9 files changed, 19 insertions(+), 26 deletions(-) diff --git a/tests/test-sessions/test-jdbc-sessions/pom.xml b/tests/test-sessions/test-jdbc-sessions/pom.xml index d6fe28174ab..a99398a0601 100644 --- a/tests/test-sessions/test-jdbc-sessions/pom.xml +++ b/tests/test-sessions/test-jdbc-sessions/pom.xml @@ -26,7 +26,9 @@ org.apache.maven.plugins maven-surefire-plugin - true + + ${mariadb.docker.version} + @@ -85,29 +87,4 @@ test - - - remote-session-tests - - - mariadb.enabled - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - ${mariadb.docker.version} - - - - - - - diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredInvalidationSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredInvalidationSessionTest.java index 5107ed56079..a2d2d3f48ca 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredInvalidationSessionTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredInvalidationSessionTest.java @@ -19,10 +19,12 @@ package org.eclipse.jetty.server.session; import org.junit.jupiter.api.AfterEach; +import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredInvalidationSessionTest */ +@Testcontainers(disabledWithoutDocker = true) public class ClusteredInvalidationSessionTest extends AbstractClusteredInvalidationSessionTest { diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java index 9ab354ad180..4a55fd495ff 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredOrphanedSessionTest.java @@ -19,10 +19,12 @@ package org.eclipse.jetty.server.session; import org.junit.jupiter.api.AfterEach; +import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredOrphanedSessionTest */ +@Testcontainers(disabledWithoutDocker = true) public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessionTest { /** diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionMigrationTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionMigrationTest.java index b1ae366c8b2..2fc4ccb5c21 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionMigrationTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionMigrationTest.java @@ -31,6 +31,7 @@ import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Testcontainers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -45,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * Rather, it tests all of the machinery above the SessionDataStore. Thus, * to reduce test time, we only apply it to the JDBCSessionDataStore. */ +@Testcontainers(disabledWithoutDocker = true) public class ClusteredSessionMigrationTest extends AbstractTestBase { diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java index aaab3eac778..45542dacfaa 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ClusteredSessionScavengingTest.java @@ -19,10 +19,12 @@ package org.eclipse.jetty.server.session; import org.junit.jupiter.api.AfterEach; +import org.testcontainers.junit.jupiter.Testcontainers; /** * ClusteredSessionScavengingTest */ +@Testcontainers(disabledWithoutDocker = true) public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScavengingTest { /** diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JDBCSessionDataStoreTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JDBCSessionDataStoreTest.java index 845ddc750e7..6fa37149a8c 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JDBCSessionDataStoreTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JDBCSessionDataStoreTest.java @@ -20,10 +20,12 @@ package org.eclipse.jetty.server.session; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.testcontainers.junit.jupiter.Testcontainers; /** * JDBCSessionDataStoreTest */ +@Testcontainers(disabledWithoutDocker = true) public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest { diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java index 27f1fad3c6a..50976c1c131 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java @@ -37,6 +37,7 @@ import org.eclipse.jetty.webapp.WebAppContext; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.testcontainers.junit.jupiter.Testcontainers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -47,6 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * ReloadedSessionMissingClassTest */ @ExtendWith(WorkDirExtension.class) +@Testcontainers(disabledWithoutDocker = true) public class ReloadedSessionMissingClassTest { public WorkDir testdir; diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java index 224d93cde7d..2319e4e861c 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java @@ -27,6 +27,7 @@ import org.eclipse.jetty.server.handler.ContextHandler; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Testcontainers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -38,6 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * Test the SessionTableSchema behaviour when the database treats "" as a NULL, * like Oracle does. */ +@Testcontainers(disabledWithoutDocker = true) public class SessionTableSchemaTest { DatabaseAdaptor _da; diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java index e17e495002b..85b0525babd 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/WebAppObjectInSessionTest.java @@ -21,10 +21,12 @@ package org.eclipse.jetty.server.session; import org.eclipse.jetty.util.resource.Resource; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Testcontainers; /** * WebAppObjectInSessionTest */ +@Testcontainers(disabledWithoutDocker = true) public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest { From e82cacfdb6ce69291c0369f22291a917248e06b0 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 27 May 2020 09:53:13 +0200 Subject: [PATCH 72/77] Jetty 9.4.x single context optimisation (#4909) * Optimisation for single context It is a frequent deployment mode to have only a single context. In that case, the ContextHandlerCollection can bypass a bit of looping/matching/selecting and just call the single context, which it works out itself anyway if the request applies to it. Signed-off-by: Greg Wilkins * Optimisation for single context updates from review Signed-off-by: Greg Wilkins --- .../handler/ContextHandlerCollection.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java index adc32da6368..e2e57efc8c9 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java @@ -176,11 +176,23 @@ public class ContextHandlerCollection extends HandlerCollection @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - Handlers handlers = _handlers.get(); - if (handlers == null) + Mapping mapping = (Mapping)_handlers.get(); + + // Handle no contexts + if (mapping == null) + return; + Handler[] handlers = mapping.getHandlers(); + if (handlers == null || handlers.length == 0) return; - Mapping mapping = (Mapping)handlers; + // handle only a single context. + if (handlers.length == 1) + { + handlers[0].handle(target, baseRequest, request, response); + return; + } + + // handle async dispatch to specific context HttpChannelState async = baseRequest.getHttpChannelState(); if (async.isAsync()) { @@ -197,6 +209,7 @@ public class ContextHandlerCollection extends HandlerCollection } } + // handle many contexts if (target.startsWith("/")) { Trie> pathBranches = mapping._pathBranches; @@ -229,11 +242,9 @@ public class ContextHandlerCollection extends HandlerCollection } else { - if (mapping.getHandlers() == null) - return; - for (int i = 0; i < mapping.getHandlers().length; i++) + for (Handler handler : handlers) { - mapping.getHandlers()[i].handle(target, baseRequest, request, response); + handler.handle(target, baseRequest, request, response); if (baseRequest.isHandled()) return; } From 65dbcc7c86abf2cb87376245f127b185efd769f2 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 27 May 2020 18:26:08 +1000 Subject: [PATCH 73/77] fix merge Signed-off-by: olivier lamy --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c16f0cd42ca..d45feef7e64 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,7 @@ ${project.build.directory}/local-repo src/it/settings.xml 0 + 1.4.2 @@ -1065,12 +1066,12 @@ org.testcontainers testcontainers - 1.14.1 + ${testcontainers.version} org.testcontainers junit-jupiter - 1.14.1 + ${testcontainers.version} From 423777ed020ba8c51235500b2220b866504d8e58 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 27 May 2020 19:35:38 +1000 Subject: [PATCH 74/77] fix AbstractThreadPoolTest from merge from 9.4.x Signed-off-by: Lachlan Roberts --- .../util/thread/AbstractThreadPoolTest.java | 28 ------------------- .../util/thread/QueuedThreadPoolTest.java | 21 ++++++++++++++ 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java index b46ef15b6bd..8ee09014ae9 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/AbstractThreadPoolTest.java @@ -18,11 +18,7 @@ package org.eclipse.jetty.util.thread; -import java.time.Duration; - import org.eclipse.jetty.util.ProcessorUtils; -import org.eclipse.jetty.util.component.ContainerLifeCycle; -import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterAll; @@ -30,8 +26,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.fail; public abstract class AbstractThreadPoolTest @@ -93,26 +87,4 @@ public abstract class AbstractThreadPoolTest assertThat(pool.getMaxThreads(), Matchers.is(3)); } - - @Test - public void testJoinWithStopTimeout() - { - // ThreadPool must be an implement ContainerLifeCycle for this test to be valid. - SizedThreadPool threadPool = newPool(3); - if (!(threadPool instanceof ContainerLifeCycle)) - return; - - final long stopTimeout = 100; - ((ContainerLifeCycle)threadPool).setStopTimeout(100); - LifeCycle.start(threadPool); - - // Verify that join does not timeout after waiting twice the stopTimeout. - assertThrows(Throwable.class, () -> - assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), threadPool::join) - ); - - // After stopping the ThreadPool join should unblock. - LifeCycle.stop(threadPool); - assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), threadPool::join); - } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java index 770a481b675..ef6b13efc66 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java @@ -19,11 +19,13 @@ package org.eclipse.jetty.util.thread; import java.io.Closeable; +import java.time.Duration; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jetty.logging.StacklessLogging; +import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.core.StringContains.containsString; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.assertTrue; public class QueuedThreadPoolTest extends AbstractThreadPoolTest @@ -753,6 +756,24 @@ public class QueuedThreadPoolTest extends AbstractThreadPoolTest assertThrows(IllegalArgumentException.class, () -> new QueuedThreadPool(4, 8)); } + @Test + public void testJoinWithStopTimeout() throws Exception + { + final long stopTimeout = 100; + QueuedThreadPool threadPool = new QueuedThreadPool(); + threadPool.setStopTimeout(100); + threadPool.start(); + + // Verify that join does not timeout after waiting twice the stopTimeout. + assertThrows(Throwable.class, () -> + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), threadPool::join) + ); + + // After stopping the ThreadPool join should unblock. + LifeCycle.stop(threadPool); + assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), threadPool::join); + } + @Test public void testDump() throws Exception { From 85b500fc15db9cd39640dab4adbc7a2840994e01 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 27 May 2020 20:27:14 +1000 Subject: [PATCH 75/77] cleanup unused imports Signed-off-by: olivier lamy --- .../server/session/infinispan/RemoteQueryManagerTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java b/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java index 53b04adeb25..603142c51cf 100644 --- a/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java +++ b/jetty-infinispan/infinispan-remote-query/src/test/java/org/eclipse/jetty/server/session/infinispan/RemoteQueryManagerTest.java @@ -41,18 +41,14 @@ import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.protostream.FileDescriptorSource; import org.infinispan.protostream.SerializationContext; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; -import org.testcontainers.utility.MountableFile; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; From d6c77a8a44285922e0609e5242c6e95adef37d0f Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Wed, 27 May 2020 20:41:15 +1000 Subject: [PATCH 76/77] fix merge from 9.4.x Signed-off-by: olivier lamy --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d45feef7e64..9a824ca94c3 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ ${project.build.directory}/local-repo src/it/settings.xml 0 - 1.4.2 + 1.14.2 From aae64f181c4c33be994bfad6cb920f1b959f7b05 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 27 May 2020 13:42:01 +0200 Subject: [PATCH 77/77] Issue #4894 use schema and/or catalog name when creating sessions table (#4908) Signed-off-by: Jan Bartel --- .../sessions/session-configuration-jdbc.adoc | 22 ++++++- .../etc/sessions/jdbc/session-store.xml | 6 ++ .../config/modules/session-store-jdbc.mod | 11 ++++ .../server/session/JDBCSessionDataStore.java | 61 +++++++++++++++---- 4 files changed, 86 insertions(+), 14 deletions(-) diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/session-configuration-jdbc.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/session-configuration-jdbc.adoc index e02c04ca5e2..533cc88e061 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/session-configuration-jdbc.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/session-configuration-jdbc.adoc @@ -85,6 +85,16 @@ db-connection-type=datasource #jetty.session.jdbc.schema.maxIntervalColumn=maxInterval #jetty.session.jdbc.schema.mapColumn=map #jetty.session.jdbc.schema.table=JettySessions +# Optional name of the schema used to identify where the session table is defined in the database: +# "" - empty string, no schema name +# "INFERRED" - special string meaning infer from the current db connection +# name - a string defined by the user +#jetty.session.jdbc.schema.schemaName +# Optional name of the catalog used to identify where the session table is defined in the database: +# "" - empty string, no catalog name +# "INFERRED" - special string meaning infer from the current db connection +# name - a string defined by the user +#jetty.session.jdbc.schema.catalogName ---- jetty.session.gracePeriod.seconds:: @@ -111,4 +121,14 @@ jetty.session.jdbc.driverUrl:: Url of the database which includes the driver type, host name and port, service name and any specific attributes unique to the database, such as a username. As an example, here is a mysql connection with the username appended: `jdbc:mysql://127.0.0.1:3306/sessions?user=sessionsadmin`. -The `jetty.sessionTableSchema` values represent the names for the columns in the JDBC database and can be changed to suit your environment. +The `jetty.session.jdbc.schema.*` values represent the names of the table and columns in the JDBC database used to store sessions and can be changed to suit your environment. + +There are also two special, optional properties: `jetty.session.jdbc.schema.schemaName` and `jetty.session.jdbc.schema.catalogName`. +The exact meaning of these two properties is dependent on your database vendor, but can broadly be described as further scoping for the session table name. +See https://en.wikipedia.org/wiki/Database_schema and https://en.wikipedia.org/wiki/Database_catalog. +These extra scoping names can come into play at startup time when jetty determines if the session table already exists, or otherwise creates it on-the-fly. +If you have employed either of these concepts when you pre-created the session table, or you want to ensure that jetty uses them when it auto-creates the session table, then you have two options: either set them explicitly, or let jetty infer them from a database connection (obtained using either a Datasource or Driver according to the `db-connection-type` you have configured). +To set them explicitly, uncomment and supply appropriate values for the `jetty.session.jdbc.schema.schemaName` and/or `jetty.session.jdbc.schema.catalogName` properties. +To allow jetty to infer them from a database connection, use the special string `INFERRED` instead. +If you leave them blank or commented out, then the sessions table will not be scoped by schema or catalog name. + diff --git a/jetty-server/src/main/config/etc/sessions/jdbc/session-store.xml b/jetty-server/src/main/config/etc/sessions/jdbc/session-store.xml index 2bc8295ec5b..6a96d65f167 100644 --- a/jetty-server/src/main/config/etc/sessions/jdbc/session-store.xml +++ b/jetty-server/src/main/config/etc/sessions/jdbc/session-store.xml @@ -54,6 +54,12 @@ + + + + + + diff --git a/jetty-server/src/main/config/modules/session-store-jdbc.mod b/jetty-server/src/main/config/modules/session-store-jdbc.mod index e97457d0781..b367e364309 100644 --- a/jetty-server/src/main/config/modules/session-store-jdbc.mod +++ b/jetty-server/src/main/config/modules/session-store-jdbc.mod @@ -55,3 +55,14 @@ db-connection-type=datasource #jetty.session.jdbc.schema.maxIntervalColumn=maxInterval #jetty.session.jdbc.schema.mapColumn=map #jetty.session.jdbc.schema.table=JettySessions +# Optional name of the schema used to identify where the session table is defined in the database: +# "" - empty string, no schema name +# "INFERRED" - special string meaning infer from the current db connection +# name - a string defined by the user +#jetty.session.jdbc.schema.schemaName +# Optional name of the catalog used to identify where the session table is defined in the database: +# "" - empty string, no catalog name +# "INFERRED" - special string meaning infer from the current db connection +# name - a string defined by the user +#jetty.session.jdbc.schema.catalogName + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java index 54e6b5354a7..0fb2f3830f8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java @@ -66,9 +66,11 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore public static class SessionTableSchema { public static final int MAX_INTERVAL_NOT_SET = -999; + public static final String INFERRED = "INFERRED"; protected DatabaseAdaptor _dbAdaptor; protected String _schemaName = null; + protected String _catalogName = null; protected String _tableName = "JettySessions"; protected String _idColumn = "sessionId"; protected String _contextPathColumn = "contextPath"; @@ -87,7 +89,20 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore { _dbAdaptor = dbadaptor; } + + public void setCatalogName(String catalogName) + { + if (catalogName != null && StringUtil.isBlank(catalogName)) + _catalogName = null; + else + _catalogName = catalogName; + } + public String getCatalogName() + { + return _catalogName; + } + public String getSchemaName() { return _schemaName; @@ -95,8 +110,10 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore public void setSchemaName(String schemaName) { - checkNotNull(schemaName); - _schemaName = schemaName; + if (schemaName != null && StringUtil.isBlank(schemaName)) + _schemaName = null; + else + _schemaName = schemaName; } public String getTableName() @@ -484,28 +501,48 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore //make the session table if necessary String tableName = _dbAdaptor.convertIdentifier(getTableName()); + String schemaName = _dbAdaptor.convertIdentifier(getSchemaName()); - try (ResultSet result = metaData.getTables(null, schemaName, tableName, null)) + if (INFERRED.equalsIgnoreCase(schemaName)) + { + //use the value from the connection - + //NOTE that this value will also now be prepended to ALL + //table names in queries/updates. + schemaName = connection.getSchema(); + setSchemaName(schemaName); + } + String catalogName = _dbAdaptor.convertIdentifier(getCatalogName()); + if (INFERRED.equalsIgnoreCase(catalogName)) + { + //use the value from the connection + catalogName = connection.getCatalog(); + setCatalogName(catalogName); + } + + try (ResultSet result = metaData.getTables(catalogName, schemaName, tableName, null)) { if (!result.next()) { + if (LOG.isDebugEnabled()) + LOG.debug("Creating table {} schema={} catalog={}", tableName, schemaName, catalogName); //table does not exist, so create it statement.executeUpdate(getCreateStatementAsString()); } else { + if (LOG.isDebugEnabled()) + LOG.debug("Not creating table {} schema={} catalog={}", tableName, schemaName, catalogName); //session table exists, check it has maxinterval column ResultSet colResult = null; try { - colResult = metaData.getColumns(null, schemaName, tableName, + colResult = metaData.getColumns(catalogName, schemaName, tableName, _dbAdaptor.convertIdentifier(getMaxIntervalColumn())); } catch (SQLException sqlEx) { - LOG.warn("Problem checking if " + getTableName() + - " table contains " + getMaxIntervalColumn() + " column. Ensure table contains column definition: \"" + - getMaxIntervalColumn() + " long not null default -999\""); + LOG.warn("Problem checking if {} table contains {} column. Ensure table contains column with definition: long not null default -999", + getTableName(), getMaxIntervalColumn()); throw sqlEx; } try @@ -519,9 +556,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore } catch (SQLException sqlEx) { - LOG.warn("Problem adding " + getMaxIntervalColumn() + - " column. Ensure table contains column definition: \"" + getMaxIntervalColumn() + - " long not null default -999\""); + LOG.warn("Problem adding {} column. Ensure table contains column definition: long not null default -999", getMaxIntervalColumn()); throw sqlEx; } } @@ -538,7 +573,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore boolean index1Exists = false; boolean index2Exists = false; - try (ResultSet result = metaData.getIndexInfo(null, schemaName, tableName, false, true)) + try (ResultSet result = metaData.getIndexInfo(catalogName, schemaName, tableName, false, true)) { while (result.next()) { @@ -559,8 +594,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore @Override public String toString() { - return String.format("%s[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", super.toString(), - _schemaName, _tableName, _idColumn, _contextPathColumn, _virtualHostColumn, _cookieTimeColumn, _createTimeColumn, + return String.format("%s[%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s]", super.toString(), + _catalogName, _schemaName, _tableName, _idColumn, _contextPathColumn, _virtualHostColumn, _cookieTimeColumn, _createTimeColumn, _expiryTimeColumn, _accessTimeColumn, _lastAccessTimeColumn, _lastNodeColumn, _lastSavedTimeColumn, _maxIntervalColumn); } }