* Created by a {@link java.util.ServiceLoader} call in the
* {@link javax.websocket.ContainerProvider#getWebSocketContainer()} call.
+ *
*/
public class JettyClientContainerProvider extends ContainerProvider
{
- private static Object lock = new Object();
- private static ClientContainer INSTANCE;
+ private static final Logger LOG = Log.getLogger(JettyClientContainerProvider.class);
- public static ClientContainer getInstance()
+ private static boolean useSingleton = false;
+ private static WebSocketContainer INSTANCE;
+ private static boolean useServerContainer = false;
+
+ private static Object lock = new Object();
+
+ /**
+ * Change calls to {@link ContainerProvider#getWebSocketContainer()} to always
+ * return a singleton instance of the same {@link WebSocketContainer}
+ *
+ * @param flag true to use a singleton instance of {@link WebSocketContainer} for all
+ * calls to {@link ContainerProvider#getWebSocketContainer()}
+ */
+ @SuppressWarnings("unused")
+ public static void useSingleton(boolean flag)
{
- return INSTANCE;
+ JettyClientContainerProvider.useSingleton = flag;
}
- public static void stop() throws Exception
+ /**
+ * Test if {@link ContainerProvider#getWebSocketContainer()} will always
+ * return a singleton instance of the same {@link WebSocketContainer}
+ *
+ * @return true if using a singleton instance of {@link WebSocketContainer} for all
+ * calls to {@link ContainerProvider#getWebSocketContainer()}
+ */
+ @SuppressWarnings("unused")
+ public static boolean willUseSingleton()
{
- synchronized (lock)
- {
- if (INSTANCE == null)
- {
- return;
- }
-
- try
- {
- INSTANCE.stop();
- }
- finally
- {
- INSTANCE = null;
- }
- }
+ return useSingleton;
+ }
+
+ /**
+ * Add ability of calls to {@link ContainerProvider#getWebSocketContainer()} to
+ * find and return the {@link javax.websocket.server.ServerContainer} from the
+ * active {@code javax.servlet.ServletContext}.
+ *
+ *
+ * This will only work if the call to {@link ContainerProvider#getWebSocketContainer()}
+ * occurs within a thread being processed by the Servlet container.
+ *
+ *
+ * @param flag true to to use return the {@link javax.websocket.server.ServerContainer}
+ * from the active {@code javax.servlet.ServletContext} for all calls to
+ * {@link ContainerProvider#getWebSocketContainer()} from within a Servlet thread.
+ */
+ @SuppressWarnings("unused")
+ public static void useServerContainer(boolean flag)
+ {
+ JettyClientContainerProvider.useServerContainer = flag;
+ }
+
+ /**
+ * Test if {@link ContainerProvider#getWebSocketContainer()} has the ability to
+ * find and return the {@link javax.websocket.server.ServerContainer} from the
+ * active {@code javax.servlet.ServletContext}, before creating a new client based
+ * {@link WebSocketContainer}.
+ *
+ * @return true if {@link WebSocketContainer} returned from
+ * calls to {@link ContainerProvider#getWebSocketContainer()} could be the
+ * {@link javax.websocket.server.ServerContainer}
+ * from the active {@code javax.servlet.ServletContext}
+ */
+ @SuppressWarnings("unused")
+ public static boolean willUseServerContainer()
+ {
+ return useServerContainer;
}
public Object getContextHandler()
@@ -74,12 +121,13 @@ public class JettyClientContainerProvider extends ContainerProvider
return null;
// Equiv of: ContextHandler handler = ContextHandler.getContextHandler(context);
- Class> clazzContext = objContext.getClass();
- Method methodGetContextHandler = clazzContextHandler.getMethod("getContextHandler", clazzContext);
- return methodGetContextHandler.invoke(objContext);
+ Class> clazzServletContext = Class.forName("javax.servlet.ServletContext");
+ Method methodGetContextHandler = clazzContextHandler.getMethod("getContextHandler", clazzServletContext);
+ return methodGetContextHandler.invoke(null, objContext);
}
catch (Throwable ignore)
{
+ LOG.ignore(ignore);
return null;
}
}
@@ -93,52 +141,79 @@ public class JettyClientContainerProvider extends ContainerProvider
{
synchronized (lock)
{
- try
+ WebSocketContainer webSocketContainer = null;
+ Object contextHandler = getContextHandler();
+
+ if (useServerContainer && contextHandler != null)
{
- Class> clazzServerContainer = Class.forName("org.eclipse.jetty.websocket.jsr356.server.ServerContainer");
- Method method = clazzServerContainer.getMethod("getWebSocketContainer");
- WebSocketContainer container = (WebSocketContainer) method.invoke(null);
- if (container != null)
+ try
{
- return container;
+ // Attempt to use the ServerContainer attribute.
+ Method methodGetServletContext = contextHandler.getClass().getMethod("getServletContext");
+ Object objServletContext = methodGetServletContext.invoke(contextHandler);
+ if (objServletContext != null)
+ {
+ Method methodGetAttribute = objServletContext.getClass().getMethod("getAttribute", String.class);
+ Object objServerContainer = methodGetAttribute.invoke(objServletContext, "javax.websocket.server.ServerContainer");
+ if (objServerContainer != null && objServerContainer instanceof WebSocketContainer)
+ {
+ webSocketContainer = (WebSocketContainer) objServerContainer;
+ }
+ }
+
+ }
+ catch (Throwable ignore)
+ {
+ LOG.ignore(ignore);
+ // continue, without server container
}
}
- catch (Throwable ignore)
+
+ if (useSingleton && INSTANCE != null)
{
+ return INSTANCE;
}
- if (INSTANCE == null)
+ // Still no instance?
+ if (webSocketContainer == null)
{
- INSTANCE = new ClientContainer();
+ // TODO: use cached Executor, ByteBufferPool, and HttpClient here
+ ClientContainer clientContainer = new ClientContainer();
- Object contextHandler = getContextHandler();
if (contextHandler != null && contextHandler instanceof ContainerLifeCycle)
{
// Add as bean to contextHandler
// Allow startup to follow Jetty lifecycle
- ((ContainerLifeCycle) contextHandler).addBean(INSTANCE, true);
+ ((ContainerLifeCycle) contextHandler).addBean(clientContainer);
}
else
{
// Static Initialization
// register JVM wide shutdown thread
- ShutdownThread.register(INSTANCE);
-
- if (!INSTANCE.isStarted())
+ ShutdownThread.register(clientContainer);
+ }
+
+ if (!clientContainer.isStarted())
+ {
+ try
{
- try
- {
- INSTANCE.start();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Unable to start Client Container", e);
- }
+ clientContainer.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to start Client Container", e);
}
}
+
+ webSocketContainer = clientContainer;
}
- return INSTANCE;
+ if (useSingleton)
+ {
+ INSTANCE = webSocketContainer;
+ }
+
+ return webSocketContainer;
}
}
}
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEchoTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEchoTest.java
index e7a9ca544a5..e8c5df00d4c 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEchoTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEchoTest.java
@@ -82,6 +82,7 @@ public class AnnotatedEchoTest
public void testEcho() throws Exception
{
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ server.addBean(container); // allow to shutdown with server
AnnotatedEchoClient echoer = new AnnotatedEchoClient();
Session session = container.connectToServer(echoer,serverUri);
session.getBasicRemote().sendText("Echo");
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
index 91b7c4dd72a..2890dea0b01 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
@@ -84,6 +84,7 @@ public class AnnotatedEndpointConfigTest
// Connect client
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ server.addBean(container); // allow to shutdown with server
socket = new AnnotatedEndpointClient();
session = container.connectToServer(socket,serverUri);
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
index cff86597328..9b5b7a310a1 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
@@ -109,6 +109,7 @@ public class ConfiguratorTest
public void testEndpointHandshakeInfo() throws Exception
{
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ server.addBean(container); // allow to shutdown with server
EndpointEchoClient echoer = new EndpointEchoClient();
// Build Config
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
index b1277b4b6c0..c88f2a7735f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
@@ -44,7 +44,6 @@ import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
public class CookiesTest
@@ -72,12 +71,6 @@ public class CookiesTest
server.stop();
}
- @Before
- public void resetClientContainer() throws Exception
- {
- JettyClientContainerProvider.stop();
- }
-
@Test
public void testCookiesAreSentToServer() throws Exception
{
@@ -110,6 +103,7 @@ public class CookiesTest
});
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ server.addBean(container); // allow it to stop
ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
builder.configurator(new ClientEndpointConfig.Configurator()
@@ -153,6 +147,7 @@ public class CookiesTest
});
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ server.addBean(container); // allow it to stop
ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
builder.configurator(new ClientEndpointConfig.Configurator()
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
index c867b9a6e2e..2b7a1ba4ea7 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
@@ -38,6 +38,7 @@ import javax.websocket.WebSocketContainer;
import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.toolchain.test.TestTracker;
+import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
@@ -174,6 +175,12 @@ public class DecoderReaderManySmallTest
{
client = ContainerProvider.getWebSocketContainer();
}
+
+ @After
+ public void stopClient() throws Exception
+ {
+ ((LifeCycle)client).stop();
+ }
@Before
public void startServer() throws Exception
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
index e5f137b2257..c391bbd00b5 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
@@ -44,6 +44,7 @@ import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.BufferUtil;
+import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
@@ -238,7 +239,13 @@ public class DecoderReaderTest
{
client = ContainerProvider.getWebSocketContainer();
}
-
+
+ @After
+ public void stopClient() throws Exception
+ {
+ ((LifeCycle)client).stop();
+ }
+
@Before
public void startServer() throws Exception
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java
index b72bd289851..af004bf2b07 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DelayedStartClientTest.java
@@ -24,46 +24,88 @@ import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadInfo;
-import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Executor;
import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;
-import org.junit.Before;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
+import org.eclipse.jetty.util.component.LifeCycle;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.junit.After;
import org.junit.Test;
public class DelayedStartClientTest
{
- @Before
- public void stopClientContainer() throws Exception
+ WebSocketContainer container;
+
+ @After
+ public void stopContainer() throws Exception
{
- JettyClientContainerProvider.stop();
+ ((LifeCycle)container).stop();
}
@Test
public void testNoExtraHttpClientThreads()
{
- WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ container = ContainerProvider.getWebSocketContainer();
assertThat("Container", container, notNullValue());
- List threadNames = getThreadNames();
+ List threadNames = getThreadNames((ContainerLifeCycle)container);
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@"))));
assertThat("Threads", threadNames, not(hasItem(containsString("HttpClient@"))));
}
- private List getThreadNames()
+ public static List getThreadNames(ContainerLifeCycle... containers)
{
- ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
- ThreadInfo[] threads = threadMXBean.dumpAllThreads(false, false);
- List ret = new ArrayList<>();
- for (ThreadInfo info : threads)
+ List threadNames = new ArrayList<>();
+ Set
Parse a string in the form "host:port", handling IPv4 an IPv6 hosts
*
+ *
The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean
+ * value to control of the square brackets are stripped off IPv6 addresses.
*/
public class HostPort
{
+ private final static boolean STRIP_IPV6 = Boolean.parseBoolean(System.getProperty("org.eclipse.jetty.util.HostPort.STRIP_IPV6","true"));
+
private final String _host;
private final int _port;
@@ -45,7 +49,7 @@ public class HostPort
int close=authority.lastIndexOf(']');
if (close<0)
throw new IllegalArgumentException("Bad IPv6 host");
- _host=authority.substring(0,close+1);
+ _host=STRIP_IPV6?authority.substring(0,close+1):authority.substring(1,close);
if (authority.length()>close+1)
{
From b2187b3b1c83e2086debdf8c28f11f75da15e8b9 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Tue, 6 Jun 2017 17:00:22 +0200
Subject: [PATCH 028/147] Issue #1591
---
.../server/session/JDBCSessionDataStore.java | 216 +++++-----------
.../jetty/server/session/JdbcTestHelper.java | 81 ++++--
.../session/SessionTableSchemaTest.java | 243 ++++++++++++++++++
...tractClusteredInvalidationSessionTest.java | 6 +-
.../AbstractClusteredLastAccessTimeTest.java | 6 +-
.../AbstractClusteredOrphanedSessionTest.java | 6 +-
...AbstractClusteredSessionMigrationTest.java | 6 +-
...bstractClusteredSessionScavengingTest.java | 4 +-
...ractNonClusteredSessionScavengingTest.java | 12 +-
.../AbstractProxySerializationTest.java | 6 +-
.../session/AbstractSessionExpiryTest.java | 20 +-
...ctSessionInvalidateCreateScavengeTest.java | 4 +-
12 files changed, 405 insertions(+), 205 deletions(-)
create mode 100644 tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java
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 944ed1857bf..16eb3609a37 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
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
-import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -33,11 +32,10 @@ import java.sql.Statement;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.log.Log;
@@ -53,6 +51,11 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
+ /**
+ * Used for Oracle and other databases where "" is treated as NULL
+ */
+ public static final String NULL_CONTEXT_PATH = "/";
+
protected boolean _initialized = false;
private DatabaseAdaptor _dbAdaptor;
private SessionTableSchema _sessionTableSchema;
@@ -275,27 +278,24 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
}
- public PreparedStatement getUpdateSessionStatement(Connection connection, String canonicalContextPath)
+ public PreparedStatement getUpdateSessionStatement(Connection connection, String id, SessionContext context)
throws SQLException
{
String s = "update "+getSchemaTableName()+
" set "+getLastNodeColumn()+" = ?, "+getAccessTimeColumn()+" = ?, "+
getLastAccessTimeColumn()+" = ?, "+getLastSavedTimeColumn()+" = ?, "+getExpiryTimeColumn()+" = ?, "+
- getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where ";
+ getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where "+getIdColumn()+" = ? and "+getContextPathColumn()+
+ " = ? and "+getVirtualHostColumn()+" = ?";
- if (canonicalContextPath == null || "".equals(canonicalContextPath))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- s = s+getIdColumn()+" = ? and "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ?";
- return connection.prepareStatement(s);
- }
- }
-
- return connection.prepareStatement(s+getIdColumn()+" = ? and "+getContextPathColumn()+
- " = ? and "+getVirtualHostColumn()+" = ?");
+ String cp = context.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
+
+ PreparedStatement statement = connection.prepareStatement(s);
+ statement.setString(8, id);
+ statement.setString(9, cp);
+ statement.setString(10, context.getVhost());
+ return statement;
}
@@ -305,27 +305,16 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
if (_dbAdaptor == null)
throw new IllegalStateException("No DB adaptor");
-
- if (canonicalContextPath == null || "".equals(canonicalContextPath))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
- " from "+getSchemaTableName()+" where "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ? and "+getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?");
- statement.setString(1, vhost);
- statement.setLong(2, expiry);
- return statement;
- }
- }
+ String cp = canonicalContextPath;
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
" from "+getSchemaTableName()+" where "+getContextPathColumn()+" = ? and "+
getVirtualHostColumn()+" = ? and "+
getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?");
- statement.setString(1, canonicalContextPath);
+ statement.setString(1, cp);
statement.setString(2, vhost);
statement.setLong(3, expiry);
return statement;
@@ -338,21 +327,9 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
if (_dbAdaptor == null)
throw new IllegalStateException("No DB adaptor");
- if (sessionContext.getCanonicalContextPath() == null || "".equals(sessionContext.getCanonicalContextPath()))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
- " from "+getSchemaTableName()+" where "+
- getLastNodeColumn() + " = ? and "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ? and "+getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?");
- statement.setString(1, sessionContext.getWorkerName());
- statement.setString(2, sessionContext.getVhost());
- statement.setLong(3, expiry);
- return statement;
- }
- }
+ String cp = sessionContext.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
" from "+getSchemaTableName()+" where "+
@@ -362,7 +339,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
getExpiryTimeColumn()+" >0 and "+getExpiryTimeColumn()+" <= ?");
statement.setString(1, sessionContext.getWorkerName());
- statement.setString(2, sessionContext.getCanonicalContextPath());
+ statement.setString(2, cp);
statement.setString(3, sessionContext.getVhost());
statement.setLong(4, expiry);
return statement;
@@ -382,52 +359,27 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
}
- public PreparedStatement getCheckSessionExistsStatement (Connection connection, String canonicalContextPath)
+ public PreparedStatement getCheckSessionExistsStatement (Connection connection, SessionContext context)
throws SQLException
{
if (_dbAdaptor == null)
throw new IllegalStateException("No DB adaptor");
-
- if (canonicalContextPath == null || "".equals(canonicalContextPath))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
- " from "+getSchemaTableName()+
- " where "+getIdColumn()+" = ? and "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ?");
- return statement;
- }
- }
+ String cp = context.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
PreparedStatement statement = connection.prepareStatement("select "+getIdColumn()+", "+getExpiryTimeColumn()+
" from "+getSchemaTableName()+
" where "+getIdColumn()+" = ? and "+
getContextPathColumn()+" = ? and "+
getVirtualHostColumn()+" = ?");
+ statement.setString(2, cp);
+ statement.setString(3, context.getVhost());
return statement;
}
- public void fillCheckSessionExistsStatement (PreparedStatement statement, String id, SessionContext contextId)
- throws SQLException
- {
- statement.clearParameters();
- ParameterMetaData metaData = statement.getParameterMetaData();
- if (metaData.getParameterCount() < 3)
- {
- statement.setString(1, id);
- statement.setString(2, contextId.getVhost());
- }
- else
- {
- statement.setString(1, id);
- statement.setString(2, contextId.getCanonicalContextPath());
- statement.setString(3, contextId.getVhost());
- }
- }
-
+
public PreparedStatement getLoadStatement (Connection connection, String id, SessionContext contextId)
throws SQLException
@@ -436,26 +388,15 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
throw new IllegalStateException("No DB adaptor");
- if (contextId.getCanonicalContextPath() == null || "".equals(contextId.getCanonicalContextPath()))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement("select * from "+getSchemaTableName()+
- " where "+getIdColumn()+" = ? and "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ?");
- statement.setString(1, id);
- statement.setString(2, contextId.getVhost());
-
- return statement;
- }
- }
+ String cp = contextId.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull()&& StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
PreparedStatement statement = connection.prepareStatement("select * from "+getSchemaTableName()+
" where "+getIdColumn()+" = ? and "+getContextPathColumn()+
" = ? and "+getVirtualHostColumn()+" = ?");
statement.setString(1, id);
- statement.setString(2, contextId.getCanonicalContextPath());
+ statement.setString(2, cp);
statement.setString(3, contextId.getVhost());
return statement;
@@ -469,28 +410,21 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
if (_dbAdaptor == null)
throw new IllegalStateException("No DB adaptor");
+ String cp = contextId.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
+
String s = "update "+getSchemaTableName()+
" set "+getLastNodeColumn()+" = ?, "+getAccessTimeColumn()+" = ?, "+
getLastAccessTimeColumn()+" = ?, "+getLastSavedTimeColumn()+" = ?, "+getExpiryTimeColumn()+" = ?, "+
- getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where ";
+ getMaxIntervalColumn()+" = ?, "+getMapColumn()+" = ? where "+getIdColumn()+" = ? and "+getContextPathColumn()+
+ " = ? and "+getVirtualHostColumn()+" = ?";
- if (contextId.getCanonicalContextPath() == null || "".equals(contextId.getCanonicalContextPath()))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement(s+getIdColumn()+" = ? and "+
- getContextPathColumn()+" is null and "+
- getVirtualHostColumn()+" = ?");
- statement.setString(1, id);
- statement.setString(2, contextId.getVhost());
- return statement;
- }
- }
- PreparedStatement statement = connection.prepareStatement(s+getIdColumn()+" = ? and "+getContextPathColumn()+
- " = ? and "+getVirtualHostColumn()+" = ?");
- statement.setString(1, id);
- statement.setString(2, contextId.getCanonicalContextPath());
- statement.setString(3, contextId.getVhost());
+
+ PreparedStatement statement = connection.prepareStatement(s);
+ statement.setString(8, id);
+ statement.setString(9, cp);
+ statement.setString(10, contextId.getVhost());
return statement;
}
@@ -505,25 +439,15 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
throw new IllegalStateException("No DB adaptor");
-
- if (contextId.getCanonicalContextPath() == null || "".equals(contextId.getCanonicalContextPath()))
- {
- if (_dbAdaptor.isEmptyStringNull())
- {
- PreparedStatement statement = connection.prepareStatement("delete from "+getSchemaTableName()+
- " where "+getIdColumn()+" = ? and "+getContextPathColumn()+
- " = ? and "+getVirtualHostColumn()+" = ?");
- statement.setString(1, id);
- statement.setString(2, contextId.getVhost());
- return statement;
- }
- }
+ String cp = contextId.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
PreparedStatement statement = connection.prepareStatement("delete from "+getSchemaTableName()+
" where "+getIdColumn()+" = ? and "+getContextPathColumn()+
" = ? and "+getVirtualHostColumn()+" = ?");
statement.setString(1, id);
- statement.setString(2, contextId.getCanonicalContextPath());
+ statement.setString(2, cp);
statement.setString(3, contextId.getVhost());
return statement;
@@ -722,8 +646,8 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
data.setLastNode(result.getString(_sessionTableSchema.getLastNodeColumn()));
data.setLastSaved(result.getLong(_sessionTableSchema.getLastSavedTimeColumn()));
data.setExpiry(result.getLong(_sessionTableSchema.getExpiryTimeColumn()));
- data.setContextPath(result.getString(_sessionTableSchema.getContextPathColumn())); //TODO needed? this is part of the key now
- data.setVhost(result.getString(_sessionTableSchema.getVirtualHostColumn())); //TODO needed??? this is part of the key now
+ data.setContextPath(_context.getCanonicalContextPath());
+ data.setVhost(_context.getVhost());
try (InputStream is = _dbAdaptor.getBlobInputStream(result, _sessionTableSchema.getMapColumn());
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(is))
@@ -815,7 +739,13 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
try (PreparedStatement statement = connection.prepareStatement(s))
{
statement.setString(1, id); //session id
- statement.setString(2, _context.getCanonicalContextPath()); //context path
+
+ String cp = _context.getCanonicalContextPath();
+ if (_dbAdaptor.isEmptyStringNull() && StringUtil.isBlank(cp))
+ cp = NULL_CONTEXT_PATH;
+
+ statement.setString(2, cp); //context path
+
statement.setString(3, _context.getVhost()); //first vhost
statement.setString(4, data.getLastNode());//my node id
statement.setLong(5, data.getAccessed());//accessTime
@@ -845,11 +775,10 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
private void doUpdate (String id, SessionData data)
throws Exception
{
- //TODO check if it is actually dirty && try to optimize the writing of lastAccessTime and expiryTime
try (Connection connection = _dbAdaptor.getConnection())
{
connection.setAutoCommit(true);
- try (PreparedStatement statement = _sessionTableSchema.getUpdateSessionStatement(connection, _context.getCanonicalContextPath()))
+ try (PreparedStatement statement = _sessionTableSchema.getUpdateSessionStatement(connection, data.getId(), _context))
{
statement.setString(1, data.getLastNode());//should be my node id
statement.setLong(2, data.getAccessed());//accessTime
@@ -865,19 +794,6 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
byte[] bytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
statement.setBinaryStream(7, bais, bytes.length);//attribute map as blob
-
- if ((_context.getCanonicalContextPath() == null || "".equals(_context.getCanonicalContextPath())) && _dbAdaptor.isEmptyStringNull())
- {
- statement.setString(8, id);
- statement.setString(9, _context.getVhost());
- }
- else
- {
- statement.setString(8, id);
- statement.setString(9, _context.getCanonicalContextPath());
- statement.setString(10, _context.getVhost());
- }
-
statement.executeUpdate();
if (LOG.isDebugEnabled())
@@ -968,11 +884,11 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
if (!notExpiredInDB.isEmpty())
{
//we have some sessions to check
- try (PreparedStatement checkSessionExists = _sessionTableSchema.getCheckSessionExistsStatement(connection, _context.getCanonicalContextPath()))
+ try (PreparedStatement checkSessionExists = _sessionTableSchema.getCheckSessionExistsStatement(connection, _context))
{
for (String k: notExpiredInDB)
{
- _sessionTableSchema.fillCheckSessionExistsStatement (checkSessionExists, k, _context);
+ checkSessionExists.setString(1, k);
try (ResultSet result = checkSessionExists.executeQuery())
{
if (!result.next())
@@ -1044,9 +960,9 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
connection.setAutoCommit(true);
//non-expired session exists?
- try (PreparedStatement checkSessionExists = _sessionTableSchema.getCheckSessionExistsStatement(connection, _context.getCanonicalContextPath()))
+ try (PreparedStatement checkSessionExists = _sessionTableSchema.getCheckSessionExistsStatement(connection, _context))
{
- _sessionTableSchema.fillCheckSessionExistsStatement (checkSessionExists, id, _context);
+ checkSessionExists.setString(1, id);
try (ResultSet result = checkSessionExists.executeQuery())
{
if (!result.next())
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 ec6c0066aa5..13e3010d7ff 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
@@ -18,11 +18,16 @@
package org.eclipse.jetty.server.session;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.HashSet;
import java.util.Set;
@@ -87,32 +92,38 @@ public class JdbcTestHelper
*/
public static SessionDataStoreFactory newSessionDataStoreFactory()
{
- JDBCSessionDataStoreFactory factory = new JDBCSessionDataStoreFactory();
-
DatabaseAdaptor da = new DatabaseAdaptor();
da.setDriverInfo(DRIVER_CLASS, DEFAULT_CONNECTION_URL);
- factory.setDatabaseAdaptor(da);
-
- JDBCSessionDataStore.SessionTableSchema sessionTableSchema = new JDBCSessionDataStore.SessionTableSchema();
- sessionTableSchema.setTableName(TABLE);
- sessionTableSchema.setIdColumn(ID_COL);
- sessionTableSchema.setAccessTimeColumn(ACCESS_COL);
- sessionTableSchema.setContextPathColumn(CONTEXT_COL);
- sessionTableSchema.setCookieTimeColumn(COOKIE_COL);
- sessionTableSchema.setCreateTimeColumn(CREATE_COL);
- sessionTableSchema.setExpiryTimeColumn(EXPIRY_COL);
- sessionTableSchema.setLastAccessTimeColumn(LAST_ACCESS_COL);
- sessionTableSchema.setLastNodeColumn(LAST_NODE_COL);
- sessionTableSchema.setLastSavedTimeColumn(LAST_SAVE_COL);
- sessionTableSchema.setMapColumn(MAP_COL);
- sessionTableSchema.setMaxIntervalColumn(MAX_IDLE_COL);
- factory.setSessionTableSchema(sessionTableSchema);
- return factory;
+ return newSessionDataStoreFactory(da);
}
-
+ public static SessionDataStoreFactory newSessionDataStoreFactory(DatabaseAdaptor da)
+ {
+ JDBCSessionDataStoreFactory factory = new JDBCSessionDataStoreFactory();
+ factory.setDatabaseAdaptor(da);
+ JDBCSessionDataStore.SessionTableSchema sessionTableSchema = newSessionTableSchema();
+ factory.setSessionTableSchema(sessionTableSchema);
+ return factory;
+ }
+ public static JDBCSessionDataStore.SessionTableSchema newSessionTableSchema()
+ {
+ JDBCSessionDataStore.SessionTableSchema sessionTableSchema = new JDBCSessionDataStore.SessionTableSchema();
+ sessionTableSchema.setTableName(TABLE);
+ sessionTableSchema.setIdColumn(ID_COL);
+ sessionTableSchema.setAccessTimeColumn(ACCESS_COL);
+ sessionTableSchema.setContextPathColumn(CONTEXT_COL);
+ sessionTableSchema.setCookieTimeColumn(COOKIE_COL);
+ sessionTableSchema.setCreateTimeColumn(CREATE_COL);
+ sessionTableSchema.setExpiryTimeColumn(EXPIRY_COL);
+ sessionTableSchema.setLastAccessTimeColumn(LAST_ACCESS_COL);
+ sessionTableSchema.setLastNodeColumn(LAST_NODE_COL);
+ sessionTableSchema.setLastSavedTimeColumn(LAST_SAVE_COL);
+ sessionTableSchema.setMapColumn(MAP_COL);
+ sessionTableSchema.setMaxIntervalColumn(MAX_IDLE_COL);
+ return sessionTableSchema;
+ }
public static boolean existsInSessionTable(String id, boolean verbose)
throws Exception
@@ -147,6 +158,36 @@ public class JdbcTestHelper
}
+ public static void insertSession (String id, String contextPath, String vhost)
+ throws Exception
+ {
+ Class.forName(DRIVER_CLASS);
+ try (Connection con=DriverManager.getConnection(DEFAULT_CONNECTION_URL);)
+ {
+ PreparedStatement statement = con.prepareStatement("insert into "+TABLE+
+ " ("+ID_COL+", "+CONTEXT_COL+", virtualHost, "+LAST_NODE_COL+
+ ", "+ACCESS_COL+", "+LAST_ACCESS_COL+", "+CREATE_COL+", "+COOKIE_COL+
+ ", "+LAST_SAVE_COL+", "+EXPIRY_COL+" "+") "+
+ " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+
+ statement.setString(1, id);
+ statement.setString(2, contextPath);
+ statement.setString(3, vhost);
+ statement.setString(4, "0");
+
+ statement.setLong(5, System.currentTimeMillis());
+ statement.setLong(6, System.currentTimeMillis());
+ statement.setLong(7, System.currentTimeMillis());
+ statement.setLong(8, System.currentTimeMillis());
+
+ statement.setLong(9, System.currentTimeMillis());
+ statement.setLong(10, System.currentTimeMillis());
+
+ statement.execute();
+ assertEquals(1,statement.getUpdateCount());
+ }
+ }
+
public static Set getSessionIds ()
throws Exception
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
new file mode 100644
index 00000000000..c5564a0e1f3
--- /dev/null
+++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/SessionTableSchemaTest.java
@@ -0,0 +1,243 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.session;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * SessionTableSchemaTest
+ *
+ * Test the SessionTableSchema behaviour when the database treats "" as a NULL,
+ * like Oracle does.
+ *
+ */
+public class SessionTableSchemaTest
+{
+ DatabaseAdaptor _da;
+ JDBCSessionDataStore.SessionTableSchema _tableSchema;
+
+
+ @Before
+ public void setUp() throws Exception
+ {
+ //pretend to be an Oracle-like database that treats "" as NULL
+ _da = new DatabaseAdaptor()
+ {
+
+ /**
+ * @see org.eclipse.jetty.server.session.DatabaseAdaptor#isEmptyStringNull()
+ */
+ @Override
+ public boolean isEmptyStringNull()
+ {
+ return true; //test special handling for oracle
+ }
+
+ };
+ _da.setDriverInfo(JdbcTestHelper.DRIVER_CLASS, JdbcTestHelper.DEFAULT_CONNECTION_URL);
+ _tableSchema = JdbcTestHelper.newSessionTableSchema();
+ _tableSchema.setDatabaseAdaptor(_da);
+ }
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ JdbcTestHelper.shutdown(null);
+ }
+
+
+ @Test
+ public void testLoad()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+ //test if it can be seen
+ try (Connection con = _da.getConnection())
+ {
+ //make a root context
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ //test the load statement
+ PreparedStatement s = _tableSchema.getLoadStatement(con, "1234", sc);
+ ResultSet rs = s.executeQuery();
+ assertTrue(rs.next());
+ }
+ }
+
+ @Test
+ public void testExists()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+ //test if it can be seen
+ try (Connection con = _da.getConnection())
+ {
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ PreparedStatement s = _tableSchema.getCheckSessionExistsStatement(con, sc);
+ s.setString(1, "1234");
+ ResultSet rs = s.executeQuery();
+ assertTrue(rs.next());
+ }
+ }
+
+ @Test
+ public void testDelete()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+ //test if it can be deleted
+ try (Connection con = _da.getConnection())
+ {
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ PreparedStatement s = _tableSchema.getDeleteStatement(con, "1234", sc);
+ assertEquals(1,s.executeUpdate());
+
+ assertFalse(JdbcTestHelper.existsInSessionTable("1234", false));
+ }
+ }
+
+
+ @Test
+ public void testExpired()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+
+ try (Connection con = _da.getConnection())
+ {
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ PreparedStatement s = _tableSchema.getExpiredSessionsStatement(con,
+ sc.getCanonicalContextPath(),
+ sc.getVhost(),
+ (System.currentTimeMillis()+100L));
+ ResultSet rs = s.executeQuery();
+ assertTrue(rs.next());
+ assertEquals("1234", rs.getString(1));
+ }
+ }
+
+ @Test
+ public void testMyExpiredSessions ()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+
+ try (Connection con = _da.getConnection())
+ {
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ PreparedStatement s = _tableSchema.getMyExpiredSessionsStatement(con,
+ sc,
+ (System.currentTimeMillis()+100L));
+ ResultSet rs = s.executeQuery();
+ assertTrue(rs.next());
+ assertEquals("1234", rs.getString(1));
+ }
+ }
+
+
+ @Test
+ public void testUpdate()
+ throws Exception
+ {
+ //set up the db
+ _da.initialize();
+ _tableSchema.prepareTables();
+
+ //insert a fake session at the root context
+ JdbcTestHelper.insertSession("1234", "/", "0.0.0.0");
+
+
+ try (Connection con = _da.getConnection())
+ {
+ ContextHandler handler = new ContextHandler();
+ handler.setContextPath("/");
+ SessionContext sc = new SessionContext("0", handler.getServletContext());
+ PreparedStatement s = _tableSchema.getUpdateStatement(con,
+ "1234",
+ sc);
+
+ s.setString(1, "0");//should be my node id
+ s.setLong(2, System.currentTimeMillis());
+ s.setLong(3, System.currentTimeMillis());
+ s.setLong(4, System.currentTimeMillis());
+ s.setLong(5, System.currentTimeMillis());
+ s.setLong(6, 2000L);
+
+
+ byte[] bytes = new byte[3];
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ s.setBinaryStream(7, bais, bytes.length);//attribute map as blob
+
+ assertEquals(1, s.executeUpdate());
+ }
+
+ }
+}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
index 4f69df0aaa6..ccd39817ee0 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
@@ -52,7 +52,7 @@ public abstract class AbstractClusteredInvalidationSessionTest extends AbstractT
@Test
public void testInvalidation() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int maxInactiveInterval = 30;
int scavengeInterval = 1;
@@ -84,8 +84,8 @@ public abstract class AbstractClusteredInvalidationSessionTest extends AbstractT
try
{
String[] urls = new String[2];
- urls[0] = "http://localhost:" + port1 + contextPath + servletMapping;
- urls[1] = "http://localhost:" + port2 + contextPath + servletMapping;
+ urls[0] = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
+ urls[1] = "http://localhost:" + port2 + contextPath + servletMapping.substring(1);
// Create the session on node1
ContentResponse response1 = client.GET(urls[0] + "?action=init");
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredLastAccessTimeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredLastAccessTimeTest.java
index 19c69697565..b8d252c028e 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredLastAccessTimeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredLastAccessTimeTest.java
@@ -57,7 +57,7 @@ public abstract class AbstractClusteredLastAccessTimeTest extends AbstractTestBa
@Test
public void testLastAccessTime() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int maxInactivePeriod = 8; //session will timeout after 8 seconds
int scavengePeriod = 2; //scavenging occurs every 2 seconds
@@ -97,7 +97,7 @@ public abstract class AbstractClusteredLastAccessTimeTest extends AbstractTestBa
try
{
// Perform one request to server1 to create a session
- ContentResponse response1 = client.GET("http://localhost:" + port1 + contextPath + servletMapping + "?action=init");
+ ContentResponse response1 = client.GET("http://localhost:" + port1 + contextPath + servletMapping.substring(1) + "?action=init");
assertEquals(HttpServletResponse.SC_OK, response1.getStatus());
assertEquals("test", response1.getContentAsString());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
@@ -116,7 +116,7 @@ public abstract class AbstractClusteredLastAccessTimeTest extends AbstractTestBa
int requestInterval = 500;
for (int i = 0; i < maxInactivePeriod * (1000 / requestInterval); ++i)
{
- Request request = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping);
+ Request request = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping.substring(1));
request.header("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK , response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredOrphanedSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredOrphanedSessionTest.java
index df8deaa760f..9583cc6e5ef 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredOrphanedSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredOrphanedSessionTest.java
@@ -52,7 +52,7 @@ public abstract class AbstractClusteredOrphanedSessionTest extends AbstractTestB
public void testOrphanedSession() throws Exception
{
// Disable scavenging for the first server, so that we simulate its "crash".
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 5;
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
@@ -85,7 +85,7 @@ public abstract class AbstractClusteredOrphanedSessionTest extends AbstractTestB
try
{
// Connect to server1 to create a session and get its session cookie
- ContentResponse response1 = client.GET("http://localhost:" + port1 + contextPath + servletMapping + "?action=init");
+ ContentResponse response1 = client.GET("http://localhost:" + port1 + contextPath + servletMapping.substring(1) + "?action=init");
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
@@ -98,7 +98,7 @@ public abstract class AbstractClusteredOrphanedSessionTest extends AbstractTestB
Thread.sleep(TimeUnit.SECONDS.toMillis(inactivePeriod + 2L * scavengePeriod));
// Perform one request to server2 to be sure that the session has been expired
- Request request = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping + "?action=check");
+ Request request = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping.substring(1) + "?action=check");
request.header("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionMigrationTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionMigrationTest.java
index 3277cad7928..181e2a38cd7 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionMigrationTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionMigrationTest.java
@@ -47,7 +47,7 @@ public abstract class AbstractClusteredSessionMigrationTest extends AbstractTest
@Test
public void testSessionMigration() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
@@ -79,7 +79,7 @@ public abstract class AbstractClusteredSessionMigrationTest extends AbstractTest
{
// Perform one request to server1 to create a session
int value = 1;
- Request request1 = client.POST("http://localhost:" + port1 + contextPath + servletMapping + "?action=set&value=" + value);
+ Request request1 = client.POST("http://localhost:" + port1 + contextPath + servletMapping.substring(1) + "?action=set&value=" + value);
ContentResponse response1 = request1.send();
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
@@ -89,7 +89,7 @@ public abstract class AbstractClusteredSessionMigrationTest extends AbstractTest
// Perform a request to server2 using the session cookie from the previous request
// This should migrate the session from server1 to server2.
- Request request2 = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping + "?action=get");
+ Request request2 = client.newRequest("http://localhost:" + port2 + contextPath + servletMapping.substring(1) + "?action=get");
request2.header("Cookie", sessionCookie);
ContentResponse response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
index 4dd9903ea5f..1e624e5d5f3 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
@@ -82,7 +82,7 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes
@Test
public void testNoScavenging() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 3;
int scavengePeriod = 0;
@@ -109,7 +109,7 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes
client.start();
try
{
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
// Create the session
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
index 3fd448ad9e5..c4695b8aec9 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
@@ -82,7 +82,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
_dataStore = context.getSessionHandler().getSessionCache().getSessionDataStore();
context.addServlet(TestServlet.class, servletMapping);
- String contextPath = "";
+ String contextPath = "/";
try
{
@@ -92,7 +92,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
client.start();
try
{
- ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create");
+ ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
@@ -106,7 +106,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
// The session should not be there anymore, but we present an old cookie
// The server should create a new session.
- Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=old-create");
+ Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-create");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -139,7 +139,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
ServletContextHandler context = server.addContext("/");
_dataStore = context.getSessionHandler().getSessionCache().getSessionDataStore();
context.addServlet(TestServlet.class, servletMapping);
- String contextPath = "";
+ String contextPath = "/";
try
{
@@ -150,7 +150,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
try
{
//create an immortal session
- ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create");
+ ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
@@ -163,7 +163,7 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
assertSession(TestServer.extractSessionId(sessionCookie), true);
// Test that the session is still there
- Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=old-test");
+ Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-test");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
index de2541cd9d4..431b17b3805 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
@@ -68,7 +68,7 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase
@Test
public void testProxySerialization() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int scavengePeriod = 10;
@@ -104,7 +104,7 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase
client.start();
try
{
- ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create");
+ ContentResponse response = client.GET("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=create");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
@@ -118,7 +118,7 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase
context.start();
// Make another request using the session id from before
- Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=test");
+ Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=test");
request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
index 2e34fe1a455..fa2c153b73f 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
@@ -107,7 +107,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
@Test
public void testSessionExpiresWithListener() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 3;
int scavengePeriod = 1;
@@ -134,7 +134,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
{
HttpClient client = new HttpClient();
client.start();
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make a request to set up a session on the server
ContentResponse response1 = client.GET(url + "?action=init");
@@ -167,7 +167,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
@Test
public void testSessionNotExpired() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 20;
int scavengePeriod = 10;
@@ -190,7 +190,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
int port1 = server1.getPort();
client.start();
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make a request to set up a session on the server
ContentResponse response = client.GET(url + "?action=init");
@@ -207,7 +207,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
//start the server again, before the session times out
server1.start();
port1 = server1.getPort();
- url = "http://localhost:" + port1 + contextPath + servletMapping;
+ url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make another request, the session should not have expired
Request request = client.newRequest(url + "?action=notexpired");
@@ -234,7 +234,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 4;
int scavengePeriod = 1;
@@ -261,7 +261,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
{
HttpClient client = new HttpClient();
client.start();
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make a request to set up a session on the server
ContentResponse response1 = client.GET(url + "?action=init");
@@ -288,7 +288,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
pause(inactivePeriod+(scavengePeriod*2));
port1 = server1.getPort();
- url = "http://localhost:" + port1 + contextPath + servletMapping;
+ url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make another request, the session should have expired
Request request = client.newRequest(url + "?action=test");
@@ -310,7 +310,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
@Test
public void testRequestForSessionWithChangedTimeout () throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 5;
int scavengePeriod = 1;
@@ -337,7 +337,7 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
{
HttpClient client = new HttpClient();
client.start();
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
//make a request to set up a session on the server with the session manager's inactive timeout
ContentResponse response = client.GET(url + "?action=init");
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
index b700ec64fd3..88edd817e55 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
@@ -87,7 +87,7 @@ public abstract class AbstractSessionInvalidateCreateScavengeTest extends Abstra
@Test
public void testSessionScavenge() throws Exception
{
- String contextPath = "";
+ String contextPath = "/";
String servletMapping = "/server";
int inactivePeriod = 6;
int scavengePeriod = 3;
@@ -115,7 +115,7 @@ public abstract class AbstractSessionInvalidateCreateScavengeTest extends Abstra
client.start();
try
{
- String url = "http://localhost:" + port1 + contextPath + servletMapping;
+ String url = "http://localhost:" + port1 + contextPath + servletMapping.substring(1);
// Create the session
From d3e42cf064528ed79d81a3f8a80f20925d6e7122 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 6 Jun 2017 17:04:49 +0200
Subject: [PATCH 029/147] Issue #1503 Optionally strip IPv6. Fixed inverted
boolean
---
.../src/main/java/org/eclipse/jetty/util/HostPort.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/HostPort.java b/jetty-util/src/main/java/org/eclipse/jetty/util/HostPort.java
index 5e4eba9481b..250c296fae3 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/HostPort.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/HostPort.java
@@ -23,11 +23,11 @@ package org.eclipse.jetty.util;
*
Parse a string in the form "host:port", handling IPv4 an IPv6 hosts
*
*
The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean
- * value to control of the square brackets are stripped off IPv6 addresses.
+ * value to control of the square brackets are stripped off IPv6 addresses (default false).
+ * This filter sets or adds a header to the response.
+ *
+ * The {@code headerConfig} init param is a CSV of actions to perform on headers, with the following syntax:
+ * [action] [header name]: [header value]
+ * [action] can be one of set, add, setDate, or addDate
+ * The date actions will add the header value in milliseconds to the current system time before setting a date header.
+ *
+ * Below is an example value for headerConfig:
+ *
+ *
+ *
+ * @see IncludeExcludeBasedFilter
+ */
+public class HeaderFilter extends IncludeExcludeBasedFilter
+{
+ private List _configuredHeaders = new ArrayList<>();
+ private static final Logger LOG = Log.getLogger(HeaderFilter.class);
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ super.init(filterConfig);
+ String header_config = filterConfig.getInitParameter("headerConfig");
+
+ if (header_config != null)
+ {
+ String[] configs = StringUtil.csvSplit(header_config);
+ for (String config : configs)
+ _configuredHeaders.add(parseHeaderConfiguration(config));
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug(this.toString());
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ chain.doFilter(request,response);
+
+ HttpServletRequest http_request = (HttpServletRequest)request;
+ HttpServletResponse http_response = (HttpServletResponse)response;
+
+ if (!super.shouldFilter(http_request,http_response))
+ {
+ return;
+ }
+
+ for (ConfiguredHeader header : _configuredHeaders)
+ {
+ if (header.isDate())
+ {
+ long header_value = System.currentTimeMillis() + header.getMsOffset();
+ if (header.isAdd())
+ {
+ http_response.addDateHeader(header.getName(),header_value);
+ }
+ else
+ {
+ http_response.setDateHeader(header.getName(),header_value);
+ }
+ }
+ else // constant header value
+ {
+ if (header.isAdd())
+ {
+ http_response.addHeader(header.getName(),header.getValue());
+ }
+ else
+ {
+ http_response.setHeader(header.getName(),header.getValue());
+ }
+ }
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append("\n");
+ sb.append("configured headers:\n");
+ for (ConfiguredHeader c : _configuredHeaders)
+ sb.append(c).append("\n");
+
+ return sb.toString();
+ }
+
+ private ConfiguredHeader parseHeaderConfiguration(String config)
+ {
+ String[] config_tokens = config.trim().split(" ",2);
+ String method = config_tokens[0].trim();
+ String header = config_tokens[1];
+ String[] header_tokens = header.trim().split(":",2);
+ String header_name = header_tokens[0].trim();
+ String header_value = header_tokens[1].trim();
+ ConfiguredHeader configured_header = new ConfiguredHeader(header_name,header_value,method.startsWith("add"),method.endsWith("Date"));
+ return configured_header;
+ }
+
+ private static class ConfiguredHeader
+ {
+ private String _name;
+ private String _value;
+ private long _msOffset;
+ private boolean _add;
+ private boolean _date;
+
+ public ConfiguredHeader(String name, String value, boolean add, boolean date)
+ {
+ _name = name;
+ _value = value;
+ _add = add;
+ _date = date;
+
+ if (_date)
+ {
+ _msOffset = Long.parseLong(_value);
+ }
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public String getValue()
+ {
+ return _value;
+ }
+
+ public boolean isAdd()
+ {
+ return _add;
+ }
+
+ public boolean isDate()
+ {
+ return _date;
+ }
+
+ public long getMsOffset()
+ {
+ return _msOffset;
+ }
+
+ @Override
+ public String toString()
+ {
+ return (_add?"add":"set") + (_date?"Date":"") + " " + _name + ": " + _value;
+ }
+ }
+}
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java
new file mode 100644
index 00000000000..b1ba2cf4342
--- /dev/null
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java
@@ -0,0 +1,162 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.servlets;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.MimeTypes;
+import org.eclipse.jetty.http.pathmap.PathSpecSet;
+import org.eclipse.jetty.util.IncludeExclude;
+import org.eclipse.jetty.util.IncludeExcludeSet;
+import org.eclipse.jetty.util.StringUtil;
+import org.eclipse.jetty.util.URIUtil;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+
+/**
+ * Include Exclude Based Filter
+ *
+ * This is an abstract filter which helps with filtering based on include/exclude of paths, mime types, and/or http methods.
+ *
+ * Use the {@link #shouldFilter(HttpServletRequest, HttpServletResponse)} method to determine if a request/response should be filtered. If mime types are used,
+ * it should be called after {@link javax.servlet.FilterChain#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)} since the mime type may not
+ * be written until then.
+ *
+ * Supported init params:
+ *
+ *
includedPaths - CSV of path specs to include
+ *
excludedPaths - CSV of path specs to exclude
+ *
includedMimeTypes - CSV of mime types to include
+ *
excludedMimeTypes - CSV of mime types to exclude
+ *
includedHttpMethods - CSV of http methods to include
+ *
excludedHttpMethods - CSV of http methods to exclude
+ *
+ *
+ * Path spec rules:
+ *
+ *
If the spec starts with '^' the spec is assumed to be a regex based path spec and will match with normal Java regex rules.
+ *
If the spec starts with '/' the spec is assumed to be a Servlet url-pattern rules path spec for either an exact match or prefix based
+ * match.
+ *
If the spec starts with '*.' the spec is assumed to be a Servlet url-pattern rules path spec for a suffix based match.
+ *
All other syntaxes are unsupported.
+ *
+ *
+ * CSVs are parsed with {@link StringUtil#csvSplit(String)}
+ *
+ * @see PathSpecSet
+ * @see IncludeExcludeSet
+ */
+public abstract class IncludeExcludeBasedFilter implements Filter
+{
+ private final IncludeExclude _mimeTypes = new IncludeExclude<>();
+ private final IncludeExclude _httpMethods = new IncludeExclude<>();
+ private final IncludeExclude _paths = new IncludeExclude<>(PathSpecSet.class);
+ private static final Logger LOG = Log.getLogger(IncludeExcludeBasedFilter.class);
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ String included_paths = filterConfig.getInitParameter("includedPaths");
+ String excluded_paths = filterConfig.getInitParameter("excludedPaths");
+ String included_mime_types = filterConfig.getInitParameter("includedMimeTypes");
+ String excluded_mime_types = filterConfig.getInitParameter("excludedMimeTypes");
+ String included_http_methods = filterConfig.getInitParameter("includedHttpMethods");
+ String excluded_http_methods = filterConfig.getInitParameter("excludedHttpMethods");
+
+ if (included_paths != null)
+ {
+ _paths.include(StringUtil.csvSplit(included_paths));
+ }
+ if (excluded_paths != null)
+ {
+ _paths.exclude(StringUtil.csvSplit(excluded_paths));
+ }
+ if (included_mime_types != null)
+ {
+ _mimeTypes.include(StringUtil.csvSplit(included_mime_types));
+ }
+ if (excluded_mime_types != null)
+ {
+ _mimeTypes.exclude(StringUtil.csvSplit(excluded_mime_types));
+ }
+ if (included_http_methods != null)
+ {
+ _httpMethods.include(StringUtil.csvSplit(included_http_methods));
+ }
+ if (excluded_http_methods != null)
+ {
+ _httpMethods.exclude(StringUtil.csvSplit(excluded_http_methods));
+ }
+ }
+
+ protected boolean shouldFilter(HttpServletRequest http_request, HttpServletResponse http_response)
+ {
+ String http_method = http_request.getMethod();
+ LOG.debug("HTTP method is: {}",http_method);
+ if (!_httpMethods.test(http_method))
+ {
+ LOG.debug("should not apply filter because HTTP method does not match");
+ return false;
+ }
+
+ String content_type = http_response.getContentType();
+ LOG.debug("Content Type is: {}",content_type);
+ content_type = (content_type == null)?"":content_type;
+ String mime_type = MimeTypes.getContentTypeWithoutCharset(content_type);
+
+ LOG.debug("Mime Type is: {}",content_type);
+ if (!_mimeTypes.test(mime_type))
+ {
+ LOG.debug("should not apply filter because mime type does not match");
+ return false;
+ }
+
+ ServletContext context = http_request.getServletContext();
+ String path = context == null?http_request.getRequestURI():URIUtil.addPaths(http_request.getServletPath(),http_request.getPathInfo());
+ LOG.debug("Path is: {}",path);
+ if (!_paths.test(path))
+ {
+ LOG.debug("should not apply filter because path does not match");
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("filter configuration:\n");
+ sb.append("paths:\n").append(_paths).append("\n");
+ sb.append("mime types:\n").append(_mimeTypes).append("\n");
+ sb.append("http methods:\n").append(_httpMethods);
+ return sb.toString();
+ }
+}
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/HeaderFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/HeaderFilterTest.java
new file mode 100644
index 00000000000..5230a96fd24
--- /dev/null
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/HeaderFilterTest.java
@@ -0,0 +1,137 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.servlets;
+
+import java.io.IOException;
+import java.util.EnumSet;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.HttpTester;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletTester;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class HeaderFilterTest
+{
+ private ServletTester _tester;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ _tester = new ServletTester();
+ _tester.setContextPath("/context");
+ _tester.addServlet(NullServlet.class,"/test/*");
+
+ _tester.start();
+ }
+
+ @After
+ public void tearDown() throws Exception
+ {
+ _tester.stop();
+ }
+
+ @Test
+ public void testHeaderFilterSet() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(HeaderFilter.class);
+ holder.setInitParameter("headerConfig","set X-Frame-Options: DENY");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Frame-Options","DENY"));
+ }
+
+ @Test
+ public void testHeaderFilterAdd() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(HeaderFilter.class);
+ holder.setInitParameter("headerConfig","add X-Frame-Options: DENY");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Frame-Options","DENY"));
+ }
+
+ @Test
+ public void testHeaderFilterSetDate() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(HeaderFilter.class);
+ holder.setInitParameter("headerConfig","setDate Expires: 100");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains(HttpHeader.EXPIRES));
+ }
+
+ @Test
+ public void testHeaderFilterAddDate() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(HeaderFilter.class);
+ holder.setInitParameter("headerConfig","addDate Expires: 100");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains(HttpHeader.EXPIRES));
+ }
+
+ public static class NullServlet extends HttpServlet
+ {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setStatus(HttpStatus.NO_CONTENT_204);
+ }
+
+ }
+}
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java
new file mode 100644
index 00000000000..f9971247ad2
--- /dev/null
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java
@@ -0,0 +1,353 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.servlets;
+
+import java.io.IOException;
+import java.util.EnumSet;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.http.HttpTester;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletTester;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IncludeExcludeBasedFilterTest
+{
+ private ServletTester _tester;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ _tester = new ServletTester();
+ _tester.setContextPath("/context");
+ _tester.addServlet(NullServlet.class,"/test/*");
+
+ _tester.start();
+ }
+
+ @After
+ public void tearDown() throws Exception
+ {
+ _tester.stop();
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludedPathMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedPaths","^/test/0$");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludedPathNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedPaths","^/nomatchtest$");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludedPathMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedPaths","^/test/0$");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludedPathNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedPaths","^/nomatchtest$");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludeOverridesInclude() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedPaths","^/test/0$");
+ holder.setInitParameter("excludedPaths","^/test/0$");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMethodMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedHttpMethods","GET");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMethodNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedHttpMethods","POST,PUT");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludeMethodMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedHttpMethods","GET");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludeMethodNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedHttpMethods","POST,PUT");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/0");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/json");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/xml");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludeMimeTypeMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedMimeTypes","application/json");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterExcludeMimeTypeNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("excludedMimeTypes","application/xml");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeSemicolonMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/json");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json-utf8");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeSemicolonNoMatch() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/xml");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json-utf8");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ public static class MockIncludeExcludeFilter extends IncludeExcludeBasedFilter
+ {
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ chain.doFilter(request,response);
+ HttpServletRequest http_request = (HttpServletRequest)request;
+ HttpServletResponse http_response = (HttpServletResponse)response;
+
+ if (!super.shouldFilter(http_request,http_response))
+ {
+ return;
+ }
+
+ http_response.setHeader("X-Custom-Value","1");
+ }
+ }
+
+ public static class NullServlet extends HttpServlet
+ {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if (req.getPathInfo().equals("/json"))
+ {
+ resp.setContentType("application/json");
+ }
+ else if (req.getPathInfo().equals("/json-utf8"))
+ {
+ resp.setContentType("application/json; charset=utf-8");
+ }
+ resp.setStatus(HttpStatus.NO_CONTENT_204);
+ }
+
+ }
+}
From 20ca6277a8e49fa53932908f845b740182e88229 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 16 Jun 2017 10:46:21 +1000
Subject: [PATCH 056/147] use outputDirectory from reactor projects rather than
having to install dependencies first #1623
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 6 ++
.../jetty/maven/plugin/AbstractJettyMojo.java | 2 +-
.../jetty/maven/plugin/JettyRunMojo.java | 97 +++++++++++++++----
.../maven/plugin/JettyWebAppContext.java | 7 +-
4 files changed, 90 insertions(+), 22 deletions(-)
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index f23db716925..335e94a2bc7 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -71,6 +71,12 @@
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ ${pluginToolsVersion}
+ provided
+ org.eclipse.jettyjetty-util
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
index 09b1c399646..72b8bad3a95 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
@@ -341,7 +341,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
{
try
{
- List provided = new ArrayList();
+ List provided = new ArrayList<>();
URL[] urls = null;
for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index 0fe35ff1896..259cb0f54d0 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -18,24 +18,29 @@
package org.eclipse.jetty.maven.plugin;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.StringUtils;
+import org.eclipse.jetty.util.PathWatcher;
+import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.webapp.WebAppContext;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.eclipse.jetty.util.PathWatcher;
-import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.webapp.WebAppContext;
-
/**
* This goal is used in-situ on a Maven project without first requiring that the project
* is assembled into a war, saving time during the development cycle.
@@ -154,18 +159,20 @@ public class JettyRunMojo extends AbstractJettyMojo
* List of deps that are wars
*/
protected List warArtifacts;
-
-
-
-
-
-
+
+ @Parameter(defaultValue = "${reactorProjects}", readonly = true, required = true)
+ private List reactorProjects;
+
/**
* @see org.eclipse.jetty.maven.plugin.AbstractJettyMojo#execute()
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
+ if ( !"war".equals( project.getPackaging() ) || skip )
+ {
+ return;
+ }
warPluginInfo = new WarPluginInfo(project);
super.execute();
}
@@ -273,7 +280,8 @@ public class JettyRunMojo extends AbstractJettyMojo
webApp.setClasses (classesDirectory);
if (useTestScope && (testClassesDirectory != null))
webApp.setTestClasses (testClassesDirectory);
-
+
+ webApp.getClassPathFiles().addAll( getDependencyProjects() );
webApp.setWebInfLib (getDependencyFiles());
//get copy of a list of war artifacts
@@ -556,18 +564,22 @@ public class JettyRunMojo extends AbstractJettyMojo
/**
* @return
*/
- private List getDependencyFiles ()
+ private List getDependencyFiles()
{
List dependencyFiles = new ArrayList();
for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
{
- Artifact artifact = (Artifact) iter.next();
+ Artifact artifact = iter.next();
// Include runtime and compile time libraries, and possibly test libs too
if(artifact.getType().equals("war"))
{
continue;
}
+ if (getProjectReferences( artifact, project )!=null)
+ {
+ continue;
+ }
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
continue; //never add dependencies of scope=provided to the webapp's classpath (see also param)
@@ -581,6 +593,57 @@ public class JettyRunMojo extends AbstractJettyMojo
return dependencyFiles;
}
+
+ private List getDependencyProjects()
+ {
+ List dependencyFiles = new ArrayList();
+ for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
+ {
+ Artifact artifact = iter.next();
+
+ // Include runtime and compile time libraries, and possibly test libs too
+ if(artifact.getType().equals("war"))
+ {
+ continue;
+ }
+
+ if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
+ continue; //never add dependencies of scope=provided to the webapp's classpath (see also param)
+
+ if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
+ continue; //only add dependencies of scope=test if explicitly required
+
+ MavenProject mavenProject = getProjectReferences( artifact, project );
+ if (mavenProject != null)
+ {
+ dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
+ getLog().debug( "Adding project reference " + mavenProject.getBuild().getOutputDirectory()
+ + " for WEB-INF/classes " );
+ }
+ }
+
+ return dependencyFiles;
+ }
+
+
+ private MavenProject getProjectReferences( Artifact artifact, MavenProject project )
+ {
+ if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
+ {
+ return null;
+ }
+ Collection mavenProjects = project.getProjectReferences().values();
+ for ( MavenProject mavenProject : mavenProjects )
+ {
+ if ( StringUtils.equals( mavenProject.getId(), artifact.getId() ) )
+ {
+ return mavenProject;
+ }
+ }
+ return null;
+ }
+
+
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index 638f8bf9996..a27903ceed5 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -95,10 +95,10 @@ public class JettyWebAppContext extends WebAppContext
private File _classes = null;
private File _testClasses = null;
- private final List _webInfClasses = new ArrayList();
- private final List _webInfJars = new ArrayList();
+ private final List _webInfClasses = new ArrayList<>();
+ private final List _webInfJars = new ArrayList<>();
private final Map _webInfJarMap = new HashMap();
- private List _classpathFiles; //webInfClasses+testClasses+webInfJars
+ private List _classpathFiles = new ArrayList<>(); //webInfClasses+testClasses+webInfJars
private String _jettyEnvXml;
private List _overlays;
private Resource _quickStartWebXml;
@@ -411,7 +411,6 @@ public class JettyWebAppContext extends WebAppContext
_webInfClasses.add(_classes);
// Set up the classpath
- _classpathFiles = new ArrayList();
_classpathFiles.addAll(_webInfClasses);
_classpathFiles.addAll(_webInfJars);
From 3104e2cf249f862a342d0d7299d3ce65d861368d Mon Sep 17 00:00:00 2001
From: Vijay Anand
Date: Sun, 18 Jun 2017 22:45:25 +0530
Subject: [PATCH 057/147] Fix Typo Signed-off-by: Vijay Anand
---
jetty-distribution/src/main/resources/webapps/README.TXT | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-distribution/src/main/resources/webapps/README.TXT b/jetty-distribution/src/main/resources/webapps/README.TXT
index 170137a0ec4..e6536844384 100644
--- a/jetty-distribution/src/main/resources/webapps/README.TXT
+++ b/jetty-distribution/src/main/resources/webapps/README.TXT
@@ -10,7 +10,7 @@ which case the context path is /. If the directory name ends with ".d"
it is ignored (by may be used by explicit configuration).
+ A file called example.war will be deployed as a standard web application
-with the context path /example (eg http://localhost:8080/example/). If he
+with the context path /example (eg http://localhost:8080/example/). If the
base name is root, then the context path is /. If example.war and example/
exist, then only the WAR is deployed (which may use the directory as an
unpack location).
From 11f2cc5294efab09b5b9bfe2118645e2069711fc Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 19 Jun 2017 08:23:56 -0700
Subject: [PATCH 058/147] Updating test to use HttpTester
---
.../jetty/servlet/AsyncContextTest.java | 226 +++++++++---------
1 file changed, 115 insertions(+), 111 deletions(-)
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 dac4f0a0bb3..32f4c8d7aea 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
@@ -18,9 +18,12 @@
package org.eclipse.jetty.servlet;
-import java.io.BufferedReader;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import java.io.StringReader;
import java.util.concurrent.TimeUnit;
import javax.servlet.AsyncContext;
@@ -34,6 +37,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
+import org.eclipse.jetty.http.HttpTester;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpConnectionFactory;
@@ -45,17 +49,9 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
/**
* This tests the correct functioning of the AsyncContext
*
@@ -115,12 +111,14 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- assertThat(responseString, startsWith("HTTP/1.1 200 "));
- assertThat(responseString, containsString("doGet:getServletPath:/servletPath"));
- assertThat(responseString, containsString("doGet:async:getServletPath:/servletPath"));
- assertThat(responseString, containsString("async:run:attr:servletPath:/servletPath"));
+ String responseBody = response.getContent();
+
+ assertThat(responseBody, containsString("doGet:getServletPath:/servletPath"));
+ assertThat(responseBody, containsString("doGet:async:getServletPath:/servletPath"));
+ assertThat(responseBody, containsString("async:run:attr:servletPath:/servletPath"));
}
@Test
@@ -131,12 +129,15 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request,10,TimeUnit.MINUTES);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request,10,TimeUnit.MINUTES));
- assertThat(responseString, startsWith("HTTP/1.1 500 "));
- assertThat(responseString, containsString("ERROR: /error"));
- assertThat(responseString, containsString("PathInfo= /IOE"));
- assertThat(responseString, containsString("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test"));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
+
+ String responseBody = response.getContent();
+
+ assertThat(responseBody, containsString("ERROR: /error"));
+ assertThat(responseBody, containsString("PathInfo= /IOE"));
+ assertThat(responseBody, containsString("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test"));
}
@Test
@@ -147,12 +148,15 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
- assertThat(responseString, startsWith("HTTP/1.1 500 "));
- assertThat(responseString, containsString("ERROR: /error"));
- assertThat(responseString, containsString("PathInfo= /IOE"));
- assertThat(responseString, containsString("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test"));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
+
+ String responseBody = response.getContent();
+
+ assertThat(responseBody, containsString("ERROR: /error"));
+ assertThat(responseBody, containsString("PathInfo= /IOE"));
+ assertThat(responseBody, containsString("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test"));
}
@Test
@@ -163,106 +167,118 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
- BufferedReader br = new BufferedReader(new StringReader(responseString));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- assertEquals("HTTP/1.1 500 Server Error", br.readLine());
- readHeader(br);
- Assert.assertEquals("ERROR: /error", br.readLine());
- Assert.assertEquals("PathInfo= /IOE", br.readLine());
- Assert.assertEquals("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test", br.readLine());
+ String responseBody = response.getContent();
+ assertThat(responseBody, containsString("ERROR: /error"));
+ assertThat(responseBody, containsString("PathInfo= /IOE"));
+ assertThat(responseBody, containsString("EXCEPTION: org.eclipse.jetty.server.QuietServletException: java.io.IOException: Test"));
}
@Test
public void testStartFlushCompleteThrow() throws Exception
{
- try(StacklessLogging stackless = new StacklessLogging(HttpChannel.class))
+ try(StacklessLogging ignore = new StacklessLogging(HttpChannel.class))
{
String request = "GET /ctx/startthrow?flush=true&complete=true HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- BufferedReader br = new BufferedReader(new StringReader(responseString));
+ String responseBody = response.getContent();
- assertEquals("HTTP/1.1 200 OK",br.readLine());
- readHeader(br);
-
- Assert.assertEquals("error servlet","completeBeforeThrow",br.readLine());
+ assertThat("error servlet", responseBody, containsString("completeBeforeThrow"));
}
}
@Test
public void testDispatchAsyncContext() throws Exception
{
- String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
- + "Connection: close\r\n" + "\r\n";
- String responseString = _connector.getResponse(request);
+ String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- BufferedReader br = parseHeader(responseString);
-
- Assert.assertEquals("servlet gets right path", "doGet:getServletPath:/servletPath2", br.readLine());
- Assert.assertEquals("async context gets right path in get", "doGet:async:getServletPath:/servletPath2", br.readLine());
- Assert.assertEquals("servlet path attr is original", "async:run:attr:servletPath:/servletPath", br.readLine());
- Assert.assertEquals("path info attr is correct", "async:run:attr:pathInfo:null", br.readLine());
- Assert.assertEquals("query string attr is correct", "async:run:attr:queryString:dispatch=true", br.readLine());
- Assert.assertEquals("context path attr is correct", "async:run:attr:contextPath:/ctx", br.readLine());
- Assert.assertEquals("request uri attr is correct", "async:run:attr:requestURI:/ctx/servletPath", br.readLine());
+ String responseBody = response.getContent();
+ assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/servletPath2"));
+ assertThat("async context gets right path in get", responseBody, containsString("doGet:async:getServletPath:/servletPath2"));
+ assertThat("servlet path attr is original", responseBody, containsString("async:run:attr:servletPath:/servletPath"));
+ assertThat("path info attr is correct", responseBody, containsString("async:run:attr:pathInfo:null"));
+ assertThat("query string attr is correct", responseBody, containsString("async:run:attr:queryString:dispatch=true"));
+ assertThat("context path attr is correct", responseBody, containsString("async:run:attr:contextPath:/ctx"));
+ assertThat("request uri attr is correct", responseBody, containsString("async:run:attr:requestURI:/ctx/servletPath"));
}
@Test
public void testDispatchAsyncContextEncodedPathAndQueryString() throws Exception
{
- String request = "GET /ctx/path%20with%20spaces/servletPath?dispatch=true&queryStringWithEncoding=space%20space HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
- + "Connection: close\r\n" + "\r\n";
- String responseString = _connector.getResponse(request);
+ String request = "GET /ctx/path%20with%20spaces/servletPath?dispatch=true&queryStringWithEncoding=space%20space HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- BufferedReader br = parseHeader(responseString);
+ String responseBody = response.getContent();
- assertThat("servlet gets right path", br.readLine(), equalTo("doGet:getServletPath:/servletPath2"));
- assertThat("async context gets right path in get", br.readLine(), equalTo("doGet:async:getServletPath:/servletPath2"));
- assertThat("servlet path attr is original", br.readLine(), equalTo("async:run:attr:servletPath:/path with spaces/servletPath"));
- assertThat("path info attr is correct", br.readLine(), equalTo("async:run:attr:pathInfo:null"));
- assertThat("query string attr is correct", br.readLine(), equalTo("async:run:attr:queryString:dispatch=true&queryStringWithEncoding=space%20space"));
- assertThat("context path attr is correct", br.readLine(), equalTo("async:run:attr:contextPath:/ctx"));
- assertThat("request uri attr is correct", br.readLine(), equalTo("async:run:attr:requestURI:/ctx/path%20with%20spaces/servletPath"));
+ assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/servletPath2"));
+ assertThat("async context gets right path in get", responseBody, containsString("doGet:async:getServletPath:/servletPath2"));
+ assertThat("servlet path attr is original", responseBody, containsString("async:run:attr:servletPath:/path with spaces/servletPath"));
+ assertThat("path info attr is correct", responseBody, containsString("async:run:attr:pathInfo:null"));
+ assertThat("query string attr is correct", responseBody, containsString("async:run:attr:queryString:dispatch=true&queryStringWithEncoding=space%20space"));
+ assertThat("context path attr is correct", responseBody, containsString("async:run:attr:contextPath:/ctx"));
+ assertThat("request uri attr is correct", responseBody, containsString("async:run:attr:requestURI:/ctx/path%20with%20spaces/servletPath"));
}
@Test
public void testSimpleWithContextAsyncContext() throws Exception
{
- String request = "GET /ctx/servletPath HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
- + "Connection: close\r\n" + "\r\n";
+ String request = "GET /ctx/servletPath HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- BufferedReader br = parseHeader(responseString);
+ String responseBody = response.getContent();
- Assert.assertEquals("servlet gets right path", "doGet:getServletPath:/servletPath", br.readLine());
- Assert.assertEquals("async context gets right path in get", "doGet:async:getServletPath:/servletPath", br.readLine());
- Assert.assertEquals("async context gets right path in async", "async:run:attr:servletPath:/servletPath", br.readLine());
+ assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/servletPath"));
+ assertThat("async context gets right path in get", responseBody, containsString("doGet:async:getServletPath:/servletPath"));
+ assertThat("async context gets right path in async", responseBody, containsString("async:run:attr:servletPath:/servletPath"));
}
@Test
public void testDispatchWithContextAsyncContext() throws Exception
{
- String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
- + "Connection: close\r\n" + "\r\n";
+ String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- BufferedReader br = parseHeader(responseString);
+ String responseBody = response.getContent();
- Assert.assertEquals("servlet gets right path", "doGet:getServletPath:/servletPath2", br.readLine());
- Assert.assertEquals("async context gets right path in get", "doGet:async:getServletPath:/servletPath2", br.readLine());
- Assert.assertEquals("servlet path attr is original", "async:run:attr:servletPath:/servletPath", br.readLine());
- Assert.assertEquals("path info attr is correct", "async:run:attr:pathInfo:null", br.readLine());
- Assert.assertEquals("query string attr is correct", "async:run:attr:queryString:dispatch=true", br.readLine());
- Assert.assertEquals("context path attr is correct", "async:run:attr:contextPath:/ctx", br.readLine());
- Assert.assertEquals("request uri attr is correct", "async:run:attr:requestURI:/ctx/servletPath", br.readLine());
+ assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/servletPath2"));
+ assertThat("async context gets right path in get", responseBody, containsString("doGet:async:getServletPath:/servletPath2"));
+ assertThat("servlet path attr is original", responseBody, containsString("async:run:attr:servletPath:/servletPath"));
+ assertThat("path info attr is correct", responseBody, containsString("async:run:attr:pathInfo:null"));
+ assertThat("query string attr is correct", responseBody, containsString("async:run:attr:queryString:dispatch=true"));
+ assertThat("context path attr is correct", responseBody, containsString("async:run:attr:contextPath:/ctx"));
+ assertThat("request uri attr is correct", responseBody, containsString("async:run:attr:requestURI:/ctx/servletPath"));
}
@Test
@@ -277,8 +293,11 @@ public class AsyncContextTest
String responseString = _connector.getResponse(request);
System.err.println(responseString);
- BufferedReader br = parseHeader(responseString);
- assertThat("!ForwardingServlet", br.readLine(), equalTo("Dispatched back to ForwardingServlet"));
+ HttpTester.Response response = HttpTester.parseResponse(responseString);
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
+
+ String responseBody = response.getContent();
+ assertThat("!ForwardingServlet", responseBody, containsString("Dispatched back to ForwardingServlet"));
}
@Test
@@ -292,24 +311,12 @@ public class AsyncContextTest
String responseString = _connector.getResponse(request);
- BufferedReader br = parseHeader(responseString);
+ HttpTester.Response response = HttpTester.parseResponse(responseString);
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
- assertThat("!AsyncDispatchingServlet", br.readLine(), equalTo("Dispatched back to AsyncDispatchingServlet"));
- }
+ String responseBody = response.getContent();
- private BufferedReader parseHeader(String responseString) throws IOException
- {
- BufferedReader br = new BufferedReader(new StringReader(responseString));
- assertEquals("HTTP/1.1 200 OK", br.readLine());
- readHeader(br);
- return br;
- }
-
- private void readHeader(BufferedReader br) throws IOException
- {
- String line = br.readLine();
- while (line!=null && !line.isEmpty())
- line = br.readLine();
+ assertThat("!AsyncDispatchingServlet", responseBody, containsString("Dispatched back to AsyncDispatchingServlet"));
}
private class ForwardingServlet extends HttpServlet
@@ -369,13 +376,12 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- BufferedReader br = new BufferedReader(new StringReader(responseString));
+ String responseBody = response.getContent();
- assertEquals("HTTP/1.1 500 Server Error", br.readLine());
- readHeader(br);
- Assert.assertEquals("error servlet", "ERROR: /error", br.readLine());
+ assertThat("error servlet", responseBody, containsString("ERROR: /error"));
}
@Test
@@ -386,16 +392,14 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
- String responseString = _connector.getResponse(request);
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- BufferedReader br = new BufferedReader(new StringReader(responseString));
+ String responseBody = response.getContent();
- assertEquals("HTTP/1.1 500 Server Error", br.readLine());
- readHeader(br);
-
- Assert.assertEquals("error servlet", "ERROR: /error", br.readLine());
- Assert.assertEquals("error servlet", "PathInfo= /500", br.readLine());
- Assert.assertEquals("error servlet", "EXCEPTION: java.lang.RuntimeException: TEST", br.readLine());
+ assertThat("error servlet", responseBody, containsString("ERROR: /error"));
+ assertThat("error servlet", responseBody, containsString("PathInfo= /500"));
+ assertThat("error servlet", responseBody, containsString("EXCEPTION: java.lang.RuntimeException: TEST"));
}
private class DispatchingRunnable implements Runnable
From 4556680ddb8dae48fb7c31e515ee7091918ae04d Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 19 Jun 2017 08:33:12 -0700
Subject: [PATCH 059/147] Issue #1618 - adding testcase to verify AsyncContext
dispatch encoding
---
.../jetty/servlet/AsyncContextTest.java | 74 ++++++++++++++++++-
1 file changed, 71 insertions(+), 3 deletions(-)
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 32f4c8d7aea..465a3b5c513 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
@@ -47,9 +47,11 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -77,6 +79,13 @@ public class AsyncContextTest
_contextHandler.addServlet(new ServletHolder(new TestServlet()), "/servletPath");
_contextHandler.addServlet(new ServletHolder(new TestServlet()), "/path with spaces/servletPath");
_contextHandler.addServlet(new ServletHolder(new TestServlet2()), "/servletPath2");
+
+
+ ServletHolder testHolder = new ServletHolder(new TestServlet());
+ testHolder.setInitParameter("dispatchPath", "/test2/something%2felse");
+ _contextHandler.addServlet(testHolder, "/test/*");
+ _contextHandler.addServlet(new ServletHolder(new TestServlet2()), "/test2/*");
+
_contextHandler.addServlet(new ServletHolder(new TestStartThrowServlet()), "/startthrow/*");
_contextHandler.addServlet(new ServletHolder(new ForwardingServlet()), "/forward");
_contextHandler.addServlet(new ServletHolder(new AsyncDispatchingServlet()), "/dispatchingServlet");
@@ -217,6 +226,40 @@ public class AsyncContextTest
assertThat("request uri attr is correct", responseBody, containsString("async:run:attr:requestURI:/ctx/servletPath"));
}
+ @Test
+ @Ignore("See https://github.com/eclipse/jetty.project/issues/1618")
+ public void testDispatchAsyncContext_EncodedUrl() throws Exception
+ {
+ String request = "GET /ctx/test/hello%2fthere?dispatch=true HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
+
+ String responseBody = response.getContent();
+
+ // initial values
+ assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/test2"));
+ assertThat("request uri has correct encoding", responseBody, containsString("doGet:getRequestURI:/ctx/test2/something%2felse"));
+ assertThat("request url has correct encoding", responseBody, containsString("doGet:getRequestURL:http://localhost/ctx/test2/something%2felse"));
+ assertThat("path info has correct encoding", responseBody, containsString("doGet:getPathInfo:/something%2felse"));
+
+ // async values
+ assertThat("async servlet gets right path", responseBody, containsString("doGet:async:getServletPath:/test2"));
+ assertThat("async request uri has correct encoding", responseBody, containsString("doGet:async:getRequestURI:/ctx/test2/something%2felse"));
+ assertThat("async request url has correct encoding", responseBody, containsString("doGet:async:getRequestURL:http://localhost/ctx/test2/something%2felse"));
+ assertThat("async path info has correct encoding", responseBody, containsString("doGet:async:getPathInfo:/something%2felse"));
+
+ // async run attributes
+ assertThat("async run attr servlet path is original", responseBody, containsString("async:run:attr:servletPath:/test"));
+ assertThat("async run attr path info has correct encoding", responseBody, containsString("async:run:attr:pathInfo:/hello%2fthere"));
+ 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"));
+ }
+
@Test
public void testDispatchAsyncContextEncodedPathAndQueryString() throws Exception
{
@@ -499,6 +542,17 @@ public class AsyncContextTest
private class TestServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
+ private String dispatchPath = "/servletPath2";
+
+ @Override
+ public void init() throws ServletException
+ {
+ String dispatchTo = getServletConfig().getInitParameter("dispatchPath");
+ if (StringUtil.isNotBlank(dispatchTo))
+ {
+ this.dispatchPath = dispatchTo;
+ }
+ }
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
@@ -506,13 +560,20 @@ public class AsyncContextTest
if (request.getParameter("dispatch") != null)
{
AsyncContext asyncContext = request.startAsync(request, response);
- asyncContext.dispatch("/servletPath2");
+ asyncContext.dispatch(dispatchPath);
}
else
{
response.getOutputStream().print("doGet:getServletPath:" + request.getServletPath() + "\n");
+ response.getOutputStream().print("doGet:getRequestURI:" + request.getRequestURI() + "\n");
+ response.getOutputStream().print("doGet:getRequestURL:" + request.getRequestURL() + "\n");
+ response.getOutputStream().print("doGet:getPathInfo:" + request.getPathInfo() + "\n");
AsyncContext asyncContext = request.startAsync(request, response);
- response.getOutputStream().print("doGet:async:getServletPath:" + ((HttpServletRequest)asyncContext.getRequest()).getServletPath() + "\n");
+ HttpServletRequest asyncRequest = (HttpServletRequest)asyncContext.getRequest();
+ response.getOutputStream().print("doGet:async:getServletPath:" + asyncRequest.getServletPath() + "\n");
+ response.getOutputStream().print("doGet:async:getRequestURI:" + asyncRequest.getRequestURI() + "\n");
+ response.getOutputStream().print("doGet:async:getRequestURL:" + asyncRequest.getRequestURL() + "\n");
+ response.getOutputStream().print("doGet:async:getPathInfo:" + asyncRequest.getPathInfo() + "\n");
asyncContext.start(new AsyncRunnable(asyncContext));
}
@@ -527,8 +588,15 @@ public class AsyncContextTest
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.getOutputStream().print("doGet:getServletPath:" + request.getServletPath() + "\n");
+ response.getOutputStream().print("doGet:getRequestURI:" + request.getRequestURI() + "\n");
+ response.getOutputStream().print("doGet:getRequestURL:" + request.getRequestURL() + "\n");
+ response.getOutputStream().print("doGet:getPathInfo:" + request.getPathInfo() + "\n");
AsyncContext asyncContext = request.startAsync(request, response);
- response.getOutputStream().print("doGet:async:getServletPath:" + ((HttpServletRequest)asyncContext.getRequest()).getServletPath() + "\n");
+ HttpServletRequest asyncRequest = (HttpServletRequest)asyncContext.getRequest();
+ response.getOutputStream().print("doGet:async:getServletPath:" + asyncRequest.getServletPath() + "\n");
+ response.getOutputStream().print("doGet:async:getRequestURI:" + asyncRequest.getRequestURI() + "\n");
+ response.getOutputStream().print("doGet:async:getRequestURL:" + asyncRequest.getRequestURL() + "\n");
+ response.getOutputStream().print("doGet:async:getPathInfo:" + asyncRequest.getPathInfo() + "\n");
asyncContext.start(new AsyncRunnable(asyncContext));
}
}
From 8c96fdde4c8e11e9cde999a7fff3a63bde548d4e Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 19 Jun 2017 08:39:39 -0700
Subject: [PATCH 060/147] Issue #1618 - updating testcase expectations for
getPathInfo to match javadoc
---
.../java/org/eclipse/jetty/servlet/AsyncContextTest.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
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 465a3b5c513..4830c61120a 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
@@ -51,7 +51,6 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -227,7 +226,6 @@ public class AsyncContextTest
}
@Test
- @Ignore("See https://github.com/eclipse/jetty.project/issues/1618")
public void testDispatchAsyncContext_EncodedUrl() throws Exception
{
String request = "GET /ctx/test/hello%2fthere?dispatch=true HTTP/1.1\r\n" +
@@ -244,17 +242,17 @@ public class AsyncContextTest
assertThat("servlet gets right path", responseBody, containsString("doGet:getServletPath:/test2"));
assertThat("request uri has correct encoding", responseBody, containsString("doGet:getRequestURI:/ctx/test2/something%2felse"));
assertThat("request url has correct encoding", responseBody, containsString("doGet:getRequestURL:http://localhost/ctx/test2/something%2felse"));
- assertThat("path info has correct encoding", responseBody, containsString("doGet:getPathInfo:/something%2felse"));
+ assertThat("path info has correct encoding", responseBody, containsString("doGet:getPathInfo:/something/else"));
// async values
assertThat("async servlet gets right path", responseBody, containsString("doGet:async:getServletPath:/test2"));
assertThat("async request uri has correct encoding", responseBody, containsString("doGet:async:getRequestURI:/ctx/test2/something%2felse"));
assertThat("async request url has correct encoding", responseBody, containsString("doGet:async:getRequestURL:http://localhost/ctx/test2/something%2felse"));
- assertThat("async path info has correct encoding", responseBody, containsString("doGet:async:getPathInfo:/something%2felse"));
+ assertThat("async path info has correct encoding", responseBody, containsString("doGet:async:getPathInfo:/something/else"));
// async run attributes
assertThat("async run attr servlet path is original", responseBody, containsString("async:run:attr:servletPath:/test"));
- assertThat("async run attr path info has correct encoding", responseBody, containsString("async:run:attr:pathInfo:/hello%2fthere"));
+ assertThat("async run attr path info has correct encoding", responseBody, containsString("async:run:attr:pathInfo:/hello/there"));
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"));
From 61904052f4058efa73a4be4158ee822b9f0f008b Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 19 Jun 2017 13:38:19 -0700
Subject: [PATCH 061/147] Issue #1618 - new testcase for
startAsync(req,resp).dispatch() behavior with regards to URL/URI
---
.../jetty/servlet/AsyncContextTest.java | 44 ++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
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 4830c61120a..884396bcd62 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
@@ -51,6 +51,7 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -79,12 +80,13 @@ public class AsyncContextTest
_contextHandler.addServlet(new ServletHolder(new TestServlet()), "/path with spaces/servletPath");
_contextHandler.addServlet(new ServletHolder(new TestServlet2()), "/servletPath2");
-
ServletHolder testHolder = new ServletHolder(new TestServlet());
testHolder.setInitParameter("dispatchPath", "/test2/something%2felse");
_contextHandler.addServlet(testHolder, "/test/*");
_contextHandler.addServlet(new ServletHolder(new TestServlet2()), "/test2/*");
+ _contextHandler.addServlet(new ServletHolder(new SelfDispatchingServlet()), "/self/*");
+
_contextHandler.addServlet(new ServletHolder(new TestStartThrowServlet()), "/startthrow/*");
_contextHandler.addServlet(new ServletHolder(new ForwardingServlet()), "/forward");
_contextHandler.addServlet(new ServletHolder(new AsyncDispatchingServlet()), "/dispatchingServlet");
@@ -258,6 +260,24 @@ public class AsyncContextTest
assertThat("async run request uri has correct encoding", responseBody, containsString("async:run:attr:requestURI:/ctx/test/hello%2fthere"));
}
+ @Test
+ @Ignore("See https://github.com/eclipse/jetty.project/issues/1618")
+ public void testDispatchAsyncContext_SelfEncodedUrl() throws Exception
+ {
+ String request = "GET /ctx/self/hello%2fthere?dispatch=true HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
+ assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
+
+ String responseBody = response.getContent();
+
+ assertThat("servlet request uri initial", responseBody, containsString("doGet:REQUEST.requestURI:/ctx/self/hello%2fthere"));
+ assertThat("servlet request uri async", responseBody, containsString("doGet:ASYNC.requestURI:/ctx/self/hello%2fthere"));
+ }
+
@Test
public void testDispatchAsyncContextEncodedPathAndQueryString() throws Exception
{
@@ -378,6 +398,28 @@ public class AsyncContextTest
}
}
+ private class SelfDispatchingServlet extends HttpServlet
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
+ {
+ DispatcherType dispatcherType = request.getDispatcherType();
+ response.getOutputStream().print("doGet." + dispatcherType.name() + ".requestURI:" + request.getRequestURI() + "\n");
+
+ if (dispatcherType == DispatcherType.ASYNC)
+ {
+ response.getOutputStream().print("Dispatched back to " + SelfDispatchingServlet.class.getSimpleName() + "\n");
+ }
+ else
+ {
+ final AsyncContext asyncContext = request.startAsync(request, response);
+ new Thread(() -> asyncContext.dispatch()).start();
+ }
+ }
+ }
+
private class AsyncDispatchingServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
From b81115dfbc1e0767af01c20fef50277af8b24554 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Tue, 20 Jun 2017 09:08:19 -0400
Subject: [PATCH 062/147] Updating SSL documentation for clarity.
---
.../connectors/configuring-ssl.adoc | 58 ++++++++-----------
1 file changed, 23 insertions(+), 35 deletions(-)
diff --git a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
index e9c7fe131ae..62a1a3bbdf3 100644
--- a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
+++ b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
@@ -363,10 +363,15 @@ An example of this setup:
[source, plain, subs="{sub-order}"]
----
$ cd /path/to/mybase
+$ java -jar ../start.jar --create-startd
+MKDIR : ${jetty.base}/start.d
+INFO : Base directory was modified
$ java -jar /path/to/jetty-dist/start.jar --add-to-start=ssl
-INFO : server initialised (transitively) in ${jetty.base}/start.d/server.ini
-INFO : ssl initialised in ${jetty.base}/start.d/ssl.ini
-INFO : Base directory was modified
+INFO : server transitively enabled, ini template available with --add-to-start=server
+INFO : ssl initialized in ${jetty.base}/start.d/ssl.ini
+MKDIR : ${jetty.base}/etc
+COPY : ${jetty.home}/modules/ssl/keystore to ${jetty.base}/etc/keystore
+INFO : Base directory was modified
$ tree
.
├── etc
@@ -394,44 +399,30 @@ jetty.sslContext.keyStorePassword::
[[two-way-authentication]]
==== Two Way Authentication
-To enable two-way authentication, you first need to activate the ssl module as shown in the previous section.
+To enable two-way authentication both the `ssl` and `https` modules need to be activated.
+Once enabled, set the `jetty.sslContext.needClientAuth` property to `true`.
-First you need load the `ssl` module and `https` module.
[source%nowrap,ini,linenums]
.$JETTY_BASE/start.d/ssl.ini
----
# Module: ssl
--module=ssl
-
-jetty.ssl.host=0.0.0.0
-jetty.ssl.port=8583
-jetty.sslContext.keyStorePath=etc/keystore
-jetty.sslContext.trustStorePath=etc/keystore
-jetty.sslContext.keyStorePassword=OBF:
-jetty.sslContext.keyManagerPassword=OBF:
-jetty.sslContext.trustStorePassword=OBF:
-jetty.sslContext.trustStoreType=JKS
-# enable two way authentication
+...
+## whether client certificate authentication is required
jetty.sslContext.needClientAuth=true
-----
-
-[source%nowrap,ini,linenums]
-.$JETTY_BASE/start.d/https.ini
-----
-# Module: https
---module=https
+...
----
[[layout-of-keystore-and-truststore]]
-===== Layout of `keystore` and `truststore`
+==== Layout of keystore and truststore
-`keystore` only contains the server's private key and certificate.
+The server's private key and certificate are contained within the keystore.
[[img-certificate-chain]]
image::images/certificate-chain.png[title="Certificate chain", alt="Certificate chain"]
[literal]
-.The structure of KeyStore file
+.The structure of a KeyStore file
....
├── PrivateKeyEntry
│  ├── PrivateKey
@@ -447,11 +438,7 @@ image::images/certificate-chain.png[title="Certificate chain", alt="Certificate
[TIP]
====
-└── PrivateKeyEntry +
-   └── Certificate chain +
-     ├── Intermediary CA certificate +
-     └── Root CA certificate +
-are optional
+`PrivateKeyEntry`, `Certificate chain`, `Intermediary CA certificate` and `Root CA certificate` are all optional values.
====
[source%nowrap,plain,linenums]
@@ -709,9 +696,10 @@ KeyIdentifier [
*******************************************
----
-In addition, you can split `$JETTY/etc/keystore` as two files.
-One is `$JETTY/etc/keystore` which only contains the server’s private key and certificate,
-the other is `$JETTY/etc/truststore` which contains intermediary CA and root CA.
+Additionally, you can split `$JETTY/etc/keystore` into two files.
+One being `$JETTY/etc/keystore` which only contains the server’s private key and certificate, while the other would be `$JETTY/etc/truststore` which contains intermediary CA and root CA.
+
+An example of this would look like the following:
[literal]
.The structure of `$JETTY/etc/keystore`
@@ -759,7 +747,7 @@ setKeyStorePath::
The configured keystore to use for all SSL/TLS in configured Jetty Connector (or Client).
____
[NOTE]
-As a keystore is vital security information, it can be desirable to locate the file in a directory with *very* restricted access.
+As the keystore is vital security information, it recommended the file is located in a directory with *very* restricted access.
____
setKeyStorePassword::
@@ -784,7 +772,7 @@ ____
____
[CAUTION]
-The keystore and truststore passwords may also be set using the system properties: `org.eclipse.jetty.ssl.keypassword` `org.eclipse.jetty.ssl.password`.
+The keystore and truststore passwords may also be set using the system properties: `org.eclipse.jetty.ssl.keypassword` and `org.eclipse.jetty.ssl.password`.
This is _not_ a recommended usage.
____
From c9a1395f08a06a523ac6654d1781f8f007a09cf9 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Wed, 21 Jun 2017 10:28:26 +0200
Subject: [PATCH 063/147] Issue #1618 Async dispatch encoded passed URI
---
.../main/java/org/eclipse/jetty/server/Request.java | 10 +++++++++-
.../org/eclipse/jetty/servlet/AsyncContextTest.java | 6 ++----
2 files changed, 11 insertions(+), 5 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 ed6b8525e7b..d84f7e5713e 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
@@ -2258,7 +2258,15 @@ public class Request implements HttpServletRequest
_async=new AsyncContextState(state);
AsyncContextEvent event = new AsyncContextEvent(_context,_async,state,this,servletRequest,servletResponse);
event.setDispatchContext(getServletContext());
- event.setDispatchPath(URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo())));
+
+ String uri = ((HttpServletRequest)servletRequest).getRequestURI();
+ if (uri.startsWith(_contextPath))
+ uri = uri.substring(_contextPath.length());
+ else
+ // TODO probably need to strip encoded context from requestURI, but will do this for now:
+ uri = URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo()));
+
+ event.setDispatchPath(uri);
state.startAsync(event);
return _async;
}
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 884396bcd62..ed11db421a9 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
@@ -261,7 +261,6 @@ public class AsyncContextTest
}
@Test
- @Ignore("See https://github.com/eclipse/jetty.project/issues/1618")
public void testDispatchAsyncContext_SelfEncodedUrl() throws Exception
{
String request = "GET /ctx/self/hello%2fthere?dispatch=true HTTP/1.1\r\n" +
@@ -274,8 +273,8 @@ public class AsyncContextTest
String responseBody = response.getContent();
- assertThat("servlet request uri initial", responseBody, containsString("doGet:REQUEST.requestURI:/ctx/self/hello%2fthere"));
- assertThat("servlet request uri async", responseBody, containsString("doGet:ASYNC.requestURI:/ctx/self/hello%2fthere"));
+ assertThat("servlet request uri initial", responseBody, containsString("doGet.REQUEST.requestURI:/ctx/self/hello%2fthere"));
+ assertThat("servlet request uri async", responseBody, containsString("doGet.ASYNC.requestURI:/ctx/self/hello%2fthere"));
}
@Test
@@ -353,7 +352,6 @@ public class AsyncContextTest
"\r\n";
String responseString = _connector.getResponse(request);
- System.err.println(responseString);
HttpTester.Response response = HttpTester.parseResponse(responseString);
assertThat("Response.status", response.getStatus(), is(HttpServletResponse.SC_OK));
From a105be95e44fae91fcf8b85b5d6d0f78fd143a04 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Wed, 21 Jun 2017 11:48:41 +0200
Subject: [PATCH 064/147] Issue #1637 Thread per HTTP/2 Connection
This fix simplifies the EWYK scheduler by factoring out the preallocated producer into a
ReservedThreadExecutor class. A shared ReservedThreadExecutor can then be used by multiple
EWYK instances to avoid over allocation of threads.
Squashed commit of the following:
commit c435dc20e25bd274d69423be1be7b0565925f249
Merge: 58a5a9a 90e5b56
Author: Greg Wilkins
Date: Wed Jun 21 10:48:22 2017 +0200
Merge branch 'jetty-9.4.x' into jetty-9.4.x-ewyk3
commit 58a5a9a655ee1a72a66f54ac8c95d7c9d73afe85
Author: Simone Bordet
Date: Wed Jun 14 15:56:43 2017 +0200
Code cleanups.
commit 4e5296216b52948523572352cba391438ff6b494
Author: Greg Wilkins
Date: Wed Jun 14 07:34:58 2017 +0200
refixed Producing to Reproducing
commit a1f8682f86d1f0803121162e3f14d7768286d3ed
Author: Greg Wilkins
Date: Wed Jun 14 07:26:29 2017 +0200
fixed Producing to Reproducing
commit 9468932e062d2271d8dc1d43a78544757732fff5
Author: Greg Wilkins
Date: Tue Jun 13 16:33:44 2017 +0200
fixed javadoc
commit 9d4941eb97638fec09b3fe34d423538d17943b6f
Author: Greg Wilkins
Date: Tue Jun 13 16:05:27 2017 +0200
Renamed Preallocated to ReservedThread
commit 6d3379ab64c6dcc2a7aa8ec7088afd77863816c2
Author: Greg Wilkins
Date: Tue Jun 13 12:28:52 2017 +0200
Added configuration in modules
commit 1bd1adea4682538e1546c2ae53f4c9340dafb3bb
Merge: 83418a9 6702248
Author: Greg Wilkins
Date: Tue Jun 13 10:09:29 2017 +0200
Merge branch 'jetty-9.4.x' into jetty-9.4.x-ewyk3
commit 83418a91320c8bfc54465ca02efdce0d2c874a0e
Author: Greg Wilkins
Date: Tue Jun 13 10:08:35 2017 +0200
javadoc
commit 62918fd39189fed3414fec4a7c8380c21e90a4b8
Author: Greg Wilkins
Date: Sat Jun 10 00:04:06 2017 +0200
Improved EatWhatYouKill implementation
Simplified by abstracting out PreallocatedExecutor
Removed invocation execution
HTTP2 now uses a shared PreallocationExcecutor between connection
---
.../client/HTTP2ClientConnectionFactory.java | 33 +-
.../eclipse/jetty/http2/HTTP2Connection.java | 14 +-
.../src/main/config/etc/jetty-http2.xml | 6 +-
.../src/main/config/modules/http2.mod | 11 +-
.../AbstractHTTP2ServerConnectionFactory.java | 43 ++-
.../http2/server/HTTP2ServerConnection.java | 3 +-
.../http2/server/HttpChannelOverHTTP2.java | 9 +-
.../org/eclipse/jetty/io/ManagedSelector.java | 22 +-
.../org/eclipse/jetty/io/SelectorManager.java | 38 +-
.../maven/plugin/MavenServerConnector.java | 4 +-
.../src/main/config/etc/jetty-http.xml | 4 +
.../src/main/config/etc/jetty-ssl.xml | 4 +
jetty-server/src/main/config/modules/http.mod | 6 +
jetty-server/src/main/config/modules/ssl.mod | 6 +
.../org/eclipse/jetty/server/Connector.java | 3 +-
.../eclipse/jetty/server/ServerConnector.java | 1 +
.../jetty/util/component/Container.java | 26 ++
.../util/component/ContainerLifeCycle.java | 3 +
.../eclipse/jetty/util/thread/Invocable.java | 80 -----
.../jetty/util/thread/QueuedThreadPool.java | 20 +-
.../util/thread/ReservedThreadExecutor.java | 235 ++++++++++++
.../util/thread/strategy/EatWhatYouKill.java | 339 +++++++-----------
.../strategy/ExecuteProduceConsume.java | 15 +-
.../strategy/ProduceExecuteConsume.java | 10 +-
.../thread/ReservedThreadExecutorTest.java | 204 +++++++++++
.../strategy/ExecutionStrategyTest.java | 4 +-
26 files changed, 804 insertions(+), 339 deletions(-)
create mode 100644 jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
create mode 100644 jetty-util/src/test/java/org/eclipse/jetty/util/thread/ReservedThreadExecutorTest.java
diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java
index 7b0d8ad39a6..3a356bc7445 100644
--- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java
+++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientConnectionFactory.java
@@ -39,6 +39,7 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.component.LifeCycle;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
import org.eclipse.jetty.util.thread.Scheduler;
public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
@@ -46,6 +47,7 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
public static final String CLIENT_CONTEXT_KEY = "http2.client";
public static final String BYTE_BUFFER_POOL_CONTEXT_KEY = "http2.client.byteBufferPool";
public static final String EXECUTOR_CONTEXT_KEY = "http2.client.executor";
+ public static final String PREALLOCATED_EXECUTOR_CONTEXT_KEY = "http2.client.preallocatedExecutor";
public static final String SCHEDULER_CONTEXT_KEY = "http2.client.scheduler";
public static final String SESSION_LISTENER_CONTEXT_KEY = "http2.client.sessionListener";
public static final String SESSION_PROMISE_CONTEXT_KEY = "http2.client.sessionPromise";
@@ -58,6 +60,7 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY);
ByteBufferPool byteBufferPool = (ByteBufferPool)context.get(BYTE_BUFFER_POOL_CONTEXT_KEY);
Executor executor = (Executor)context.get(EXECUTOR_CONTEXT_KEY);
+ ReservedThreadExecutor preallocatedExecutor = (ReservedThreadExecutor)context.get(PREALLOCATED_EXECUTOR_CONTEXT_KEY);
Scheduler scheduler = (Scheduler)context.get(SCHEDULER_CONTEXT_KEY);
Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY);
@SuppressWarnings("unchecked")
@@ -67,7 +70,33 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
FlowControlStrategy flowControl = client.getFlowControlStrategyFactory().newFlowControlStrategy();
HTTP2ClientSession session = new HTTP2ClientSession(scheduler, endPoint, generator, listener, flowControl);
Parser parser = new Parser(byteBufferPool, session, 4096, 8192);
- HTTP2ClientConnection connection = new HTTP2ClientConnection(client, byteBufferPool, executor, endPoint,
+
+ if (preallocatedExecutor==null)
+ {
+ // TODO move this to non lazy construction
+ preallocatedExecutor=client.getBean(ReservedThreadExecutor.class);
+ if (preallocatedExecutor==null)
+ {
+ synchronized (this)
+ {
+ if (preallocatedExecutor==null)
+ {
+ try
+ {
+ preallocatedExecutor = new ReservedThreadExecutor(executor,1); // TODO configure size
+ preallocatedExecutor.start();
+ client.addBean(preallocatedExecutor,true);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+
+ HTTP2ClientConnection connection = new HTTP2ClientConnection(client, byteBufferPool, preallocatedExecutor, endPoint,
parser, session, client.getInputBufferSize(), promise, listener);
connection.addListener(connectionListener);
return customize(connection, context);
@@ -79,7 +108,7 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
private final Promise promise;
private final Session.Listener listener;
- private HTTP2ClientConnection(HTTP2Client client, ByteBufferPool byteBufferPool, Executor executor, EndPoint endpoint, Parser parser, ISession session, int bufferSize, Promise promise, Session.Listener listener)
+ private HTTP2ClientConnection(HTTP2Client client, ByteBufferPool byteBufferPool, ReservedThreadExecutor executor, EndPoint endpoint, Parser parser, ISession session, int bufferSize, Promise promise, Session.Listener listener)
{
super(byteBufferPool, executor, endpoint, parser, session, bufferSize);
this.client = client;
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java
index 65a04cbd0e6..39350c2e70b 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Connection.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ExecutionStrategy;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill;
public class HTTP2Connection extends AbstractConnection
@@ -50,14 +51,14 @@ public class HTTP2Connection extends AbstractConnection
private final int bufferSize;
private final ExecutionStrategy strategy;
- public HTTP2Connection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, Parser parser, ISession session, int bufferSize)
+ public HTTP2Connection(ByteBufferPool byteBufferPool, ReservedThreadExecutor executor, EndPoint endPoint, Parser parser, ISession session, int bufferSize)
{
- super(endPoint, executor);
+ super(endPoint, executor.getExecutor());
this.byteBufferPool = byteBufferPool;
this.parser = parser;
this.session = session;
this.bufferSize = bufferSize;
- this.strategy = new EatWhatYouKill(producer, executor, 0);
+ this.strategy = new EatWhatYouKill(producer, executor.getExecutor(), executor);
LifeCycle.start(strategy);
}
@@ -147,7 +148,10 @@ public class HTTP2Connection extends AbstractConnection
protected void offerTask(Runnable task, boolean dispatch)
{
offerTask(task);
- strategy.dispatch();
+ if (dispatch)
+ strategy.dispatch();
+ else
+ strategy.produce();
}
@Override
@@ -180,7 +184,7 @@ public class HTTP2Connection extends AbstractConnection
private ByteBuffer buffer;
@Override
- public synchronized Runnable produce()
+ public Runnable produce()
{
Runnable task = pollTask();
if (LOG.isDebugEnabled())
diff --git a/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml b/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml
index 226941d5e71..1d6423589e3 100644
--- a/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml
+++ b/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml
@@ -9,8 +9,10 @@
-
-
+
+
+
+
diff --git a/jetty-http2/http2-server/src/main/config/modules/http2.mod b/jetty-http2/http2-server/src/main/config/modules/http2.mod
index e1e700ba372..2ffa068ede6 100644
--- a/jetty-http2/http2-server/src/main/config/modules/http2.mod
+++ b/jetty-http2/http2-server/src/main/config/modules/http2.mod
@@ -20,7 +20,14 @@ etc/jetty-http2.xml
[ini-template]
## Max number of concurrent streams per connection
-# jetty.http2.maxConcurrentStreams=1024
+# jetty.http2.maxConcurrentStreams=128
## Initial stream receive window (client to server)
-# jetty.http2.initialStreamRecvWindow=65535
+# jetty.http2.initialStreamRecvWindow=524288
+
+## Initial session receive window (client to server)
+# jetty.http2.initialSessionRecvWindow=1048576
+
+## Reserve threads for high priority tasks (-1 use number of Selectors, 0 no reserved threads)
+# jetty.http2.reservedThreads=-1
+
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java
index 82ed664041e..b0e6c8d2dbe 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.component.LifeCycle;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
@ManagedObject
public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConnectionFactory
@@ -48,6 +49,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
private int maxHeaderBlockFragment = 0;
private FlowControlStrategy.Factory flowControlStrategyFactory = () -> new BufferingFlowControlStrategy(0.5F);
private long streamIdleTimeout;
+ private int reservedThreads = -1;
public AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration)
{
@@ -108,6 +110,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
this.maxConcurrentStreams = maxConcurrentStreams;
}
+ @ManagedAttribute("The max header block fragment")
public int getMaxHeaderBlockFragment()
{
return maxHeaderBlockFragment;
@@ -139,6 +142,21 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
this.streamIdleTimeout = streamIdleTimeout;
}
+ /**
+ * @see ReservedThreadExecutor
+ * @return The number of reserved threads
+ */
+ @ManagedAttribute("The number of threads reserved for high priority tasks")
+ public int getReservedThreads()
+ {
+ return reservedThreads;
+ }
+
+ public void setReservedThreads(int threads)
+ {
+ this.reservedThreads = threads;
+ }
+
public HttpConfiguration getHttpConfiguration()
{
return httpConfiguration;
@@ -163,9 +181,32 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
streamIdleTimeout = endPoint.getIdleTimeout();
session.setStreamIdleTimeout(streamIdleTimeout);
session.setInitialSessionRecvWindow(getInitialSessionRecvWindow());
+
+ ReservedThreadExecutor executor = connector.getBean(ReservedThreadExecutor.class);
+ if (executor==null)
+ {
+ synchronized (this)
+ {
+ executor = connector.getBean(ReservedThreadExecutor.class);
+ if (executor==null)
+ {
+ try
+ {
+ executor = new ReservedThreadExecutor(connector.getExecutor(),getReservedThreads());
+ executor.start();
+ connector.addBean(executor,true);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
ServerParser parser = newServerParser(connector, session);
- HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), connector.getExecutor(),
+ HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), executor,
endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener);
connection.addListener(connectionListener);
return configure(connection, connector, endPoint);
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
index 18e6d47c22a..a1f9ed0d394 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
@@ -56,6 +56,7 @@ import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.TypeUtil;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
public class HTTP2ServerConnection extends HTTP2Connection implements Connection.UpgradeTo
{
@@ -91,7 +92,7 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
private final HttpConfiguration httpConfig;
private boolean recycleHttpChannels;
- public HTTP2ServerConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, ISession session, int inputBufferSize, ServerSessionListener listener)
+ public HTTP2ServerConnection(ByteBufferPool byteBufferPool, ReservedThreadExecutor executor, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, ISession session, int inputBufferSize, ServerSessionListener listener)
{
super(byteBufferPool, executor, endPoint, parser, session, inputBufferSize);
this.listener = listener;
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java
index 81a8cc490ff..6487577ba87 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpChannelOverHTTP2.java
@@ -18,6 +18,7 @@
package org.eclipse.jetty.http2.server;
+import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -46,7 +47,7 @@ import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class HttpChannelOverHTTP2 extends HttpChannel
+public class HttpChannelOverHTTP2 extends HttpChannel implements Closeable
{
private static final Logger LOG = Log.getLogger(HttpChannelOverHTTP2.class);
private static final HttpField SERVER_VERSION = new PreEncodedHttpField(HttpHeader.SERVER, HttpConfiguration.SERVER_VERSION);
@@ -377,6 +378,12 @@ public class HttpChannelOverHTTP2 extends HttpChannel
}
}
+ @Override
+ public void close()
+ {
+ abort(new IOException("Unexpected close"));
+ }
+
@Override
public String toString()
{
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
index 8868befb44c..1af25a979f4 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
@@ -38,7 +38,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
@@ -47,10 +46,9 @@ import org.eclipse.jetty.util.thread.ExecutionStrategy;
import org.eclipse.jetty.util.thread.Invocable;
import org.eclipse.jetty.util.thread.Invocable.InvocationType;
import org.eclipse.jetty.util.thread.Locker;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill;
-import org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume;
-import org.eclipse.jetty.util.thread.strategy.ProduceExecuteConsume;
/**
*
{@link ManagedSelector} wraps a {@link Selector} simplifying non-blocking operations on channels.
{@link SelectorManager} manages a number of {@link ManagedSelector}s that
@@ -42,6 +45,8 @@ import org.eclipse.jetty.util.thread.Scheduler;
*
{@link SelectorManager} subclasses implement methods to return protocol-specific
* {@link EndPoint}s and {@link Connection}s.
*/
+
+@ManagedObject("Manager of the NIO Selectors")
public abstract class SelectorManager extends ContainerLifeCycle implements Dumpable
{
public static final int DEFAULT_CONNECT_TIMEOUT = 15000;
@@ -52,6 +57,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
private final ManagedSelector[] _selectors;
private long _connectTimeout = DEFAULT_CONNECT_TIMEOUT;
private long _selectorIndex;
+ private int _reservedThreads = -2;
protected SelectorManager(Executor executor, Scheduler scheduler)
{
@@ -67,11 +73,13 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
_selectors = new ManagedSelector[selectors];
}
+ @ManagedAttribute("The Executor")
public Executor getExecutor()
{
return executor;
}
+ @ManagedAttribute("The Scheduler")
public Scheduler getScheduler()
{
return scheduler;
@@ -82,6 +90,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
*
* @return the connect timeout (in milliseconds)
*/
+ @ManagedAttribute("The Connection timeout (ms)")
public long getConnectTimeout()
{
return _connectTimeout;
@@ -97,6 +106,30 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
_connectTimeout = milliseconds;
}
+ /**
+ * Get the number of preallocated producing threads
+ * @see EatWhatYouKill
+ * @see ReservedThreadExecutor
+ * @return The number of threads preallocated to producing (default 1).
+ */
+ @ManagedAttribute("The number of preallocated producer threads")
+ public int getReservedThreads()
+ {
+ return _reservedThreads;
+ }
+
+ /**
+ * Set the number of preallocated threads for high priority tasks
+ * @see EatWhatYouKill
+ * @see ReservedThreadExecutor
+ * @param threads The number of producing threads to preallocate (default 1).
+ * The EatWhatYouKill scheduler will be disabled with a value of 0.
+ */
+ public void setReservedThreads(int threads)
+ {
+ _reservedThreads = threads;
+ }
+
/**
* Executes the given task in a different thread.
*
@@ -110,6 +143,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
/**
* @return the number of selectors in use
*/
+ @ManagedAttribute("The number of NIO Selectors")
public int getSelectorCount()
{
return _selectors.length;
@@ -231,6 +265,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
@Override
protected void doStart() throws Exception
{
+ addBean(new ReservedThreadExecutor(getExecutor(),_reservedThreads==-2?_selectors.length:_reservedThreads),true);
for (int i = 0; i < _selectors.length; i++)
{
ManagedSelector selector = newSelector(i);
@@ -373,4 +408,5 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
* @throws IOException if unable to create new connection
*/
public abstract Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException;
+
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
index b5cc6360b69..075f4d9c66b 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
@@ -31,7 +31,7 @@ import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.thread.Scheduler;
@@ -45,7 +45,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
* be referenced in the pom.xml. This class wraps a ServerConnector, delaying setting the
* server instance. Only a few of the setters from the ServerConnector class are supported.
*/
-public class MavenServerConnector extends AbstractLifeCycle implements Connector
+public class MavenServerConnector extends ContainerLifeCycle implements Connector
{
public static String PORT_SYSPROPERTY = "jetty.http.port";
diff --git a/jetty-server/src/main/config/etc/jetty-http.xml b/jetty-server/src/main/config/etc/jetty-http.xml
index 70d317bab86..93ce0739193 100644
--- a/jetty-server/src/main/config/etc/jetty-http.xml
+++ b/jetty-server/src/main/config/etc/jetty-http.xml
@@ -40,6 +40,10 @@
+
+
+
+
diff --git a/jetty-server/src/main/config/etc/jetty-ssl.xml b/jetty-server/src/main/config/etc/jetty-ssl.xml
index a079c1f6ab2..956809bda28 100644
--- a/jetty-server/src/main/config/etc/jetty-ssl.xml
+++ b/jetty-server/src/main/config/etc/jetty-ssl.xml
@@ -32,6 +32,10 @@
+
+
+
+
diff --git a/jetty-server/src/main/config/modules/http.mod b/jetty-server/src/main/config/modules/http.mod
index fa13822fff5..d833a6da297 100644
--- a/jetty-server/src/main/config/modules/http.mod
+++ b/jetty-server/src/main/config/modules/http.mod
@@ -40,5 +40,11 @@ etc/jetty-http.xml
## Thread priority delta to give to acceptor threads
# jetty.http.acceptorPriorityDelta=0
+## Reserve threads for high priority tasks (-2 use number of selectors,-1 use number of CPUs, 0 no reserved threads)
+# jetty.http.reservedThreads=-2
+
+## Connect Timeout in milliseconds
+# jetty.http.connectTimeout=15000
+
## HTTP Compliance: RFC7230, RFC2616, LEGACY
# jetty.http.compliance=RFC7230
diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod
index 3efb90e3b93..cac38448246 100644
--- a/jetty-server/src/main/config/modules/ssl.mod
+++ b/jetty-server/src/main/config/modules/ssl.mod
@@ -44,6 +44,12 @@ basehome:modules/ssl/keystore|etc/keystore
## Thread priority delta to give to acceptor threads
# jetty.ssl.acceptorPriorityDelta=0
+## Preallocated producer threads (0 disables EatWhatYouKill scheduling)
+# jetty.ssl.reservedThreads=-1
+
+## Connect Timeout in milliseconds
+# jetty.ssl.connectTimeout=15000
+
## Whether request host names are checked to match any SNI names
# jetty.ssl.sniHostCheck=true
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java
index 8b2f3707dbd..2e38fc81ba5 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Connector.java
@@ -27,6 +27,7 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
+import org.eclipse.jetty.util.component.Container;
import org.eclipse.jetty.util.component.Graceful;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.thread.Scheduler;
@@ -37,7 +38,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
* the machinery needed to handle such tasks.
*/
@ManagedObject("Connector Interface")
-public interface Connector extends LifeCycle, Graceful
+public interface Connector extends LifeCycle, Container, Graceful
{
/**
* @return the {@link Server} instance associated with this {@link Connector}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
index db6a05e17f8..4137f226e0c 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
@@ -378,6 +378,7 @@ public class ServerConnector extends AbstractNetworkConnector
}
}
+ @ManagedAttribute("The Selector Manager")
public SelectorManager getSelectorManager()
{
return _manager;
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java
index 260e4451a2a..6a582351cb1 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/Container.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.util.component;
import java.util.Collection;
+
/**
* A Container
*/
@@ -76,6 +77,31 @@ public interface Container
*/
public void removeEventListener(Listener listener);
+ /**
+ * Unmanages a bean already contained by this aggregate, so that it is not started/stopped/destroyed with this
+ * aggregate.
+ *
+ * @param bean The bean to unmanage (must already have been added).
+ */
+ void unmanage(Object bean);
+
+ /**
+ * Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this
+ * aggregate.
+ *
+ * @param bean The bean to manage (must already have been added).
+ */
+ void manage(Object bean);
+
+ /**
+ * Adds the given bean, explicitly managing it or not.
+ *
+ * @param o The bean object to add
+ * @param managed whether to managed the lifecycle of the bean
+ * @return true if the bean was added, false if it was already present
+ */
+ boolean addBean(Object o, boolean managed);
+
/**
* A listener for Container events.
* If an added bean implements this interface it will receive the events
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java
index fdc0b9cd60e..533c1949537 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java
@@ -236,6 +236,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
* @param managed whether to managed the lifecycle of the bean
* @return true if the bean was added, false if it was already present
*/
+ @Override
public boolean addBean(Object o, boolean managed)
{
if (o instanceof LifeCycle)
@@ -380,6 +381,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
*
* @param bean The bean to manage (must already have been added).
*/
+ @Override
public void manage(Object bean)
{
for (Bean b : _beans)
@@ -426,6 +428,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
*
* @param bean The bean to unmanage (must already have been added).
*/
+ @Override
public void unmanage(Object bean)
{
for (Bean b : _beans)
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Invocable.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Invocable.java
index cb926417b28..e060a4b30ad 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Invocable.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Invocable.java
@@ -186,84 +186,4 @@ public interface Invocable
return InvocationType.BLOCKING;
}
- /**
- * An Executor wrapper that knows about Invocable
- *
- */
- public static class InvocableExecutor implements Executor
- {
- private static final Logger LOG = Log.getLogger(InvocableExecutor.class);
-
- private final Executor _executor;
- private final InvocationType _preferredInvocationForExecute;
- private final InvocationType _preferredInvocationForInvoke;
-
- public InvocableExecutor(Executor executor,InvocationType preferred)
- {
- this(executor,preferred,preferred);
- }
-
- public InvocableExecutor(Executor executor,InvocationType preferredInvocationForExecute,InvocationType preferredInvocationForIvoke)
- {
- _executor=executor;
- _preferredInvocationForExecute=preferredInvocationForExecute;
- _preferredInvocationForInvoke=preferredInvocationForIvoke;
- }
-
- public Invocable.InvocationType getPreferredInvocationType()
- {
- return _preferredInvocationForInvoke;
- }
-
- public void invoke(Runnable task)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("{} invoke {}", this, task);
- Invocable.invokePreferred(task,_preferredInvocationForInvoke);
- if (LOG.isDebugEnabled())
- LOG.debug("{} invoked {}", this, task);
- }
-
- public void execute(Runnable task)
- {
- tryExecute(task,_preferredInvocationForExecute);
- }
-
- public void execute(Runnable task, InvocationType preferred)
- {
- tryExecute(task,preferred);
- }
-
- public boolean tryExecute(Runnable task)
- {
- return tryExecute(task,_preferredInvocationForExecute);
- }
-
- public boolean tryExecute(Runnable task, InvocationType preferred)
- {
- try
- {
- _executor.execute(Invocable.asPreferred(task,preferred));
- return true;
- }
- catch(RejectedExecutionException e)
- {
- // If we cannot execute, then close the task
- LOG.debug(e);
- LOG.warn("Rejected execution of {}",task);
- try
- {
- if (task instanceof Closeable)
- ((Closeable)task).close();
- }
- catch (Exception x)
- {
- e.addSuppressed(x);
- LOG.warn(e);
- }
- }
- return false;
- }
-
- }
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
index 4cb6fcfa3c4..efadbcf694f 100755
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java
@@ -506,16 +506,22 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
for (final Thread thread : _threads)
{
final StackTraceElement[] trace = thread.getStackTrace();
- boolean inIdleJobPoll = false;
+ String knownMethod = "";
for (StackTraceElement t : trace)
{
if ("idleJobPoll".equals(t.getMethodName()))
{
- inIdleJobPoll = true;
+ knownMethod = "IDLE ";
+ break;
+ }
+
+ if ("preallocatedWait".equals(t.getMethodName()))
+ {
+ knownMethod = "PREALLOCATED ";
break;
}
}
- final boolean idle = inIdleJobPoll;
+ final String known = knownMethod;
if (isDetailedDump())
{
@@ -524,11 +530,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
@Override
public void dump(Appendable out, String indent) throws IOException
{
- out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "");
+ out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(known).append(thread.getState().toString());
if (thread.getPriority()!=Thread.NORM_PRIORITY)
out.append(" prio=").append(String.valueOf(thread.getPriority()));
out.append(System.lineSeparator());
- if (!idle)
+ if (known.length()==0)
ContainerLifeCycle.dump(out, indent, Arrays.asList(trace));
}
@@ -542,7 +548,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
else
{
int p=thread.getPriority();
- threads.add(thread.getId() + " " + thread.getName() + " " + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (idle ? " IDLE" : "")+ (p==Thread.NORM_PRIORITY?"":(" prio="+p)));
+ threads.add(thread.getId() + " " + thread.getName() + " " + known + thread.getState() + " @ " + (trace.length > 0 ? trace[0] : "???") + (p==Thread.NORM_PRIORITY?"":(" prio="+p)));
}
}
@@ -557,7 +563,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
@Override
public String toString()
{
- return String.format("%s{%s,%d<=%d<=%d,i=%d,q=%d}", _name, getState(), getMinThreads(), getThreads(), getMaxThreads(), getIdleThreads(), (_jobs == null ? -1 : _jobs.size()));
+ return String.format("org.eclipse.jetty.util.thread.QueuedThreadPool@%s{%s,%d<=%d<=%d,i=%d,q=%d}", _name, getState(), getMinThreads(), getThreads(), getMaxThreads(), getIdleThreads(), (_jobs == null ? -1 : _jobs.size()));
}
private Runnable idleJobPoll() throws InterruptedException
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
new file mode 100644
index 00000000000..95045b29386
--- /dev/null
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
@@ -0,0 +1,235 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.thread;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.locks.Condition;
+
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+
+/**
+ * An Executor using preallocated/reserved Threads from a wrapped Executor.
+ *
Calls to {@link #execute(Runnable)} on a {@link ReservedThreadExecutor} will either succeed
+ * with a Thread immediately being assigned the Runnable task, or fail if no Thread is
+ * available. Threads are preallocated up to the capacity from a wrapped {@link Executor}.
+ */
+public class ReservedThreadExecutor extends AbstractLifeCycle implements Executor
+{
+ private static final Logger LOG = Log.getLogger(ReservedThreadExecutor.class);
+
+ private final Executor _executor;
+ private final Locker _locker = new Locker();
+ private final ReservedThread[] _queue;
+ private int _head;
+ private int _size;
+ private int _pending;
+
+ public ReservedThreadExecutor(Executor executor)
+ {
+ this(executor,1);
+ }
+
+ /**
+ * @param executor The executor to use to obtain threads
+ * @param capacity The number of threads to preallocate. If less than 0 then the number of available processors is used.
+ */
+ public ReservedThreadExecutor(Executor executor,int capacity)
+ {
+ _executor = executor;
+ _queue = new ReservedThread[capacity>=0?capacity:Runtime.getRuntime().availableProcessors()];
+ }
+
+ public Executor getExecutor()
+ {
+ return _executor;
+ }
+
+ public int getCapacity()
+ {
+ return _queue.length;
+ }
+
+ public int getPreallocated()
+ {
+ try (Locker.Lock lock = _locker.lock())
+ {
+ return _size;
+ }
+ }
+
+ @Override
+ public void doStart() throws Exception
+ {
+ try (Locker.Lock lock = _locker.lock())
+ {
+ _head = _size = _pending = 0;
+ while (_pending<_queue.length)
+ {
+ _executor.execute(new ReservedThread());
+ _pending++;
+ }
+ }
+ }
+
+ @Override
+ public void doStop() throws Exception
+ {
+ try (Locker.Lock lock = _locker.lock())
+ {
+ while (_size>0)
+ {
+ ReservedThread thread = _queue[_head];
+ _queue[_head] = null;
+ _head = (_head+1)%_queue.length;
+ _size--;
+ thread._wakeup.signal();
+ }
+ }
+ }
+
+ @Override
+ public void execute(Runnable task) throws RejectedExecutionException
+ {
+ if (!tryExecute(task))
+ throw new RejectedExecutionException();
+ }
+
+ /**
+ * @param task The task to run
+ * @return True iff a reserved thread was available and has been assigned the task to run.
+ */
+ public boolean tryExecute(Runnable task)
+ {
+ if (task==null)
+ return false;
+
+ try (Locker.Lock lock = _locker.lock())
+ {
+ if (_size==0)
+ {
+ if (_pending<_queue.length)
+ {
+ _executor.execute(new ReservedThread());
+ _pending++;
+ }
+ return false;
+ }
+
+ ReservedThread thread = _queue[_head];
+ _queue[_head] = null;
+ _head = (_head+1)%_queue.length;
+ _size--;
+
+ if (_size==0 && _pending<_queue.length)
+ {
+ _executor.execute(new ReservedThread());
+ _pending++;
+ }
+
+ thread._task = task;
+ thread._wakeup.signal();
+
+ return true;
+ }
+ catch(RejectedExecutionException e)
+ {
+ LOG.ignore(e);
+ return false;
+ }
+ }
+
+ private class ReservedThread implements Runnable
+ {
+ private Condition _wakeup = null;
+ private Runnable _task = null;
+
+ private void reservedWait() throws InterruptedException
+ {
+ _wakeup.await();
+ }
+
+ @Override
+ public void run()
+ {
+ while (true)
+ {
+ Runnable task = null;
+
+ try (Locker.Lock lock = _locker.lock())
+ {
+ // if this is our first loop, decrement pending count
+ if (_wakeup==null)
+ {
+ _pending--;
+ _wakeup = _locker.newCondition();
+ }
+
+ // Exit if no longer running or there now too many preallocated threads
+ if (!isRunning() || _size>=_queue.length)
+ break;
+
+ // Insert ourselves in the queue
+ _queue[(_head+_size++)%_queue.length] = this;
+
+ // Wait for a task, ignoring spurious interrupts
+ do
+ {
+ try
+ {
+ reservedWait();
+ task = _task;
+ _task = null;
+ }
+ catch (InterruptedException e)
+ {
+ LOG.ignore(e);
+ }
+ }
+ while (isRunning() && task==null);
+ }
+
+ // Run any task
+ if (task!=null)
+ {
+ try
+ {
+ task.run();
+ }
+ catch (Exception e)
+ {
+ LOG.warn(e);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ try (Locker.Lock lock = _locker.lock())
+ {
+ return String.format("%s{s=%d,p=%d}",super.toString(),_size,_pending);
+ }
+ }
+}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/EatWhatYouKill.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/EatWhatYouKill.java
index 84898e4fecb..6e8854d3aba 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/EatWhatYouKill.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/EatWhatYouKill.java
@@ -18,18 +18,19 @@
package org.eclipse.jetty.util.thread.strategy;
+import java.io.Closeable;
import java.util.concurrent.Executor;
-import java.util.concurrent.locks.Condition;
+import java.util.concurrent.RejectedExecutionException;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ExecutionStrategy;
import org.eclipse.jetty.util.thread.Invocable;
-import org.eclipse.jetty.util.thread.Invocable.InvocableExecutor;
import org.eclipse.jetty.util.thread.Invocable.InvocationType;
import org.eclipse.jetty.util.thread.Locker;
import org.eclipse.jetty.util.thread.Locker.Lock;
+import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
/**
*
A strategy where the thread that produces will run the resulting task if it
@@ -57,100 +58,61 @@ import org.eclipse.jetty.util.thread.Locker.Lock;
*
*
*/
-public class EatWhatYouKill extends AbstractLifeCycle implements ExecutionStrategy, Runnable
+public class EatWhatYouKill extends ContainerLifeCycle implements ExecutionStrategy, Runnable
{
private static final Logger LOG = Log.getLogger(EatWhatYouKill.class);
- enum State { IDLE, PRODUCING, REPRODUCING };
+ private enum State { IDLE, PRODUCING, REPRODUCING }
private final Locker _locker = new Locker();
private State _state = State.IDLE;
private final Runnable _runProduce = new RunProduce();
private final Producer _producer;
- private final InvocableExecutor _executor;
- private int _pendingProducersMax;
- private int _pendingProducers;
- private int _pendingProducersDispatched;
- private int _pendingProducersSignalled;
- private Condition _produce = _locker.newCondition();
+ private final Executor _executor;
+ private final ReservedThreadExecutor _producers;
public EatWhatYouKill(Producer producer, Executor executor)
{
- this(producer,executor,InvocationType.NON_BLOCKING,InvocationType.BLOCKING);
+ this(producer,executor,new ReservedThreadExecutor(executor,1));
}
- public EatWhatYouKill(Producer producer, Executor executor, int maxProducersPending )
+ public EatWhatYouKill(Producer producer, Executor executor, int maxProducersPending)
{
- this(producer,executor,InvocationType.NON_BLOCKING,InvocationType.BLOCKING);
+ this(producer,executor,new ReservedThreadExecutor(executor,maxProducersPending));
}
-
- public EatWhatYouKill(Producer producer, Executor executor, InvocationType preferredInvocationPEC, InvocationType preferredInvocationEPC)
- {
- this(producer,executor,preferredInvocationPEC,preferredInvocationEPC,Integer.getInteger("org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.maxProducersPending",1));
- }
-
- public EatWhatYouKill(Producer producer, Executor executor, InvocationType preferredInvocationPEC, InvocationType preferredInvocationEPC, int maxProducersPending )
+
+ public EatWhatYouKill(Producer producer, Executor executor, ReservedThreadExecutor producers)
{
_producer = producer;
- _pendingProducersMax = maxProducersPending;
- _executor = new InvocableExecutor(executor,preferredInvocationPEC,preferredInvocationEPC);
- }
-
- @Override
- public void produce()
- {
- boolean produce;
- try (Lock locked = _locker.lock())
- {
- switch(_state)
- {
- case IDLE:
- _state = State.PRODUCING;
- produce = true;
- break;
-
- case PRODUCING:
- _state = State.REPRODUCING;
- produce = false;
- break;
-
- default:
- produce = false;
- }
- }
-
- if (LOG.isDebugEnabled())
- LOG.debug("{} execute {}", this, produce);
-
- if (produce)
- doProduce();
+ _executor = executor;
+ _producers = producers;
+ addBean(_producer);
}
@Override
public void dispatch()
{
- boolean dispatch = false;
+ boolean execute = false;
try (Lock locked = _locker.lock())
{
switch(_state)
{
case IDLE:
- dispatch = true;
+ execute = true;
break;
case PRODUCING:
_state = State.REPRODUCING;
- dispatch = false;
break;
- default:
- dispatch = false;
+ default:
+ break;
}
}
if (LOG.isDebugEnabled())
- LOG.debug("{} dispatch {}", this, dispatch);
- if (dispatch)
- _executor.execute(_runProduce,InvocationType.BLOCKING);
+ LOG.debug("{} dispatch {}", this, execute);
+ if (execute)
+ _executor.execute(_runProduce);
}
@Override
@@ -158,160 +120,139 @@ public class EatWhatYouKill extends AbstractLifeCycle implements ExecutionStrate
{
if (LOG.isDebugEnabled())
LOG.debug("{} run", this);
- if (!isRunning())
- return;
+ produce();
+ }
+
+ @Override
+ public void produce()
+ {
+ boolean reproduce = true;
+ while(isRunning() && tryProduce(reproduce) && doProduce())
+ reproduce = false;
+ }
+
+ public boolean tryProduce(boolean reproduce)
+ {
boolean producing = false;
try (Lock locked = _locker.lock())
{
- _pendingProducersDispatched--;
- _pendingProducers++;
-
- loop: while (isRunning())
+ switch (_state)
{
- try
- {
- _produce.await();
-
- if (_pendingProducersSignalled==0)
- {
- // spurious wakeup!
- continue loop;
- }
-
- _pendingProducersSignalled--;
- if (_state == State.IDLE)
- {
- _state = State.PRODUCING;
- producing = true;
- }
- }
- catch (InterruptedException e)
- {
- LOG.debug(e);
- _pendingProducers--;
- }
-
- break loop;
- }
+ case IDLE:
+ // Enter PRODUCING
+ _state = State.PRODUCING;
+ producing = true;
+ break;
+
+ case PRODUCING:
+ // Keep other Thread producing
+ if (reproduce)
+ _state = State.REPRODUCING;
+ break;
+
+ default:
+ break;
+ }
}
-
- if (producing)
- doProduce();
+ return producing;
}
- private void doProduce()
+ public boolean doProduce()
{
- boolean may_block_caller = !Invocable.isNonBlockingInvocation();
- if (LOG.isDebugEnabled())
- LOG.debug("{} produce {}", this,may_block_caller?"non-blocking":"blocking");
-
- producing: while (isRunning())
+ boolean producing = true;
+ while (isRunning() && producing)
{
// If we got here, then we are the thread that is producing.
- Runnable task = _producer.produce();
-
- boolean produce;
- boolean consume;
- boolean execute_producer;
-
- StringBuilder state = null;
-
- try (Lock locked = _locker.lock())
+ Runnable task = null;
+ try
{
- if (LOG.isDebugEnabled())
+ task = _producer.produce();
+ }
+ catch(Throwable e)
+ {
+ LOG.warn(e);
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} t={}/{}",this,task,Invocable.getInvocationType(task));
+
+ if (task==null)
+ {
+ try (Lock locked = _locker.lock())
{
- state = new StringBuilder();
- getString(state);
- getState(state);
- state.append("->");
- }
-
- // Did we produced a task?
- if (task == null)
- {
- // There is no task.
// Could another one just have been queued with a produce call?
if (_state==State.REPRODUCING)
- {
_state = State.PRODUCING;
- continue producing;
+ else
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} IDLE",toStringLocked());
+ _state = State.IDLE;
+ producing = false;
}
-
- // ... and no additional calls to execute, so we are idle
- _state = State.IDLE;
- break producing;
}
-
- // Will we eat our own kill - ie consume the task we just produced?
- if (Invocable.getInvocationType(task)==InvocationType.NON_BLOCKING)
- {
- // ProduceConsume
- produce = true;
- consume = true;
- execute_producer = false;
- }
- else if (may_block_caller && (_pendingProducers>0 || _pendingProducersMax==0))
- {
- // ExecuteProduceConsume (eat what we kill!)
- produce = false;
- consume = true;
- execute_producer = true;
- _pendingProducersDispatched++;
- _state = State.IDLE;
- _pendingProducers--;
- _pendingProducersSignalled++;
- _produce.signal();
- }
- else
- {
- // ProduceExecuteConsume
- produce = true;
- consume = false;
- execute_producer = (_pendingProducersDispatched + _pendingProducers)<_pendingProducersMax;
- if (execute_producer)
- _pendingProducersDispatched++;
- }
-
+ }
+ else if (Invocable.getInvocationType(task)==InvocationType.NON_BLOCKING)
+ {
+ // PRODUCE CONSUME (EWYK!)
if (LOG.isDebugEnabled())
- getState(state);
-
+ LOG.debug("{} PC t={}",this,task);
+ task.run();
}
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("{} {} {}",
- state,
- consume?(execute_producer?"EPC!":"PC"):"PEC",
- task);
- }
-
- if (execute_producer)
- // Spawn a new thread to continue production by running the produce loop.
- _executor.execute(this);
-
- // Run or execute the task.
- if (consume)
- _executor.invoke(task);
else
- _executor.execute(task);
-
- // Once we have run the task, we can try producing again.
- if (produce)
- continue producing;
-
- try (Lock locked = _locker.lock())
{
- if (_state==State.IDLE)
+ boolean consume;
+ try (Lock locked = _locker.lock())
{
- _state = State.PRODUCING;
- continue producing;
+ if (_producers.tryExecute(this))
+ {
+ // EXECUTE PRODUCE CONSUME!
+ // We have executed a new Producer, so we can EWYK consume
+ _state = State.IDLE;
+ producing = false;
+ consume = true;
+ }
+ else
+ {
+ // PRODUCE EXECUTE CONSUME!
+ consume = false;
+ }
+ }
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("{} {} t={}",this,consume?"EPC":"PEC",task);
+
+ // Consume or execute task
+ try
+ {
+ if (consume)
+ task.run();
+ else
+ _executor.execute(task);
+ }
+ catch(RejectedExecutionException e)
+ {
+ LOG.warn(e);
+ if (task instanceof Closeable)
+ {
+ try
+ {
+ ((Closeable)task).close();
+ }
+ catch(Throwable e2)
+ {
+ LOG.ignore(e2);
+ }
+ }
+ }
+ catch(Throwable e)
+ {
+ LOG.warn(e);
}
}
-
- break producing;
}
- if (LOG.isDebugEnabled())
- LOG.debug("{} produce exit",this);
+
+ return producing;
}
public Boolean isIdle()
@@ -322,25 +263,19 @@ public class EatWhatYouKill extends AbstractLifeCycle implements ExecutionStrate
}
}
- @Override
- protected void doStop() throws Exception
+ public String toString()
{
try (Lock locked = _locker.lock())
{
- _pendingProducersSignalled=_pendingProducers+_pendingProducersDispatched;
- _pendingProducers=0;
- _produce.signalAll();
+ return toStringLocked();
}
}
- public String toString()
+ public String toStringLocked()
{
StringBuilder builder = new StringBuilder();
getString(builder);
- try (Lock locked = _locker.lock())
- {
- getState(builder);
- }
+ getState(builder);
return builder.toString();
}
@@ -358,9 +293,7 @@ public class EatWhatYouKill extends AbstractLifeCycle implements ExecutionStrate
{
builder.append(_state);
builder.append('/');
- builder.append(_pendingProducers);
- builder.append('/');
- builder.append(_pendingProducersMax);
+ builder.append(_producers);
}
private class RunProduce implements Runnable
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
index 1a8d3666df6..8d21b7f37c6 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
@@ -24,7 +24,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ExecutionStrategy;
import org.eclipse.jetty.util.thread.Invocable;
-import org.eclipse.jetty.util.thread.Invocable.InvocableExecutor;
import org.eclipse.jetty.util.thread.Invocable.InvocationType;
import org.eclipse.jetty.util.thread.Locker;
import org.eclipse.jetty.util.thread.Locker.Lock;
@@ -49,7 +48,7 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
private final Locker _locker = new Locker();
private final Runnable _runProduce = new RunProduce();
private final Producer _producer;
- private final InvocableExecutor _executor;
+ private final Executor _executor;
private boolean _idle = true;
private boolean _execute;
private boolean _producing;
@@ -57,14 +56,9 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
public ExecuteProduceConsume(Producer producer, Executor executor)
- {
- this(producer,executor,InvocationType.BLOCKING);
- }
-
- public ExecuteProduceConsume(Producer producer, Executor executor, InvocationType preferred )
{
this._producer = producer;
- _executor = new InvocableExecutor(executor,preferred);
+ _executor = executor;
}
@Override
@@ -192,15 +186,14 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
// Spawn a new thread to continue production by running the produce loop.
if (LOG.isDebugEnabled())
LOG.debug("{} dispatch", this);
- if (!_executor.tryExecute(this))
- task = null;
+ _executor.execute(this);
}
// Run the task.
if (LOG.isDebugEnabled())
LOG.debug("{} run {}", this, task);
if (task != null)
- _executor.invoke(task);
+ task.run();
if (LOG.isDebugEnabled())
LOG.debug("{} ran {}", this, task);
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
index 4e14596bc45..6e5e1783d35 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
@@ -24,7 +24,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ExecutionStrategy;
import org.eclipse.jetty.util.thread.Invocable.InvocationType;
-import org.eclipse.jetty.util.thread.Invocable.InvocableExecutor;
import org.eclipse.jetty.util.thread.Locker;
import org.eclipse.jetty.util.thread.Locker.Lock;
@@ -38,18 +37,13 @@ public class ProduceExecuteConsume implements ExecutionStrategy
private final Locker _locker = new Locker();
private final Producer _producer;
- private final InvocableExecutor _executor;
+ private final Executor _executor;
private State _state = State.IDLE;
public ProduceExecuteConsume(Producer producer, Executor executor)
- {
- this(producer,executor,InvocationType.NON_BLOCKING);
- }
-
- public ProduceExecuteConsume(Producer producer, Executor executor, InvocationType preferred)
{
_producer = producer;
- _executor = new InvocableExecutor(executor,preferred);
+ _executor = executor;
}
@Override
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ReservedThreadExecutorTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ReservedThreadExecutorTest.java
new file mode 100644
index 00000000000..f6209683a59
--- /dev/null
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/ReservedThreadExecutorTest.java
@@ -0,0 +1,204 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.thread;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ReservedThreadExecutorTest
+{
+ final static int SIZE = 2;
+ TestExecutor _executor;
+ ReservedThreadExecutor _pae;
+
+ @Before
+ public void before() throws Exception
+ {
+ _executor = new TestExecutor();
+ _pae = new ReservedThreadExecutor(_executor,SIZE);
+ _pae.start();
+ }
+
+
+ @After
+ public void after() throws Exception
+ {
+ _pae.stop();
+ }
+
+ @Test
+ public void testStarted() throws Exception
+ {
+ assertThat(_executor._queue.size(),is(SIZE));
+ while(!_executor._queue.isEmpty())
+ _executor.execute();
+
+ assertThat(_pae.getCapacity(),is(SIZE));
+
+ long started = System.nanoTime();
+ while (_pae.getPreallocated()10)
+ break;
+ Thread.sleep(100);
+ }
+ assertThat(_pae.getPreallocated(),is(SIZE));
+ }
+
+ @Test
+ public void testPending() throws Exception
+ {
+ assertThat(_executor._queue.size(),is(SIZE));
+ assertThat(_pae.tryExecute(new NOOP()),is(false));
+ assertThat(_executor._queue.size(),is(SIZE));
+
+ _executor.execute();
+ assertThat(_executor._queue.size(),is(SIZE-1));
+ while (!_executor._queue.isEmpty())
+ _executor.execute();
+
+ long started = System.nanoTime();
+ while (_pae.getPreallocated()10)
+ break;
+ Thread.sleep(100);
+ }
+ assertThat(_executor._queue.size(),is(0));
+ assertThat(_pae.getPreallocated(),is(SIZE));
+
+ for (int i=SIZE;i-->0;)
+ assertThat(_pae.tryExecute(new Task()),is(true));
+ assertThat(_executor._queue.size(),is(1));
+ assertThat(_pae.getPreallocated(),is(0));
+
+ for (int i=SIZE;i-->0;)
+ assertThat(_pae.tryExecute(new NOOP()),is(false));
+ assertThat(_executor._queue.size(),is(SIZE));
+ assertThat(_pae.getPreallocated(),is(0));
+
+ assertThat(_pae.tryExecute(new NOOP()),is(false));
+ assertThat(_executor._queue.size(),is(SIZE));
+ assertThat(_pae.getPreallocated(),is(0));
+ }
+
+ @Test
+ public void testExecuted() throws Exception
+ {
+ while(!_executor._queue.isEmpty())
+ _executor.execute();
+ long started = System.nanoTime();
+ while (_pae.getPreallocated()10)
+ break;
+ Thread.sleep(100);
+ }
+ assertThat(_pae.getPreallocated(),is(SIZE));
+
+ Task[] task = new Task[SIZE];
+ for (int i=SIZE;i-->0;)
+ {
+ task[i] = new Task();
+ assertThat(_pae.tryExecute(task[i]),is(true));
+ }
+
+ for (int i=SIZE;i-->0;)
+ {
+ task[i]._ran.await(10,TimeUnit.SECONDS);
+ }
+
+ assertThat(_executor._queue.size(),is(1));
+ Task extra = new Task();
+ assertThat(_pae.tryExecute(extra),is(false));
+ assertThat(_executor._queue.size(),is(2));
+ Thread.sleep(100);
+ assertThat(extra._ran.getCount(),is(1L));
+
+ for (int i=SIZE;i-->0;)
+ {
+ task[i]._complete.countDown();
+ }
+
+ started = System.nanoTime();
+ while (_pae.getPreallocated()10)
+ break;
+ Thread.sleep(100);
+ }
+ assertThat(_pae.getPreallocated(),is(SIZE));
+
+
+ }
+
+
+ private static class TestExecutor implements Executor
+ {
+ Deque _queue = new ArrayDeque<>();
+
+ @Override
+ public void execute(Runnable task)
+ {
+ _queue.addLast(task);
+ }
+
+ public void execute()
+ {
+ Runnable task = _queue.pollFirst();
+ if (task!=null)
+ new Thread(task).start();
+ }
+ }
+
+ private static class NOOP implements Runnable
+ {
+ @Override
+ public void run() {}
+ }
+
+ private static class Task implements Runnable
+ {
+ private CountDownLatch _ran = new CountDownLatch(1);
+ private CountDownLatch _complete = new CountDownLatch(1);
+ @Override
+ public void run()
+ {
+ _ran.countDown();
+ try
+ {
+ _complete.await();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecutionStrategyTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecutionStrategyTest.java
index 23981455096..f5156598cd4 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecutionStrategyTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecutionStrategyTest.java
@@ -158,7 +158,8 @@ public class ExecutionStrategyTest
@Override
public Runnable produce()
{
- if (tasks-->0)
+ final int id = --tasks;
+ if (id>=0)
{
try
{
@@ -171,6 +172,7 @@ public class ExecutionStrategyTest
@Override
public void run()
{
+ // System.err.println("RUN "+id);
latch.countDown();
}
};
From e32136f74c469cfefa1fdce4bdc077bcac719ea8 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Wed, 21 Jun 2017 16:27:44 +0200
Subject: [PATCH 065/147] Issue #1639
---
.../test-webapps/test-servlet-spec/test-spec-webapp/pom.xml | 5 -----
1 file changed, 5 deletions(-)
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 212abd36d48..2a9186175c3 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
@@ -212,11 +212,6 @@
${project.version}provided
-
- org.eclipse.jetty.orbit
- javax.mail.glassfish
- provided
- javax.servletjavax.servlet-api
From a7e4f920546f5cab83c4fcd874600bd614a866bf Mon Sep 17 00:00:00 2001
From: S K
Date: Wed, 21 Jun 2017 23:18:30 -0700
Subject: [PATCH 066/147] Issue #1622 - HeaderFilter does not work if response
has been committed (#1628)
Signed-off-by: S K (xz64)
---
.../administration/extras/header-filter.adoc | 17 ++--
.../eclipse/jetty/servlets/HeaderFilter.java | 58 ++++++------
.../servlets/IncludeExcludeBasedFilter.java | 33 ++++++-
.../IncludeExcludeBasedFilterTest.java | 92 +++++++++----------
4 files changed, 107 insertions(+), 93 deletions(-)
diff --git a/jetty-documentation/src/main/asciidoc/administration/extras/header-filter.adoc b/jetty-documentation/src/main/asciidoc/administration/extras/header-filter.adoc
index e7e97d9079e..58a08ac74ae 100644
--- a/jetty-documentation/src/main/asciidoc/administration/extras/header-filter.adoc
+++ b/jetty-documentation/src/main/asciidoc/administration/extras/header-filter.adoc
@@ -28,7 +28,8 @@
[[header-filter-usage]]
==== Usage
-The header filter sets or adds headers to each response based on an optionally included/excluded list of path specs, mime types, and/or HTTP methods.
+The header filter sets or adds headers to each response based on an optionally included/excluded list of path specs, mime types, and/or HTTP methods.
+This filter processes its configured headers before calling `doFilter` in the filter chain. Some of the headers configured in this filter may get overwritten by other filters and/or the servlet processing the request.
===== Required JARs
@@ -76,25 +77,25 @@ ____
The following `init` parameters control the behavior of the filter:
includedPaths::
-Optional. CSV of included path specs.
+Optional. Comma separated values of included path specs.
excludedPaths::
-Optional. CSV of excluded path specs.
+Optional. Comma separated values of excluded path specs.
includedMimeTypes::
-Optional. CSV of included mime types.
+Optional. Comma separated values of included mime types. The mime type will be guessed from the extension at the end of the request URL if the content type has not been set on the response.
excludedMimeTypes::
-Optional. CSV of excluded mime types.
+Optional. Comma separated values of excluded mime types. The mime type will be guessed from the extension at the end of the request URL if the content type has not been set on the response.
includedHttpMethods::
-Optional. CSV of included http methods.
+Optional. Comma separated values of included http methods.
excludedHttpMethods::
-Optional. CSV of excluded http methods.
+Optional. Comma separated values of excluded http methods.
headerConfig::
-CSV of actions to perform on headers. The syntax for each action is `action headerName: headerValue`.
+Comma separated values of actions to perform on headers. The syntax for each action is `action headerName: headerValue`.
Supported header actions:
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/HeaderFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/HeaderFilter.java
index c23b6b5b88c..0c2dc0dba24 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/HeaderFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/HeaderFilter.java
@@ -80,42 +80,40 @@ public class HeaderFilter extends IncludeExcludeBasedFilter
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
- chain.doFilter(request,response);
-
HttpServletRequest http_request = (HttpServletRequest)request;
HttpServletResponse http_response = (HttpServletResponse)response;
- if (!super.shouldFilter(http_request,http_response))
+ if (super.shouldFilter(http_request,http_response))
{
- return;
+ for (ConfiguredHeader header : _configuredHeaders)
+ {
+ if (header.isDate())
+ {
+ long header_value = System.currentTimeMillis() + header.getMsOffset();
+ if (header.isAdd())
+ {
+ http_response.addDateHeader(header.getName(),header_value);
+ }
+ else
+ {
+ http_response.setDateHeader(header.getName(),header_value);
+ }
+ }
+ else // constant header value
+ {
+ if (header.isAdd())
+ {
+ http_response.addHeader(header.getName(),header.getValue());
+ }
+ else
+ {
+ http_response.setHeader(header.getName(),header.getValue());
+ }
+ }
+ }
}
- for (ConfiguredHeader header : _configuredHeaders)
- {
- if (header.isDate())
- {
- long header_value = System.currentTimeMillis() + header.getMsOffset();
- if (header.isAdd())
- {
- http_response.addDateHeader(header.getName(),header_value);
- }
- else
- {
- http_response.setDateHeader(header.getName(),header_value);
- }
- }
- else // constant header value
- {
- if (header.isAdd())
- {
- http_response.addHeader(header.getName(),header.getValue());
- }
- else
- {
- http_response.setHeader(header.getName(),header.getValue());
- }
- }
- }
+ chain.doFilter(request,response);
}
@Override
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java
index b1ba2cf4342..35f40be4823 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilter.java
@@ -110,6 +110,33 @@ public abstract class IncludeExcludeBasedFilter implements Filter
}
}
+ protected String guessMimeType(HttpServletRequest http_request, HttpServletResponse http_response)
+ {
+ String content_type = http_response.getContentType();
+ LOG.debug("Content Type is: {}",content_type);
+
+ String mime_type = "";
+ if (content_type != null)
+ {
+ mime_type = MimeTypes.getContentTypeWithoutCharset(content_type);
+ LOG.debug("Mime Type is: {}",mime_type);
+ }
+ else
+ {
+ String request_url = http_request.getPathInfo();
+ mime_type = MimeTypes.getDefaultMimeByExtension(request_url);
+
+ if (mime_type == null)
+ {
+ mime_type = "";
+ }
+
+ LOG.debug("Guessed mime type is {}",mime_type);
+ }
+
+ return mime_type;
+ }
+
protected boolean shouldFilter(HttpServletRequest http_request, HttpServletResponse http_response)
{
String http_method = http_request.getMethod();
@@ -120,12 +147,8 @@ public abstract class IncludeExcludeBasedFilter implements Filter
return false;
}
- String content_type = http_response.getContentType();
- LOG.debug("Content Type is: {}",content_type);
- content_type = (content_type == null)?"":content_type;
- String mime_type = MimeTypes.getContentTypeWithoutCharset(content_type);
+ String mime_type = guessMimeType(http_request,http_response);
- LOG.debug("Mime Type is: {}",content_type);
if (!_mimeTypes.test(mime_type))
{
LOG.debug("should not apply filter because mime type does not match");
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java
index f9971247ad2..29285f70f82 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/IncludeExcludeBasedFilterTest.java
@@ -224,7 +224,24 @@ public class IncludeExcludeBasedFilterTest
request.setMethod("GET");
request.setVersion("HTTP/1.1");
request.setHeader("Host","localhost");
- request.setURI("/context/test/json");
+ request.setURI("/context/test/json.json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertTrue(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeMatchWithQueryString() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/json");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/json.json?some=value");
HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
Assert.assertTrue(response.contains("X-Custom-Value","1"));
@@ -241,7 +258,24 @@ public class IncludeExcludeBasedFilterTest
request.setMethod("GET");
request.setVersion("HTTP/1.1");
request.setHeader("Host","localhost");
- request.setURI("/context/test/json");
+ request.setURI("/context/test/json.json");
+
+ HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
+ Assert.assertFalse(response.contains("X-Custom-Value","1"));
+ }
+
+ @Test
+ public void testIncludeExcludeFilterIncludeMimeTypeNoMatchNoExtension() throws Exception
+ {
+ FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
+ holder.setInitParameter("includedMimeTypes","application/json");
+ _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
+
+ HttpTester.Request request = HttpTester.newRequest();
+ request.setMethod("GET");
+ request.setVersion("HTTP/1.1");
+ request.setHeader("Host","localhost");
+ request.setURI("/context/test/abcdef");
HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
Assert.assertFalse(response.contains("X-Custom-Value","1"));
@@ -258,7 +292,7 @@ public class IncludeExcludeBasedFilterTest
request.setMethod("GET");
request.setVersion("HTTP/1.1");
request.setHeader("Host","localhost");
- request.setURI("/context/test/json");
+ request.setURI("/context/test/json.json");
HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
Assert.assertFalse(response.contains("X-Custom-Value","1"));
@@ -275,61 +309,26 @@ public class IncludeExcludeBasedFilterTest
request.setMethod("GET");
request.setVersion("HTTP/1.1");
request.setHeader("Host","localhost");
- request.setURI("/context/test/json");
+ request.setURI("/context/test/json.json");
HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
Assert.assertTrue(response.contains("X-Custom-Value","1"));
}
- @Test
- public void testIncludeExcludeFilterIncludeMimeTypeSemicolonMatch() throws Exception
- {
- FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
- holder.setInitParameter("includedMimeTypes","application/json");
- _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
-
- HttpTester.Request request = HttpTester.newRequest();
- request.setMethod("GET");
- request.setVersion("HTTP/1.1");
- request.setHeader("Host","localhost");
- request.setURI("/context/test/json-utf8");
-
- HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
- Assert.assertTrue(response.contains("X-Custom-Value","1"));
- }
-
- @Test
- public void testIncludeExcludeFilterIncludeMimeTypeSemicolonNoMatch() throws Exception
- {
- FilterHolder holder = new FilterHolder(MockIncludeExcludeFilter.class);
- holder.setInitParameter("includedMimeTypes","application/xml");
- _tester.getContext().getServletHandler().addFilterWithMapping(holder,"/*",EnumSet.of(DispatcherType.REQUEST));
-
- HttpTester.Request request = HttpTester.newRequest();
- request.setMethod("GET");
- request.setVersion("HTTP/1.1");
- request.setHeader("Host","localhost");
- request.setURI("/context/test/json-utf8");
-
- HttpTester.Response response = HttpTester.parseResponse(_tester.getResponses(request.generate()));
- Assert.assertFalse(response.contains("X-Custom-Value","1"));
- }
-
public static class MockIncludeExcludeFilter extends IncludeExcludeBasedFilter
{
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
- chain.doFilter(request,response);
HttpServletRequest http_request = (HttpServletRequest)request;
HttpServletResponse http_response = (HttpServletResponse)response;
- if (!super.shouldFilter(http_request,http_response))
+ if (super.shouldFilter(http_request,http_response))
{
- return;
+ http_response.setHeader("X-Custom-Value","1");
}
- http_response.setHeader("X-Custom-Value","1");
+ chain.doFilter(request,response);
}
}
@@ -338,15 +337,8 @@ public class IncludeExcludeBasedFilterTest
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
- if (req.getPathInfo().equals("/json"))
- {
- resp.setContentType("application/json");
- }
- else if (req.getPathInfo().equals("/json-utf8"))
- {
- resp.setContentType("application/json; charset=utf-8");
- }
resp.setStatus(HttpStatus.NO_CONTENT_204);
+ resp.flushBuffer();
}
}
From b0e5681451c6c4638883fc70b4a4972b88619ac1 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Thu, 22 Jun 2017 16:24:13 +1000
Subject: [PATCH 067/147] add it for run mojo #1638
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 50 ++++++++++-
.../it/jetty-run-mojo-it/invoker.properties | 1 +
.../jetty-simple-base/pom.xml | 50 +++++++++++
.../its/jetty_run_mojo_it/HelloServlet.java | 44 +++++++++
.../jetty-simple-webapp/pom.xml | 84 +++++++++++++++++
.../src/main/webapp/WEB-INF/web.xml | 7 ++
.../jetty_run_mojo_it/TestHelloServlet.java | 66 ++++++++++++++
.../src/it/jetty-run-mojo-it/pom.xml | 89 +++++++++++++++++++
jetty-maven-plugin/src/it/settings.xml | 36 ++++++++
.../jetty/maven/plugin/AbstractJettyMojo.java | 54 ++++++++---
.../jetty/maven/plugin/JettyDeployWar.java | 4 +-
.../jetty/maven/plugin/JettyRunMojo.java | 10 +--
.../jetty/maven/plugin/JettyStartMojo.java | 2 +-
.../maven/plugin/MavenServerConnector.java | 5 ++
14 files changed, 483 insertions(+), 19 deletions(-)
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/invoker.properties
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
create mode 100644 jetty-maven-plugin/src/it/settings.xml
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index 335e94a2bc7..4fb6579684b 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -10,7 +10,9 @@
Jetty :: Jetty Maven Plugin3.0.3
- 3.1
+ 3.4
+ ${project.groupId}.maven.plugin
+ false
@@ -153,6 +155,12 @@
javax.transaction-apicompile
+
+ org.eclipse.jetty
+ jetty-client
+ ${project.version}
+ test
+
@@ -178,4 +186,44 @@
+
+
+ run-its
+
+
+
+ org.apache.maven.plugins
+ maven-invoker-plugin
+ 3.0.0
+
+
+ integration-test
+
+ install
+ integration-test
+ verify
+
+
+
+
+ ${it.debug}
+ true
+ src/it
+ ${project.build.directory}/it
+
+ */pom.xml
+
+ setup
+ verify
+ ${project.build.directory}/local-repo
+ src/it/settings.xml
+
+ clean
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-mojo-it/invoker.properties
new file mode 100644
index 00000000000..e0222d4d54e
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = test
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
new file mode 100644
index 00000000000..c29b270cb61
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-base
+ jar
+
+ Jetty :: Simple :: Base
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ commons-io
+ commons-io
+
+
+
+ org.eclipse.jetty.toolchain
+ jetty-perf-helper
+ 1.0.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.1
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..bb6915814df
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,44 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
new file mode 100644
index 00000000000..a11175216c8
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
@@ -0,0 +1,84 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-webapp
+ war
+
+ Jetty :: Simple :: Webapp
+
+
+
+
+ com.webtide.jetty.its.jetty-run-mojo-it
+ jetty-simple-base
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ @project.version@
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin-version}
+
+ false
+
+
+
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ start-jetty
+ test-compile
+
+ run
+
+
+ true
+ ${project.build.directory}/jetty.properties
+
+ 0
+
+
+
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..2a5ac4b71bf
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+ Jetty Simple Webapp run-mojo-it
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
new file mode 100644
index 00000000000..699c3171145
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -0,0 +1,66 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+/**
+ *
+ */
+public class TestHelloServlet
+{
+ @Test
+ public void hello_servlet()
+ throws Exception
+ {
+
+ Path path = Paths.get( "target/jetty.properties" );
+ int port;
+ try (InputStream inputStream = Files.newInputStream( path ))
+ {
+ Properties properties = new Properties();
+ properties.load( inputStream );
+ port = Integer.parseInt( properties.getProperty( "port" ) );
+ }
+
+ HttpClient httpClient = new HttpClient();
+ try
+ {
+ httpClient.start();
+
+ String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "hello beer", response.trim() );
+ }
+ finally
+ {
+ httpClient.stop();
+ }
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
new file mode 100644
index 00000000000..44247ef1e75
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+ com.webtide.jetty.its.jetty-run-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+ pom
+
+ Jetty :: Simple
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.0
+
+
+
+ jetty-simple-base
+ jetty-simple-webapp
+
+
+
+
+
+
+ com.webtide.jetty.its.jetty-run-mojo-it
+ jetty-simple-base
+ ${project.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ @project.version@
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ @project.version@
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/settings.xml b/jetty-maven-plugin/src/it/settings.xml
new file mode 100644
index 00000000000..d64bdb89034
--- /dev/null
+++ b/jetty-maven-plugin/src/it/settings.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+ it-repo
+
+ true
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+ local.central
+ @localRepositoryUrl@
+
+ true
+
+
+ true
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
index 72b8bad3a95..ae15f544235 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
@@ -21,9 +21,13 @@ package org.eclipse.jetty.maven.plugin;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
@@ -36,11 +40,14 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.ShutdownMonitor;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
@@ -272,9 +279,14 @@ public abstract class AbstractJettyMojo extends AbstractMojo
protected Thread consoleScanner;
protected ServerSupport serverSupport;
-
-
-
+
+
+ /**
+ * Will dump port in a properties file with key port.
+ * If empty no file generated
+ * @parameter
+ */
+ protected String propertiesPortFilePath;
/**
*
@@ -287,8 +299,9 @@ public abstract class AbstractJettyMojo extends AbstractMojo
* If true, the server will not block the execution of subsequent code. This
* is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.
*
+ * @parameter default-value="false"
*/
- protected boolean nonblocking = false;
+ protected boolean nonBlocking = false;
public abstract void restartWebApp(boolean reconfigureScanner) throws Exception;
@@ -429,11 +442,13 @@ public abstract class AbstractJettyMojo extends AbstractMojo
// if a was specified in the pom, use it
if (httpConnector != null)
{
+
// check that its port was set
- if (httpConnector.getPort() <= 0)
+ if (httpConnector.getPort() < 0)
{
//use any jetty.http.port settings provided
- String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY, System.getProperty("jetty.port", MavenServerConnector.DEFAULT_PORT_STR));
+ String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY,
+ System.getProperty("jetty.port", MavenServerConnector.DEFAULT_PORT_STR));
httpConnector.setPort(Integer.parseInt(tmp.trim()));
}
httpConnector.setServer(server);
@@ -459,7 +474,25 @@ public abstract class AbstractJettyMojo extends AbstractMojo
// start Jetty
this.server.start();
- getLog().info("Started Jetty Server");
+ if (httpConnector != null)
+ {
+ int port = httpConnector.getLocalPort();
+ getLog().info( "Started Jetty Server on port: " + port );
+ if (propertiesPortFilePath != null)
+ {
+ Path propertiesPath = Paths.get( propertiesPortFilePath);
+ Files.deleteIfExists(propertiesPath);
+ try(OutputStream outputStream = Files.newOutputStream( propertiesPath ))
+ {
+ Properties properties = new Properties( );
+ properties.put( "port", Integer.toString( port ) );
+ properties.store( outputStream, "Eclipse Jetty Maven Plugin port used" );
+ }
+ }
+ } else
+ {
+ getLog().info( "Started Jetty Server" );
+ }
if ( dumpOnStart )
{
@@ -478,10 +511,11 @@ public abstract class AbstractJettyMojo extends AbstractMojo
startConsoleScanner();
// keep the thread going if not in daemon mode
- if (!nonblocking )
+ if (!nonBlocking )
{
server.join();
}
+
}
catch (Exception e)
{
@@ -489,7 +523,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
}
finally
{
- if (!nonblocking )
+ if (!nonBlocking )
{
getLog().info("Jetty server exiting.");
}
@@ -504,7 +538,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
ShutdownMonitor monitor = ShutdownMonitor.getInstance();
monitor.setPort(stopPort);
monitor.setKey(stopKey);
- monitor.setExitVm(!nonblocking);
+ monitor.setExitVm(!nonBlocking );
}
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyDeployWar.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyDeployWar.java
index 96ea192a519..8a20299896e 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyDeployWar.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyDeployWar.java
@@ -61,7 +61,7 @@ public class JettyDeployWar extends JettyRunWarMojo
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
- nonblocking = daemon;
+ nonBlocking = daemon;
super.execute();
}
@@ -72,7 +72,7 @@ public class JettyDeployWar extends JettyRunWarMojo
{
super.finishConfigurationBeforeStart();
//only stop the server at shutdown if we are blocking
- server.setStopAtShutdown(!nonblocking);
+ server.setStopAtShutdown(!nonBlocking );
}
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index 259cb0f54d0..cdedd33c921 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -222,7 +222,7 @@ public class JettyRunMojo extends AbstractJettyMojo
{
getLog().info("Reload Mechanic: " + reload );
}
-
+ getLog().info( "nonBlocking:" + nonBlocking );
// check the classes to form a classpath with
try
@@ -566,7 +566,7 @@ public class JettyRunMojo extends AbstractJettyMojo
*/
private List getDependencyFiles()
{
- List dependencyFiles = new ArrayList();
+ List dependencyFiles = new ArrayList<>();
for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = iter.next();
@@ -596,7 +596,7 @@ public class JettyRunMojo extends AbstractJettyMojo
private List getDependencyProjects()
{
- List dependencyFiles = new ArrayList();
+ List dependencyFiles = new ArrayList<>();
for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = iter.next();
@@ -656,10 +656,10 @@ public class JettyRunMojo extends AbstractJettyMojo
if (warArtifacts != null)
return warArtifacts;
- warArtifacts = new ArrayList();
+ warArtifacts = new ArrayList<>();
for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
{
- Artifact artifact = (Artifact) iter.next();
+ Artifact artifact = iter.next();
if (artifact.getType().equals("war") || artifact.getType().equals("zip"))
{
try
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java
index ca7068c3ecc..1909536e0ee 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyStartMojo.java
@@ -44,7 +44,7 @@ public class JettyStartMojo extends JettyRunMojo
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
- nonblocking = true; //ensure that starting jetty won't hold up the thread
+ nonBlocking = true; //ensure that starting jetty won't hold up the thread
super.execute();
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
index 075f4d9c66b..aed7f8dddaf 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenServerConnector.java
@@ -270,6 +270,11 @@ public class MavenServerConnector extends ContainerLifeCycle implements Connecto
{
return this.name;
}
+
+ public int getLocalPort()
+ {
+ return this.delegate.getLocalPort();
+ }
private void checkDelegate() throws IllegalStateException
{
From 3aa42d989bb3bb748f563f0c13dc8b57a73ad063 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Thu, 22 Jun 2017 12:05:43 -0700
Subject: [PATCH 068/147] Issue #1642 - avoid casting to get to (base) Request
---
.../jetty/rewrite/handler/RuleContainer.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
index afaac89d4e9..3f2395c9c02 100644
--- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
+++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
@@ -163,7 +163,7 @@ public class RuleContainer extends Rule
if (_rules==null)
return target;
-
+
for (Rule rule : _rules)
{
String applied=rule.matchAndApply(target,request, response);
@@ -179,26 +179,29 @@ public class RuleContainer extends Rule
String query = request.getQueryString();
if (query != null)
request.setAttribute(_originalQueryStringAttribute,query);
- }
+ }
+
+ // Ugly hack, we should just pass baseRequest into the API from RewriteHandler itself.
+ Request baseRequest = Request.getBaseRequest(request);
if (_rewriteRequestURI)
{
String encoded=URIUtil.encodePath(applied);
if (rule instanceof Rule.ApplyURI)
- ((Rule.ApplyURI)rule).applyURI((Request)request,((Request)request).getRequestURI(), encoded);
+ ((Rule.ApplyURI)rule).applyURI(baseRequest, baseRequest.getRequestURI(), encoded);
else
- ((Request)request).setURIPathQuery(encoded);
+ baseRequest.setURIPathQuery(encoded);
}
if (_rewritePathInfo)
- ((Request)request).setPathInfo(applied);
+ baseRequest.setPathInfo(applied);
target=applied;
if (rule.isHandling())
{
LOG.debug("handling {}",rule);
- Request.getBaseRequest(request).setHandled(true);
+ baseRequest.setHandled(true);
}
if (rule.isTerminating())
From 4d2f66a2521d3a12c72e4155761bd68e312d8bd0 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Thu, 22 Jun 2017 17:18:01 -0400
Subject: [PATCH 069/147] Script doco update
---
.../startup/startup-unix-service.adoc | 35 ++++++++++---------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/jetty-documentation/src/main/asciidoc/administration/startup/startup-unix-service.adoc b/jetty-documentation/src/main/asciidoc/administration/startup/startup-unix-service.adoc
index b11aa50a28a..1f7b701123b 100644
--- a/jetty-documentation/src/main/asciidoc/administration/startup/startup-unix-service.adoc
+++ b/jetty-documentation/src/main/asciidoc/administration/startup/startup-unix-service.adoc
@@ -136,7 +136,7 @@ jetty-distribution-{VERSION}/
....
It might seem strange or undesirable to unpack the first portion of the jetty-distribution directory name too.
-But starting with Jetty 9.1 the split between `${jetty.home}` and `${jetty.base}` allows for easier upgrades of Jetty itself while isolating your webapp specific configuration.
+But starting with Jetty 9 the split between `${jetty.home}` and `${jetty.base}` allows for easier upgrades of Jetty itself while isolating your webapp specific configuration.
For more information on the Jetty home and base concepts see the section on managing a Jetty installation <>
The `/opt/jetty/temp` directory is created as a durable place for Jetty to use for temp and working directories.
@@ -156,16 +156,17 @@ While this is still supported, we encourage you to setup a proper `${jetty.base}
# cd /opt/web/mybase/
[/opt/web/mybase]# ls
[/opt/web/mybase]# java -jar /opt/jetty/jetty-distribution-{VERSION}/start.jar \
- --add-to-start=deploy,http,logging
-WARNING: deploy initialised in ${jetty.base}/start.ini (appended)
-WARNING: deploy enabled in ${jetty.base}/start.ini
-WARNING: server initialised in ${jetty.base}/start.ini (appended)
-WARNING: server enabled in ${jetty.base}/start.ini
-WARNING: http initialised in ${jetty.base}/start.ini (appended)
-WARNING: http enabled in ${jetty.base}/start.ini
-WARNING: server enabled in ${jetty.base}/start.ini
-WARNING: logging initialised in ${jetty.base}/start.ini (appended)
-WARNING: logging enabled in ${jetty.base}/start.ini
+ --add-to-start=deploy,http,console-capture
+ INFO : webapp transitively enabled, ini template available with --add-to-start=webapp
+ INFO : server transitively enabled, ini template available with --add-to-start=server
+ INFO : security transitively enabled
+ INFO : servlet transitively enabled
+ INFO : console-capture initialized in ${jetty.base}/start.ini
+ INFO : http initialized in ${jetty.base}/start.ini
+ INFO : deploy initialized in ${jetty.base}/start.ini
+ MKDIR : ${jetty.base}/logs
+ MKDIR : ${jetty.base}/webapps
+ INFO : Base directory was modified
[/opt/web/mybase]# ls -F
start.ini webapps/
....
@@ -178,10 +179,12 @@ http::
This sets up a single Connector that listens for basic HTTP requests.
+
See the created `start.ini` for configuring this connector.
-logging::
+console-capture::
When running Jetty as a service it is very important to have logging enabled.
This module will enable the basic STDOUT and STDERR capture logging to the `/opt/web/mybase/logs/` directory.
+Additionally, the `webapp`, `server`, `security` and `servlet` modules were enabled as they are dependencies for other modules.
+
See xref:start-jar[] for more details and options on setting up and configuring a `${jetty.base}` directory.
Copy your war file into place.
@@ -238,7 +241,7 @@ JAVA_OPTIONS = -Djetty.state=/opt/web/mybase/jetty.state
-Djetty.home=/opt/jetty/jetty-distribution-{VERSION}
-Djetty.base=/opt/web/mybase
-Djava.io.tmpdir=/opt/jetty/temp
-JETTY_ARGS = jetty-logging.xml jetty-started.xml
+JETTY_ARGS = console-capture.xml jetty-started.xml
RUN_CMD = /usr/bin/java
-Djetty.state=/opt/web/mybase/jetty.state
-Djetty.logs=/opt/web/mybase/logs
@@ -246,11 +249,11 @@ RUN_CMD = /usr/bin/java
-Djetty.base=/opt/web/mybase
-Djava.io.tmpdir=/opt/jetty/temp
-jar /opt/jetty/jetty-distribution-{VERSION}/start.jar
- jetty-logging.xml
+ console-capture.xml
jetty-started.xml
....
-You now have a configured `${jetty.base}` in `/opt/web/mybase` and a jetty-distribution in `/opt/jetty/jetty-distribution-{VERSION}`, along with the service level files necessary to start the service.
+You now have a configured `${jetty.base}` in `/opt/web/mybase` and a `${jetty.home}` in `/opt/jetty/jetty-distribution-{VERSION}`, along with the service level files necessary to start the service.
Test the service to make sure it starts up and runs successfully.
@@ -268,4 +271,4 @@ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jetty 2958 5.3 0.1 11179176 53984 ? Sl 12:46 0:00 /usr/bin/java -Djetty...
....
-You should now have your server running. Try it out
+You should now have your server running.
From 1cdc94f0a56e1ab72fe12810f909fee620408f03 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 10:42:03 +1000
Subject: [PATCH 070/147] add test for run forked mojo
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 26 ++++
.../invoker.properties | 1 +
.../jetty-simple-base/pom.xml | 50 +++++++
.../its/jetty_run_mojo_it/HelloServlet.java | 45 ++++++
.../jetty-simple-webapp/pom.xml | 133 ++++++++++++++++++
.../jetty-simple-webapp/src/config/jetty.xml | 33 +++++
.../src/main/webapp/WEB-INF/web.xml | 7 +
.../jetty_run_mojo_it/TestHelloServlet.java | 52 +++++++
.../src/it/jetty-run-forked-mojo-it/pom.xml | 89 ++++++++++++
.../it/jetty-run-forked-mojo-it/postbuild.foo | 8 ++
.../its/jetty_run_mojo_it/HelloServlet.java | 3 +-
.../jetty-simple-webapp/pom.xml | 13 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 21 +--
.../jetty/maven/plugin/AbstractJettyMojo.java | 32 +----
.../maven/plugin/JettyRunForkedMojo.java | 17 ++-
.../jetty/maven/plugin/JettyRunMojo.java | 2 +-
.../eclipse/jetty/maven/plugin/Starter.java | 4 +-
17 files changed, 480 insertions(+), 56 deletions(-)
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/invoker.properties
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/config/jetty.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index 4fb6579684b..f574267f2f9 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -13,6 +13,7 @@
3.4${project.groupId}.maven.pluginfalse
+ FOOBEER
@@ -217,11 +218,36 @@
verify${project.build.directory}/local-reposrc/it/settings.xml
+
+ ${jetty.stopKey}
+ ${jetty.stopPort}
+ ${jetty.runPort}
+ clean
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.0.0
+
+
+ reserve-ports
+ pre-integration-test
+
+ reserve-network-port
+
+
+
+ jetty.stopPort
+ jetty.runPort
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/invoker.properties
new file mode 100644
index 00000000000..2fc6409821b
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = test -fae
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
new file mode 100644
index 00000000000..594ddba4c8d
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-forked-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-base
+ jar
+
+ Jetty :: Simple :: Base
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ commons-io
+ commons-io
+
+
+
+ org.eclipse.jetty.toolchain
+ jetty-perf-helper
+ 1.0.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.1
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..a6d2a3e256d
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
new file mode 100644
index 00000000000..21f5b01073a
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
@@ -0,0 +1,133 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-forked-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-webapp
+ war
+
+ Jetty :: Simple :: Webapp
+
+
+ @jetty.runPort@
+
+
+
+
+
+ com.webtide.jetty.its.jetty-run-forked-mojo-it
+ jetty-simple-base
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ @project.version@
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin-version}
+
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
+
+ @jetty.runPort@
+
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+ @jetty.stopPort@
+ @jetty.stopKey@
+
+
+
+ start-jetty
+ test-compile
+
+ run-forked
+
+
+ true
+ false
+ ${project.build.directory}/config/jetty.xml
+
+
+
+ stop-jetty
+ test
+
+ stop
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.2
+
+
+ copy-resources-jetty
+ generate-resources
+
+ copy-resources
+
+
+ ${project.build.directory}/config
+
+
+ ${basedir}/src/config/
+ true
+
+ **/**
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/config/jetty.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/config/jetty.xml
new file mode 100644
index 00000000000..a057f0664eb
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/config/jetty.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ https
+
+ 32768
+ 8192
+ 8192
+ 512
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 30000
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..2a5ac4b71bf
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+ Jetty Simple Webapp run-mojo-it
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
new file mode 100644
index 00000000000..27d9d55c787
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -0,0 +1,52 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestHelloServlet
+{
+ @Test
+ public void hello_servlet()
+ throws Exception
+ {
+ int port = Integer.getInteger( "jetty.runPort" );
+ System.out.println( "port used:" + port );
+ HttpClient httpClient = new HttpClient();
+ try
+ {
+ httpClient.start();
+
+ String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "hello beer", response.trim() );
+ }
+ finally
+ {
+ httpClient.stop();
+ }
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
new file mode 100644
index 00000000000..e45f2ad1fcd
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+ com.webtide.jetty.its.jetty-run-forked-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+ pom
+
+ Jetty :: Simple
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.0
+
+
+
+ jetty-simple-base
+ jetty-simple-webapp
+
+
+
+
+
+
+ com.webtide.jetty.its.jetty-run-forked-mojo-it
+ jetty-simple-base
+ ${project.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ @project.version@
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ @project.version@
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
new file mode 100644
index 00000000000..134e91137c7
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
@@ -0,0 +1,8 @@
+
+Socket s=new Socket(InetAddress.getByName("127.0.0.1"),Integer.getInteger( "jetty.runPort" ));
+s.setSoLinger(false, 0);
+
+OutputStream out=s.getOutputStream();
+out.write((System.getProperty( "jetty.stopKey" )+"\r\n"+command+"\r\n").getBytes());
+out.flush();
+s.close()
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
index bb6915814df..a6d2a3e256d 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -1,6 +1,6 @@
//
// ========================================================================
-// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
@@ -16,6 +16,7 @@
// ========================================================================
//
+
package com.webtide.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
index a11175216c8..ce4d50f13ec 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
@@ -57,6 +57,16 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
+
+ @jetty.runPort@
+
+
+ org.eclipse.jettyjetty-maven-plugin
@@ -69,9 +79,8 @@
true
- ${project.build.directory}/jetty.properties
- 0
+ @jetty.runPort@
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 699c3171145..1ec2da6ff78 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -1,6 +1,6 @@
//
// ========================================================================
-// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
@@ -16,18 +16,13 @@
// ========================================================================
//
+
package com.webtide.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
import org.junit.Test;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-
/**
*
*/
@@ -37,16 +32,8 @@ public class TestHelloServlet
public void hello_servlet()
throws Exception
{
-
- Path path = Paths.get( "target/jetty.properties" );
- int port;
- try (InputStream inputStream = Files.newInputStream( path ))
- {
- Properties properties = new Properties();
- properties.load( inputStream );
- port = Integer.parseInt( properties.getProperty( "port" ) );
- }
-
+ int port = Integer.getInteger( "jetty.runPort" );
+ System.out.println( "port used:" + port );
HttpClient httpClient = new HttpClient();
try
{
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
index ae15f544235..ef9dbb2674a 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractJettyMojo.java
@@ -280,14 +280,6 @@ public abstract class AbstractJettyMojo extends AbstractMojo
protected ServerSupport serverSupport;
-
- /**
- * Will dump port in a properties file with key port.
- * If empty no file generated
- * @parameter
- */
- protected String propertiesPortFilePath;
-
/**
*
* Determines whether or not the server blocks when started. The default
@@ -444,10 +436,10 @@ public abstract class AbstractJettyMojo extends AbstractMojo
{
// check that its port was set
- if (httpConnector.getPort() < 0)
+ if (httpConnector.getPort() <= 0)
{
//use any jetty.http.port settings provided
- String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY,
+ String tmp = System.getProperty(MavenServerConnector.PORT_SYSPROPERTY, //
System.getProperty("jetty.port", MavenServerConnector.DEFAULT_PORT_STR));
httpConnector.setPort(Integer.parseInt(tmp.trim()));
}
@@ -474,25 +466,7 @@ public abstract class AbstractJettyMojo extends AbstractMojo
// start Jetty
this.server.start();
- if (httpConnector != null)
- {
- int port = httpConnector.getLocalPort();
- getLog().info( "Started Jetty Server on port: " + port );
- if (propertiesPortFilePath != null)
- {
- Path propertiesPath = Paths.get( propertiesPortFilePath);
- Files.deleteIfExists(propertiesPath);
- try(OutputStream outputStream = Files.newOutputStream( propertiesPath ))
- {
- Properties properties = new Properties( );
- properties.put( "port", Integer.toString( port ) );
- properties.store( outputStream, "Eclipse Jetty Maven Plugin port used" );
- }
- }
- } else
- {
- getLog().info( "Started Jetty Server" );
- }
+ getLog().info( "Started Jetty Server" );
if ( dumpOnStart )
{
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index c4d03008abf..6e6b35b46a3 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -44,6 +44,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.IO;
@@ -169,10 +170,18 @@ public class JettyRunForkedMojo extends JettyRunMojo
}
}
}
-
-
-
+
+ @Override
+ /**
+ * we o
+ */
+ protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
+ {
+
+ return null;
+ }
+
/**
* ConsoleStreamer
*
@@ -349,7 +358,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
builder.directory(project.getBasedir());
if (PluginLog.getLog().isDebugEnabled())
- PluginLog.getLog().debug(Arrays.toString(cmd.toArray()));
+ PluginLog.getLog().debug("Forked cli:"+Arrays.toString(cmd.toArray()));
PluginLog.getLog().info("Forked process starting");
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index cdedd33c921..00a6b9f3ec8 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -626,7 +626,7 @@ public class JettyRunMojo extends AbstractJettyMojo
}
- private MavenProject getProjectReferences( Artifact artifact, MavenProject project )
+ protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
{
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
{
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
index 040a58202cf..37a155f6b89 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
@@ -246,7 +246,7 @@ public class Starter
Set matchedWars = new HashSet();
//process any overlays and the war type artifacts
- List overlays = new ArrayList();
+ List overlays = new ArrayList<>();
for (OverlayConfig config:orderedConfigs.values())
{
//overlays can be individually skipped
@@ -302,7 +302,7 @@ public class Starter
// - the equivalent of web-inf lib
- str = (String)props.getProperty("lib.jars");
+ str = props.getProperty("lib.jars");
if (str != null && !"".equals(str.trim()))
{
List jars = new ArrayList();
From 2f9dc5869905ceb88c8a78431b64e7c7b59fc4c5 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 14:55:44 +1000
Subject: [PATCH 071/147] fix run forked support of reactor projects
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 11 ++---
.../jetty-simple-webapp/pom.xml | 4 ++
.../it/jetty-run-forked-mojo-it/postbuild.foo | 8 ---
.../jetty-run-forked-mojo-it/postbuild.groovy | 13 +++++
.../maven/plugin/JettyRunForkedMojo.java | 49 ++++++++++++-------
.../jetty/maven/plugin/ServerSupport.java | 2 +-
.../eclipse/jetty/maven/plugin/Starter.java | 36 +++++++++-----
7 files changed, 77 insertions(+), 46 deletions(-)
delete mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.groovy
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index f574267f2f9..e7b62ffc8fc 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -14,6 +14,7 @@
${project.groupId}.maven.pluginfalseFOOBEER
+
@@ -195,7 +196,7 @@
org.apache.maven.pluginsmaven-invoker-plugin
- 3.0.0
+ 3.0.1-SNAPSHOTintegration-test
@@ -214,14 +215,12 @@
*/pom.xml
- setup
- verify${project.build.directory}/local-reposrc/it/settings.xml
- ${jetty.stopKey}
- ${jetty.stopPort}
- ${jetty.runPort}
+ ${jetty.stopKey}
+ ${jetty.stopPort}
+ ${jetty.runPort}clean
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
index 21f5b01073a..3c6f21d22ea 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
@@ -16,6 +16,7 @@
@jetty.runPort@
+ @jetty.jvmArgs@
@@ -89,8 +90,10 @@
truefalse${project.build.directory}/config/jetty.xml
+ ${jetty.jvmArgs}
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
deleted file mode 100644
index 134e91137c7..00000000000
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.foo
+++ /dev/null
@@ -1,8 +0,0 @@
-
-Socket s=new Socket(InetAddress.getByName("127.0.0.1"),Integer.getInteger( "jetty.runPort" ));
-s.setSoLinger(false, 0);
-
-OutputStream out=s.getOutputStream();
-out.write((System.getProperty( "jetty.stopKey" )+"\r\n"+command+"\r\n").getBytes());
-out.flush();
-s.close()
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.groovy b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.groovy
new file mode 100644
index 00000000000..8a524044e2a
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/postbuild.groovy
@@ -0,0 +1,13 @@
+
+
+System.out.println( "running postbuild.groovy port " + jettyStopPort + ", key:" + jettyStopKey )
+
+int port = Integer.parseInt( jettyStopPort )
+
+Socket s=new Socket(InetAddress.getByName("127.0.0.1"),port )
+s.setSoLinger(false, 0)
+
+OutputStream out=s.getOutputStream()
+out.write(( jettyStopKey +"\r\nforcestop\r\n").getBytes())
+out.flush()
+s.close()
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index 6e6b35b46a3..4de7f20ae53 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -18,6 +18,17 @@
package org.eclipse.jetty.maven.plugin;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.eclipse.jetty.annotations.AnnotationConfiguration;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.resource.ResourceCollection;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -40,18 +51,6 @@ import java.util.Properties;
import java.util.Random;
import java.util.Set;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.project.MavenProject;
-import org.eclipse.jetty.annotations.AnnotationConfiguration;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.IO;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.util.resource.ResourceCollection;
-import org.eclipse.jetty.util.thread.QueuedThreadPool;
-
/**
* This goal is used to deploy your unassembled webapp into a forked JVM.
@@ -172,15 +171,14 @@ public class JettyRunForkedMojo extends JettyRunMojo
}
- @Override
/**
* we o
*/
- protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
- {
-
- return null;
- }
+// protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
+// {
+//
+// return null;
+// }
/**
* ConsoleStreamer
@@ -519,6 +517,19 @@ public class JettyRunForkedMojo extends JettyRunMojo
props.put("testClasses.dir", webApp.getTestClasses().getAbsolutePath());
}
+ if ( !webApp.getClassPathFiles().isEmpty() )
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ for ( File dependency : webApp.getClassPathFiles() )
+ {
+ if (dependency.isDirectory())
+ {
+ stringBuilder.append( dependency.getCanonicalPath() ).append( '|' );
+ }
+ }
+ props.put( "projects.classes.dir", stringBuilder.toString() );
+ }
+
//web-inf lib
List deps = webApp.getWebInfLib();
StringBuffer strbuff = new StringBuffer();
@@ -587,7 +598,7 @@ public class JettyRunForkedMojo extends JettyRunMojo
List warArtifacts = new ArrayList();
for ( Iterator iter = project.getArtifacts().iterator(); iter.hasNext(); )
{
- Artifact artifact = (Artifact) iter.next();
+ Artifact artifact = iter.next();
if (artifact.getType().equals("war"))
warArtifacts.add(artifact);
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
index eeda81108f0..3b0512ced41 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java
@@ -164,7 +164,7 @@ public class ServerSupport
if (server == null)
return null;
- return (ContextHandlerCollection)server.getChildHandlerByClass(ContextHandlerCollection.class);
+ return server.getChildHandlerByClass(ContextHandlerCollection.class);
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
index 37a155f6b89..88f542db616 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
@@ -22,7 +22,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
@@ -30,6 +32,8 @@ import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
@@ -174,31 +178,31 @@ public class Starter
//apply a properties file that defines the things that we configure in the jetty:run plugin:
// - the context path
- String str = (String)props.get("context.path");
+ String str = props.getProperty("context.path");
if (str != null)
webApp.setContextPath(str);
// - web.xml
- str = (String)props.get("web.xml");
+ str = props.getProperty("web.xml");
if (str != null)
webApp.setDescriptor(str);
- str = (String)props.get("quickstart.web.xml");
+ str = props.getProperty("quickstart.web.xml");
if (str != null)
webApp.setQuickStartWebDescriptor(Resource.newResource(new File(str)));
// - the tmp directory
- str = (String)props.getProperty("tmp.dir");
+ str = props.getProperty("tmp.dir");
if (str != null)
webApp.setTempDirectory(new File(str.trim()));
- str = (String)props.getProperty("tmp.dir.persist");
+ str = props.getProperty("tmp.dir.persist");
if (str != null)
webApp.setPersistTempDirectory(Boolean.valueOf(str));
//Get the calculated base dirs which includes the overlays
- str = (String)props.getProperty("base.dirs");
+ str = props.getProperty("base.dirs");
if (str != null && !"".equals(str.trim()))
{
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
@@ -207,7 +211,7 @@ public class Starter
}
//Get the original base dirs without the overlays
- str = (String)props.get("base.dirs.orig");
+ str = props.getProperty("base.dirs.orig");
if (str != null && !"".equals(str.trim()))
{
ResourceCollection bases = new ResourceCollection(StringUtil.csvSplit(str));
@@ -215,9 +219,9 @@ public class Starter
}
//For overlays
- str = (String)props.getProperty("maven.war.includes");
+ str = props.getProperty("maven.war.includes");
List defaultWarIncludes = fromCSV(str);
- str = (String)props.getProperty("maven.war.excludes");
+ str = props.getProperty("maven.war.excludes");
List defaultWarExcludes = fromCSV(str);
//List of war artifacts
@@ -288,19 +292,18 @@ public class Starter
// - the equivalent of web-inf classes
- str = (String)props.getProperty("classes.dir");
+ str = props.getProperty("classes.dir");
if (str != null && !"".equals(str.trim()))
{
webApp.setClasses(new File(str));
}
- str = (String)props.getProperty("testClasses.dir");
+ str = props.getProperty("testClasses.dir");
if (str != null && !"".equals(str.trim()))
{
webApp.setTestClasses(new File(str));
}
-
// - the equivalent of web-inf lib
str = props.getProperty("lib.jars");
if (str != null && !"".equals(str.trim()))
@@ -311,6 +314,15 @@ public class Starter
jars.add(new File(names[j].trim()));
webApp.setWebInfLib(jars);
}
+
+ str = props.getProperty( "projects.classes.dir" );
+ if (str != null && !"".equals(str.trim()))
+ {
+ List classesDirectories = //
+ Arrays.stream(str.split( Pattern.quote("|") )) //
+ .map( s -> Paths.get( s).toFile() ).collect( Collectors.toList() );
+ webApp.getWebInfLib().addAll( classesDirectories );
+ }
}
From 4024273fa64db6ad2cf805b5656b6cac99705174 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 15:07:18 +1000
Subject: [PATCH 072/147] Add it test for Maven Plugin #1638
Signed-off-by: olivier lamy
---
.../it/jetty-start-mojo-it/invoker.properties | 1 +
.../jetty-simple-base/pom.xml | 50 ++++++++++
.../its/jetty_run_mojo_it/HelloServlet.java | 45 +++++++++
.../jetty-simple-webapp/pom.xml | 92 +++++++++++++++++++
.../src/main/webapp/WEB-INF/web.xml | 7 ++
.../jetty_run_mojo_it/TestHelloServlet.java | 53 +++++++++++
.../src/it/jetty-start-mojo-it/pom.xml | 89 ++++++++++++++++++
7 files changed, 337 insertions(+)
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/invoker.properties
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-start-mojo-it/invoker.properties
new file mode 100644
index 00000000000..e0222d4d54e
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = test
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
new file mode 100644
index 00000000000..7a9a5382308
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-start-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-base
+ jar
+
+ Jetty :: Simple :: Base
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ commons-io
+ commons-io
+
+
+
+ org.eclipse.jetty.toolchain
+ jetty-perf-helper
+ 1.0.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.1
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..a6d2a3e256d
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
new file mode 100644
index 00000000000..38ae1555a4b
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
@@ -0,0 +1,92 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-start-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-webapp
+ war
+
+ Jetty :: Simple :: Webapp
+
+
+
+
+ com.webtide.jetty.its.jetty-start-mojo-it
+ jetty-simple-base
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ @project.version@
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin-version}
+
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
+
+ @jetty.runPort@
+
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ start-jetty
+ test-compile
+
+ start
+
+
+
+ @jetty.runPort@
+
+
+
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..2a5ac4b71bf
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+ Jetty Simple Webapp run-mojo-it
+
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
new file mode 100644
index 00000000000..1ec2da6ff78
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -0,0 +1,53 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestHelloServlet
+{
+ @Test
+ public void hello_servlet()
+ throws Exception
+ {
+ int port = Integer.getInteger( "jetty.runPort" );
+ System.out.println( "port used:" + port );
+ HttpClient httpClient = new HttpClient();
+ try
+ {
+ httpClient.start();
+
+ String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "hello beer", response.trim() );
+ }
+ finally
+ {
+ httpClient.stop();
+ }
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
new file mode 100644
index 00000000000..bc0398916e7
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
@@ -0,0 +1,89 @@
+
+
+ 4.0.0
+
+ com.webtide.jetty.its.jetty-start-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+ pom
+
+ Jetty :: Simple
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.0
+
+
+
+ jetty-simple-base
+ jetty-simple-webapp
+
+
+
+
+
+
+ com.webtide.jetty.its.jetty-start-mojo-it
+ jetty-simple-base
+ ${project.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ @project.version@
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ @project.version@
+
+
+
+
+
+
From 7dcab0e5a20a1893f74f4b806ed5973207ba1e13 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 15:51:38 +1000
Subject: [PATCH 073/147] add test with fragment for #1623
Signed-off-by: olivier lamy
---
.../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++
.../main/resources/META-INF/web-fragment.xml | 32 +++++++++++++++
.../jetty_run_mojo_it/TestHelloServlet.java | 6 +++
.../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++
.../main/resources/META-INF/web-fragment.xml | 32 +++++++++++++++
.../jetty_run_mojo_it/TestHelloServlet.java | 6 +++
.../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++
.../java/resources/META-INF/web-fragment.xml | 32 +++++++++++++++
.../jetty_run_mojo_it/TestHelloServlet.java | 6 +++
.../main/resources/META-INF/web-fragment.xml | 1 -
10 files changed, 237 insertions(+), 1 deletion(-)
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..f5686592252
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 00000000000..031012f7fed
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ FragmentA
+
+
+
+
+
+
+ Ping
+ com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+
+ extra1123
+
+
+ extra2345
+
+
+
+
+ Ping
+ /ping
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 27d9d55c787..f48eee38074 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -43,6 +43,12 @@ public class TestHelloServlet
System.out.println( "httpResponse:" + response );
Assert.assertEquals( "hello beer", response.trim() );
+
+ response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "pong beer", response.trim() );
}
finally
{
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..f5686592252
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 00000000000..031012f7fed
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ FragmentA
+
+
+
+
+
+
+ Ping
+ com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+
+ extra1123
+
+
+ extra2345
+
+
+
+
+ Ping
+ /ping
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 1ec2da6ff78..4e3ced68d91 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -44,6 +44,12 @@ public class TestHelloServlet
System.out.println( "httpResponse:" + response );
Assert.assertEquals( "hello beer", response.trim() );
+
+ response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "pong beer", response.trim() );
}
finally
{
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..f5686592252
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml
new file mode 100644
index 00000000000..031012f7fed
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ FragmentA
+
+
+
+
+
+
+ Ping
+ com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+
+ extra1123
+
+
+ extra2345
+
+
+
+
+ Ping
+ /ping
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 1ec2da6ff78..4e3ced68d91 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -44,6 +44,12 @@ public class TestHelloServlet
System.out.println( "httpResponse:" + response );
Assert.assertEquals( "hello beer", response.trim() );
+
+ response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "pong beer", response.trim() );
}
finally
{
diff --git a/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml b/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml
index a85aea5f030..ae015f2712c 100644
--- a/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml
+++ b/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml
@@ -32,7 +32,6 @@
Fragment/fragment/*
-
From 8095da38481968f7a2786510f7d9ad19d65828e3 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 20:35:59 +1000
Subject: [PATCH 074/147] try to fix web fragment for directory classes #1623
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 12 ++++++++++++
.../org/eclipse/jetty/maven/plugin/JettyRunMojo.java | 12 +++++++++---
.../eclipse/jetty/webapp/MetaInfConfiguration.java | 3 +--
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index e7b62ffc8fc..b17414749bd 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -249,6 +249,18 @@
+
+
+ apache.snaphots
+ https://repository.apache.org/content/repositories/snapshots
+
+ false
+
+
+ true
+
+
+
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index 00a6b9f3ec8..23f21a7125f 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -40,6 +40,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
/**
* This goal is used in-situ on a Maven project without first requiring that the project
@@ -281,14 +283,18 @@ public class JettyRunMojo extends AbstractJettyMojo
if (useTestScope && (testClassesDirectory != null))
webApp.setTestClasses (testClassesDirectory);
- webApp.getClassPathFiles().addAll( getDependencyProjects() );
+ List dependencyProjects = getDependencyProjects();
+ webApp.getClassPathFiles().addAll( dependencyProjects );
+ List dependencyResources = //
+ dependencyProjects.stream() //
+ .map( file -> Resource.newResource( file ) ) //
+ .collect( Collectors.toList() );
+ webApp.getMetaData().getContainerResources().addAll( dependencyResources );
webApp.setWebInfLib (getDependencyFiles());
//get copy of a list of war artifacts
Set matchedWarArtifacts = new HashSet();
-
-
//process any overlays and the war type artifacts
List overlays = new ArrayList();
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java
index ea973624719..e06a55cda1e 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/MetaInfConfiguration.java
@@ -276,8 +276,7 @@ public class MetaInfConfiguration extends AbstractConfiguration
if (LOG.isDebugEnabled()) LOG.debug(jar+" META-INF/web-fragment.xml checked");
if (jar.isDirectory())
{
- //TODO ????
- webFrag = jar.addPath("/META-INF/web-fragment.xml");
+ webFrag = Resource.newResource( new File (jar.getFile(),"/META-INF/web-fragment.xml"));
}
else
{
From aae7b38b82a9867c30c2405face786d92e84f752 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 20:46:09 +1000
Subject: [PATCH 075/147] version in only one place
Signed-off-by: olivier lamy
---
jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml | 5 +++--
jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml | 5 +++--
jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml | 5 +++--
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
index e45f2ad1fcd..cada3739cce 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
@@ -15,6 +15,7 @@
UTF-81.83.0.0
+ @project.version@
@@ -54,7 +55,7 @@
org.eclipse.jettyjetty-servlet
- @project.version@
+ ${jetty.version}
@@ -80,7 +81,7 @@
org.eclipse.jettyjetty-maven-plugin
- @project.version@
+ ${jetty.version}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
index 44247ef1e75..3d303f4caf8 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
@@ -15,6 +15,7 @@
UTF-81.83.0.0
+ @project.version@
@@ -54,7 +55,7 @@
org.eclipse.jettyjetty-servlet
- @project.version@
+ ${jetty.version}
@@ -80,7 +81,7 @@
org.eclipse.jettyjetty-maven-plugin
- @project.version@
+ ${jetty.version}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
index bc0398916e7..7319c0d604f 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
@@ -15,6 +15,7 @@
UTF-81.83.0.0
+ @project.version@
@@ -54,7 +55,7 @@
org.eclipse.jettyjetty-servlet
- @project.version@
+ ${jetty.version}
@@ -80,7 +81,7 @@
org.eclipse.jettyjetty-maven-plugin
- @project.version@
+ ${jetty.version}
From dfb4e85c0ace7840975b0e12683a8bcea1645b7b Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Fri, 23 Jun 2017 21:32:11 +1000
Subject: [PATCH 076/147] fix fragment from dependent projects #1623
Signed-off-by: olivier lamy
---
.../resources/META-INF/web-fragment.xml | 0
.../jetty/maven/plugin/JettyRunMojo.java | 18 ++++++++++++++++--
.../jetty/maven/plugin/JettyWebAppContext.java | 9 ++++++---
.../maven/plugin/MavenWebInfConfiguration.java | 2 ++
4 files changed, 24 insertions(+), 5 deletions(-)
rename jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/{java => }/resources/META-INF/web-fragment.xml (100%)
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
similarity index 100%
rename from jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml
rename to jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index 23f21a7125f..94102e9db95 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -291,7 +291,11 @@ public class JettyRunMojo extends AbstractJettyMojo
.collect( Collectors.toList() );
webApp.getMetaData().getContainerResources().addAll( dependencyResources );
webApp.setWebInfLib (getDependencyFiles());
-
+// webApp.getWebInfLib().addAll( dependencyResources //
+// .stream() //
+// .map( resource -> toFile(resource) ) //
+// .collect( Collectors.toList() ) );
+ webApp.getDependentProjects().addAll( dependencyResources );
//get copy of a list of war artifacts
Set matchedWarArtifacts = new HashSet();
@@ -373,7 +377,17 @@ public class JettyRunMojo extends AbstractJettyMojo
getLog().info("Webapp directory = " + webAppSourceDirectory.getCanonicalPath());
}
-
+ private static File toFile(Resource resource)
+ {
+ try
+ {
+ return resource.getFile();
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
/**
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index a27903ceed5..3ec20ce8081 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -104,9 +104,7 @@ public class JettyWebAppContext extends WebAppContext
private Resource _quickStartWebXml;
private String _originAttribute;
private boolean _generateOrigin;
-
-
-
+ private List dependentProjects = new ArrayList<>();
/**
* Set the "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" with a pattern for matching jars on
@@ -321,6 +319,11 @@ public class JettyWebAppContext extends WebAppContext
{
return _webInfJars;
}
+
+ public List getDependentProjects()
+ {
+ return dependentProjects;
+ }
/* ------------------------------------------------------------ */
public void setGenerateQuickStart (boolean quickStart)
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
index 2ea7443713e..440238d22b4 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
@@ -93,6 +93,8 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
public void preConfigure(WebAppContext context) throws Exception
{
super.preConfigure(context);
+ ((JettyWebAppContext)context).getDependentProjects()
+ .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
}
From 4b513c61e8ac7400826880d18729c71eca1b6ae8 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Sat, 24 Jun 2017 21:22:06 +1000
Subject: [PATCH 077/147] add it test for run war mojo
Signed-off-by: olivier lamy
---
.../jetty-run-war-mojo-it/invoker.properties | 2 +
.../jetty-simple-base/pom.xml | 50 ++++++++
.../its/jetty_run_mojo_it/HelloServlet.java | 45 +++++++
.../its/jetty_run_mojo_it/PingServlet.java | 41 ++++++
.../main/resources/META-INF/web-fragment.xml | 32 +++++
.../jetty-simple-webapp/pom.xml | 121 ++++++++++++++++++
.../src/main/webapp/WEB-INF/web.xml | 7 +
.../jetty_run_mojo_it/TestHelloServlet.java | 59 +++++++++
.../src/it/jetty-run-war-mojo-it/pom.xml | 90 +++++++++++++
.../jetty/maven/plugin/JettyRunWarMojo.java | 4 +
10 files changed, 451 insertions(+)
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/invoker.properties
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/invoker.properties
new file mode 100644
index 00000000000..161dd58f0af
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/invoker.properties
@@ -0,0 +1,2 @@
+invoker.goals = verify
+#test-compile failsafe:integration-test
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
new file mode 100644
index 00000000000..8903e68d8a0
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-war-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-base
+ jar
+
+ Jetty :: Simple :: Base
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ commons-io
+ commons-io
+
+
+
+ org.eclipse.jetty.toolchain
+ jetty-perf-helper
+ 1.0.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.1
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..a6d2a3e256d
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..f5686592252
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 00000000000..031012f7fed
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ FragmentA
+
+
+
+
+
+
+ Ping
+ com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+
+ extra1123
+
+
+ extra2345
+
+
+
+
+ Ping
+ /ping
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
new file mode 100644
index 00000000000..23109b90f00
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
@@ -0,0 +1,121 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-war-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-webapp
+ war
+
+ Jetty :: Simple :: Webapp
+
+
+
+
+ com.webtide.jetty.its.jetty-run-war-mojo-it
+ jetty-simple-base
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ @project.version@
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin-version}
+
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
+ true
+
+ @jetty.runPort@
+
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.20
+
+
+ @jetty.runPort@
+
+
+ **/*TestHelloServlet*
+
+
+
+
+ integration-test
+
+ integration-test
+
+
+
+ verify
+
+ verify
+
+
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ start-jetty
+ test-compile
+
+ run-war
+
+
+ true
+
+ @jetty.runPort@
+
+
+
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..2a5ac4b71bf
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+ Jetty Simple Webapp run-mojo-it
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
new file mode 100644
index 00000000000..4e3ced68d91
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -0,0 +1,59 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestHelloServlet
+{
+ @Test
+ public void hello_servlet()
+ throws Exception
+ {
+ int port = Integer.getInteger( "jetty.runPort" );
+ System.out.println( "port used:" + port );
+ HttpClient httpClient = new HttpClient();
+ try
+ {
+ httpClient.start();
+
+ String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "hello beer", response.trim() );
+
+ response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "pong beer", response.trim() );
+ }
+ finally
+ {
+ httpClient.stop();
+ }
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
new file mode 100644
index 00000000000..432f0120781
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
@@ -0,0 +1,90 @@
+
+
+ 4.0.0
+
+ com.webtide.jetty.its.jetty-run-war-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+ pom
+
+ Jetty :: Simple
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.0
+ @project.version@
+
+
+
+ jetty-simple-base
+ jetty-simple-webapp
+
+
+
+
+
+
+ com.webtide.jetty.its.jetty-run-war-mojo-it
+ jetty-simple-base
+ ${project.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${jetty.version}
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ ${jetty.version}
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java
index 46249291769..aa81cb021d3 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunWarMojo.java
@@ -61,6 +61,10 @@ public class JettyRunWarMojo extends AbstractJettyMojo
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
+ if ( !"war".equals( project.getPackaging() ) || skip )
+ {
+ return;
+ }
super.execute();
}
From 6ac625e22605719fabef61041619a583b44a7035 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Sat, 24 Jun 2017 21:27:24 +1000
Subject: [PATCH 078/147] add it test for run war exploded mojo
Signed-off-by: olivier lamy
---
.../invoker.properties | 2 +
.../jetty-simple-base/pom.xml | 50 ++++++++
.../its/jetty_run_mojo_it/HelloServlet.java | 45 +++++++
.../its/jetty_run_mojo_it/PingServlet.java | 41 ++++++
.../main/resources/META-INF/web-fragment.xml | 32 +++++
.../jetty-simple-webapp/pom.xml | 121 ++++++++++++++++++
.../src/main/webapp/WEB-INF/web.xml | 7 +
.../jetty_run_mojo_it/TestHelloServlet.java | 59 +++++++++
.../it/jetty-run-war-exploded-mojo-it/pom.xml | 90 +++++++++++++
9 files changed, 447 insertions(+)
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties
new file mode 100644
index 00000000000..161dd58f0af
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties
@@ -0,0 +1,2 @@
+invoker.goals = verify
+#test-compile failsafe:integration-test
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
new file mode 100644
index 00000000000..4425c34f117
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
@@ -0,0 +1,50 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-base
+ jar
+
+ Jetty :: Simple :: Base
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ commons-io
+ commons-io
+
+
+
+ org.eclipse.jetty.toolchain
+ jetty-perf-helper
+ 1.0.5
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.1
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..a6d2a3e256d
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..f5686592252
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 00000000000..031012f7fed
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ FragmentA
+
+
+
+
+
+
+ Ping
+ com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+
+ extra1123
+
+
+ extra2345
+
+
+
+
+ Ping
+ /ping
+
+
+
+
\ No newline at end of file
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
new file mode 100644
index 00000000000..0489e0e1a2c
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
@@ -0,0 +1,121 @@
+
+
+ 4.0.0
+
+
+ com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+
+
+ jetty-simple-webapp
+ war
+
+ Jetty :: Simple :: Webapp
+
+
+
+
+ com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ jetty-simple-base
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-client
+ @project.version@
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin-version}
+
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
+ true
+
+ @jetty.runPort@
+
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.20
+
+
+ @jetty.runPort@
+
+
+ **/*TestHelloServlet*
+
+
+
+
+ integration-test
+
+ integration-test
+
+
+
+ verify
+
+ verify
+
+
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ start-jetty
+ test-compile
+
+ run-exploded
+
+
+ true
+
+ @jetty.runPort@
+
+
+
+
+
+
+
+
+
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..2a5ac4b71bf
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,7 @@
+
+
+ Jetty Simple Webapp run-mojo-it
+
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
new file mode 100644
index 00000000000..4e3ced68d91
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -0,0 +1,59 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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 com.webtide.jetty.its.jetty_run_mojo_it;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestHelloServlet
+{
+ @Test
+ public void hello_servlet()
+ throws Exception
+ {
+ int port = Integer.getInteger( "jetty.runPort" );
+ System.out.println( "port used:" + port );
+ HttpClient httpClient = new HttpClient();
+ try
+ {
+ httpClient.start();
+
+ String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "hello beer", response.trim() );
+
+ response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
+
+ System.out.println( "httpResponse:" + response );
+
+ Assert.assertEquals( "pong beer", response.trim() );
+ }
+ finally
+ {
+ httpClient.stop();
+ }
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
new file mode 100644
index 00000000000..5b88c8fd196
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
@@ -0,0 +1,90 @@
+
+
+ 4.0.0
+
+ com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ jetty-simple-project
+ 0.0.1-SNAPSHOT
+ pom
+
+ Jetty :: Simple
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.0
+ @project.version@
+
+
+
+ jetty-simple-base
+ jetty-simple-webapp
+
+
+
+
+
+
+ com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ jetty-simple-base
+ ${project.version}
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${jetty.version}
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ 1.8
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ ${jetty.version}
+
+
+
+
+
+
From d438c510751216a4cb5f07b2361e7c3b5d37d21e Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Sat, 24 Jun 2017 21:28:31 +1000
Subject: [PATCH 079/147] activate mojo it profile in Jenkinsfile
Signed-off-by: olivier lamy
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 0016dc734dd..185f2d6ab31 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -53,7 +53,7 @@ node {
withEnv(mvnEnv) {
timeout(time: 90, unit: 'MINUTES') {
// Run test phase / ignore test failures
- sh "mvn -B install -Dmaven.test.failure.ignore=true"
+ sh "mvn -B install -Dmaven.test.failure.ignore=true -Prun-its"
// Report failures in the jenkins UI
step([$class: 'JUnitResultArchiver',
testResults: '**/target/surefire-reports/TEST-*.xml'])
From 2648b9a6e27f2d02ce1ee0a0783cd800b0309f07 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 26 Jun 2017 13:38:00 -0700
Subject: [PATCH 080/147] Restoring 8u131 profile to main pom
From c6d45c0af1f15e1433cd30748ff40b5f16f62fad Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 26 Jun 2017 13:49:30 -0700
Subject: [PATCH 081/147] Restoring Jenkinsfile testing
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 185f2d6ab31..0016dc734dd 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -53,7 +53,7 @@ node {
withEnv(mvnEnv) {
timeout(time: 90, unit: 'MINUTES') {
// Run test phase / ignore test failures
- sh "mvn -B install -Dmaven.test.failure.ignore=true -Prun-its"
+ sh "mvn -B install -Dmaven.test.failure.ignore=true"
// Report failures in the jenkins UI
step([$class: 'JUnitResultArchiver',
testResults: '**/target/surefire-reports/TEST-*.xml'])
From 27d85cb77ed01c88dec47fd9601ad0e33792217a Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 27 Jun 2017 10:36:17 +0200
Subject: [PATCH 082/147] Issue #1643 Configure selectors for
AbstractProxyServlet
---
.../org/eclipse/jetty/proxy/AbstractProxyServlet.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
index 09c50264057..5fc8e34813d 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
@@ -44,6 +44,7 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.ProtocolHandlers;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
+import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
@@ -259,7 +260,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
*
*
*
- *
+ * @see #newHttpClient()
* @return a {@link HttpClient} configured from the {@link #getServletConfig() servlet configuration}
* @throws ServletException if the {@link HttpClient} cannot be created
*/
@@ -340,11 +341,17 @@ public abstract class AbstractProxyServlet extends HttpServlet
}
/**
+ * The servlet init parameter 'selectors' can be set for the number of
+ * selector threads to be used by the HttpClient.
* @return a new HttpClient instance
*/
protected HttpClient newHttpClient()
{
- return new HttpClient();
+ int selectors = (Runtime.getRuntime().availableProcessors() + 1) / 2;
+ String value = getServletConfig().getInitParameter("selectors");
+ if (value != null)
+ selectors = Integer.parseInt(value);
+ return new HttpClient(new HttpClientTransportOverHTTP(selectors),null);
}
protected HttpClient getHttpClient()
From c2598408d06186aa634a5532d4d2c75e2f45cea6 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Tue, 27 Jun 2017 14:15:19 -0700
Subject: [PATCH 083/147] Issue #1650 - update clirr to report on API changes
---
pom.xml | 6 +++---
tests/pom.xml | 46 ++++++++++++++++++++++++++++++++++++----------
2 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/pom.xml b/pom.xml
index 860dc214aa2..4bf8f67c652 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1092,9 +1092,9 @@
- org.neo4j.build.plugins
+ org.codehaus.mojoclirr-maven-plugin
- 1.0.1
+ 2.8clirr-report.html${project.build.directory}/clirr-report.xml
@@ -1103,7 +1103,7 @@
falsetrueinfo
- 9.3.8.v20160314
+ 9.4.6.v20170531false
diff --git a/tests/pom.xml b/tests/pom.xml
index 27e448c5e96..ea58838cf0e 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -30,16 +30,42 @@
http://www.eclipse.org/jettypom
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
-
-
- true
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+ true
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+
+ true
+
+
+
+ org.codehaus.mojo
+ clirr-maven-plugin
+
+
+ true
+
+
+
+ test-webapps
From f2970967167745d5fb407e16964a834423d74ff8 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 29 Jun 2017 08:12:11 +0200
Subject: [PATCH 084/147] Fix #1653
---
.../jetty/webapp/ClasspathPattern.java | 2 +-
.../eclipse/jetty/webapp/WebAppContext.java | 33 +++++++++++++------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java
index 9c224ef9ff0..5c089b1a331 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java
@@ -43,7 +43,7 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;
/**
- * Classpath classes list performs sequential pattern matching of a class name
+ * Classpath classes list performs pattern matching of a class name
* against an internal array of classpath pattern entries.
* A class pattern is a string of one of the forms:
*
'org.package.SomeClass' will match a specific class
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
index 070c670bd1c..5268e9e9c8a 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
@@ -702,6 +702,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
+ /**
+ * @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#add(String)}
+ * @param classOrPackageOrLocation pattern (see {@link ClasspathPattern}
+ */
@Deprecated
public void addServerClass(String classOrPackageOrLocation)
{
@@ -713,13 +717,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
/* ------------------------------------------------------------ */
/** Prepend to the list of Server classes.
- * @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
- * or a qualified package name ending with '.' (eg com.foo.). If the class
- * or package has '-' it is excluded from the server classes and order is thus
- * important when added system class patterns. This argument may also be a comma
- * separated list of classOrPackage patterns.
+ * @param classOrPackage A pattern.
* @see #setServerClasses(String[])
* @see Jetty Documentation: Classloading
+ * @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#add(String)}
*/
@Deprecated
public void prependServerClass(String classOrPackage)
@@ -757,6 +758,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
+ /**
+ *
+ * @param classOrPackage pattern
+ * @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#add(String)}
+ */
@Deprecated
public void addSystemClass(String classOrPackage)
{
@@ -769,13 +775,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
/* ------------------------------------------------------------ */
/** Prepend to the list of System classes.
- * @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
- * or a qualified package name ending with '.' (eg com.foo.). If the class
- * or package has '-' it is excluded from the system classes and order is thus
- * important when added system class patterns.This argument may also be a comma
- * separated list of classOrPackage patterns.
+ * @param classOrPackage A pattern.
* @see #setSystemClasses(String[])
* @see Jetty Documentation: Classloading
+ * @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#add(String)}
*/
@Deprecated
public void prependSystemClass(String classOrPackage)
@@ -787,6 +790,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
+ /**
+ * @param name class name
+ * @return true if matched by {@link #getServerClasspathPattern()}
+ * @deprecated Use {@link #getServerClasspathPattern()}.{@link ClasspathPattern#match(String)}
+ */
@Deprecated
public boolean isServerClass(String name)
{
@@ -797,6 +805,11 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
}
/* ------------------------------------------------------------ */
+ /**
+ * @param name class name
+ * @return true if matched by {@link #getServerClasspathPattern()}
+ * @deprecated Use {@link #getSystemClasspathPattern()}.{@link ClasspathPattern#match(String)}
+ */
@Deprecated
public boolean isSystemClass(String name)
{
From e65d0ba0e741eabe56b540c2eefede43fd771646 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Thu, 29 Jun 2017 06:43:27 -0700
Subject: [PATCH 085/147] Improving test reliability (esp on Windows)
---
.../eclipse/jetty/util/BufferUtilTest.java | 14 +++++++-------
.../util/RolloverFileOutputStreamTest.java | 6 +++---
.../org/eclipse/jetty/util/TypeUtilTest.java | 19 +++++++++++--------
.../util/resource/FileSystemResourceTest.java | 7 +++----
.../jetty/util/resource/ResourceTest.java | 5 +++--
5 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java
index 7c7a038dd4d..89a1f7e6470 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/BufferUtilTest.java
@@ -19,6 +19,12 @@
package org.eclipse.jetty.util;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
@@ -35,12 +41,6 @@ import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
public class BufferUtilTest
{
@Test
@@ -346,7 +346,7 @@ public class BufferUtilTest
String data="Now is the time for all good men to come to the aid of the party";
File file = File.createTempFile("test",".txt");
file.deleteOnExit();
- try(FileWriter out = new FileWriter(file);)
+ try(FileWriter out = new FileWriter(file))
{
out.write(data);
}
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java
index 9ee1410fc8d..2b6aeaa5493 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/RolloverFileOutputStreamTest.java
@@ -35,7 +35,7 @@ import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.FS;
-import org.eclipse.jetty.toolchain.test.TestingDir;
+import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
@@ -166,7 +166,7 @@ public class RolloverFileOutputStreamTest
@Test
public void testFileHandling() throws Exception
{
- File testDir = testingDir.getEmptyPathDir().toFile();
+ File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testFileHandling");
Path testPath = testDir.toPath();
FS.ensureEmpty(testDir);
@@ -277,7 +277,7 @@ public class RolloverFileOutputStreamTest
@Test
public void testRollover() throws Exception
{
- File testDir = testingDir.getEmptyPathDir().toFile();
+ File testDir = MavenTestingUtils.getTargetTestingDir(RolloverFileOutputStreamTest.class.getName() + "_testRollover");
FS.ensureEmpty(testDir);
TimeZone zone = toZoneId("Australia/Sydney");
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java
index 032cae7c313..d7085b9c77f 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java
@@ -19,14 +19,16 @@
package org.eclipse.jetty.util;
-import org.eclipse.jetty.toolchain.test.JDK;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
import java.nio.file.Path;
import java.nio.file.Paths;
+import org.eclipse.jetty.toolchain.test.JDK;
+import org.junit.Assert;
+import org.junit.Test;
+
public class TypeUtilTest
{
@Test
@@ -129,18 +131,19 @@ public class TypeUtilTest
public void testGetLocationOfClass() throws Exception
{
Path mavenRepoPath = Paths.get( System.getProperty( "mavenRepoPath" ) );
- String mavenRepo = mavenRepoPath.toFile().getPath();
+ String mavenRepo = mavenRepoPath.toFile().getPath().replaceAll("\\\\", "/");
+
// Classes from maven dependencies
- Assert.assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),Matchers.containsString(mavenRepo));
+ assertThat(TypeUtil.getLocationOfClass(Assert.class).toASCIIString(),containsString(mavenRepo));
// Class from project dependencies
- Assert.assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),Matchers.containsString("/classes/"));
+ assertThat(TypeUtil.getLocationOfClass(TypeUtil.class).toASCIIString(),containsString("/classes/"));
// Class from JVM core
String expectedJavaBase = "/rt.jar";
if(JDK.IS_9)
expectedJavaBase = "/java.base/";
- Assert.assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),Matchers.containsString(expectedJavaBase));
+ assertThat(TypeUtil.getLocationOfClass(String.class).toASCIIString(),containsString(expectedJavaBase));
}
}
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java
index f1e3e16316b..68b8d28266a 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/FileSystemResourceTest.java
@@ -1404,13 +1404,12 @@ public class FileSystemResourceTest
assumeTrue("Only windows supports UNC paths", OS.IS_WINDOWS);
assumeFalse("FileResource does not support this test", _class.equals(FileResource.class));
- try (Resource base = newResource(URI.create("file://127.0.0.1/path")))
+ try (Resource base = newResource(URI.create("file:////127.0.0.1/path")))
{
Resource resource = base.addPath("WEB-INF/");
assertThat("getURI()", resource.getURI().toASCIIString(), containsString("path/WEB-INF/"));
- assertThat("isAlias()", resource.isAlias(), is(true));
- assertThat("getAlias()", resource.getAlias(), notNullValue());
- assertThat("getAlias()", resource.getAlias().toASCIIString(), containsString("path/WEB-INF"));
+ assertThat("isAlias()", resource.isAlias(), is(false));
+ assertThat("getAlias()", resource.getAlias(), nullValue());
}
}
}
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
index 3937d97a248..f978024bf4d 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
@@ -196,8 +196,9 @@ public class ResourceTest
File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
FS.ensureEmpty(testDir);
- File tmpFile = File.createTempFile("test",null,testDir);
-
+ File tmpFile = new File(testDir, "test.tmp");
+ FS.touch(tmpFile);
+
cases.addCase(new Data(tmpFile.toString(),EXISTS,!DIR));
// Some resource references.
From 12e61bf97370f6975b7e51cb8eeaa10ab83ac31e Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Thu, 29 Jun 2017 09:57:28 -0700
Subject: [PATCH 086/147] Making tests more reliable on lesser FileSystems
---
.../jetty/servlet/DefaultServletTest.java | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
index cff16eeea75..833d9236298 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.servlet;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.FileOutputStream;
@@ -231,10 +232,7 @@ public class DefaultServletTest
createFile(index, "
Hello Index
");
File wackyDir = new File(resBase, "dir?");
- if (!OS.IS_WINDOWS)
- {
- FS.ensureDirExists(wackyDir);
- }
+ assumeTrue("FileSystem should support question dirs", wackyDir.mkdirs());
wackyDir = new File(resBase, "dir;");
assertTrue(wackyDir.mkdirs());
@@ -266,13 +264,8 @@ public class DefaultServletTest
response = connector.getResponse("GET /context/dir?/ HTTP/1.0\r\n\r\n");
assertResponseContains("404", response);
- if (!OS.IS_WINDOWS)
- {
- response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
- assertResponseContains("Directory: /context/dir?/<", response);
- }
- else
- assertResponseContains("404", response);
+ response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("Directory: /context/dir?/<", response);
response = connector.getResponse("GET /context/index.html HTTP/1.0\r\n\r\n");
assertResponseContains("Hello Index", response);
@@ -421,7 +414,8 @@ public class DefaultServletTest
context.setBaseResource(Resource.newResource(resBase));
File dir = new File(resBase, "dir?");
- assertTrue(dir.mkdirs());
+ assumeTrue("FileSystem should support question dirs", dir.mkdirs());
+
File index = new File(dir, "index.html");
createFile(index, "
Hello Index
");
@@ -437,7 +431,6 @@ public class DefaultServletTest
response = connector.getResponse("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
assertResponseContains("Location: http://0.0.0.0/context/dir%3F/index.html", response);
}
-
@Test
public void testWelcomeServlet() throws Exception
From 47b72399a5f3ae896bc4b71f4a47e947ad84731a Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Thu, 29 Jun 2017 14:09:37 -0400
Subject: [PATCH 087/147] Resolves #1408
---
.../clients/http/http-client-cookie.adoc | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/jetty-documentation/src/main/asciidoc/development/clients/http/http-client-cookie.adoc b/jetty-documentation/src/main/asciidoc/development/clients/http/http-client-cookie.adoc
index a2ab7b39eaa..9aa7d8839f2 100644
--- a/jetty-documentation/src/main/asciidoc/development/clients/http/http-client-cookie.adoc
+++ b/jetty-documentation/src/main/asciidoc/development/clients/http/http-client-cookie.adoc
@@ -86,3 +86,33 @@ public class GoogleOnlyCookieStore extends HttpCookieStore
----
The example above will retain only cookies that come from the `google.com` domain or sub-domains.
+
+==== Special Characters in Cookies
+Jetty is compliant with link:https://tools.ietf.org/html/rfc6265[RFC6265], and as such care must be taken when setting a cookie value that includes special characters such as `;`.
+
+Previously, Version=1 cookies defined in link:https://tools.ietf.org/html/rfc2109[RFC2109] (and continued in link:https://tools.ietf.org/html/rfc2965[RFC2965]) allowed for special/reserved characters to be enclosed within double quotes when declared in a `Set-Cookie` response header:
+
+[source, java, subs="{sub-order}"]
+----
+Set-Cookie: foo="bar;baz";Version=1;Path="/secur"
+----
+
+This was added to the HTTP Response header as follows:
+
+[source, java, subs="{sub-order}"]
+----
+Cookie cookie = new Cookie("foo", "bar;baz");
+cookie.setPath("/secur");
+response.addCookie(cookie);
+----
+
+The introduction of RFC6265 has rendered this approach no longer possible; users are now required to encode cookie values that use these special characters.
+This can be done utilizing `javax.servlet.http.Cookie` as follows:
+
+[source, java, subs="{sub-order}"]
+----
+Cookie cookie = new Cookie("foo", URLEncoder.encode("bar;baz", "utf-8"));
+----
+
+Jetty validates all cookie names and values being added to the `HttpServletResponse` via the `addCookie(Cookie)` method.
+If an illegal value is discovered Jetty will throw an `IllegalArgumentException` with the details.
From 349ee90b5d19a670f1891edea55f9a7d17c193db Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Mon, 3 Jul 2017 13:15:45 +0200
Subject: [PATCH 088/147] Issue #1643 - ProxyServlet always uses default number
of selector threads.
Reviewed changes and applied them to FastCGIProxyServlet as well.
---
.../server/proxy/FastCGIProxyServlet.java | 20 +++++++++++--------
.../jetty/proxy/AbstractProxyServlet.java | 7 ++++++-
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java
index b2cc9ffa25a..b5a42262c40 100644
--- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java
+++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java
@@ -45,23 +45,23 @@ import org.eclipse.jetty.proxy.AsyncProxyServlet;
* Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI.
*
* This servlet accepts a HTTP request and transforms it into a FastCGI request
- * that is sent to the FastCGI server specified in the proxyTo
+ * that is sent to the FastCGI server specified in the {@code proxyTo}
* init-param.
*
* This servlet accepts two additional init-params:
*
- *
scriptRoot, mandatory, that must be set to the directory where
+ *
{@code scriptRoot}, mandatory, that must be set to the directory where
* the application that must be served via FastCGI is installed and corresponds to
* the FastCGI DOCUMENT_ROOT parameter
- *
scriptPattern, optional, defaults to (.+?\.php),
+ *
{@code scriptPattern}, optional, defaults to {@code (.+?\.php)},
* that specifies a regular expression with at least 1 and at most 2 groups that specify
* respectively:
*
*
the FastCGI SCRIPT_NAME parameter
*
the FastCGI PATH_INFO parameter
*
- *
fastCGI.HTTPS, optional, defaults to false, that specifies whether
- * to force the FastCGI HTTPS parameter to the value on
+ *
{@code fastCGI.HTTPS}, optional, defaults to false, that specifies whether
+ * to force the FastCGI {@code HTTPS} parameter to the value {@code on}
*
*
* @see TryFilesFilter
@@ -111,7 +111,11 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
String scriptRoot = config.getInitParameter(SCRIPT_ROOT_INIT_PARAM);
if (scriptRoot == null)
throw new IllegalArgumentException("Mandatory parameter '" + SCRIPT_ROOT_INIT_PARAM + "' not configured");
- return new HttpClient(new ProxyHttpClientTransportOverFCGI(scriptRoot), null);
+ int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
+ String value = config.getInitParameter("selectors");
+ if (value != null)
+ selectors = Integer.parseInt(value);
+ return new HttpClient(new ProxyHttpClientTransportOverFCGI(selectors, scriptRoot), null);
}
@Override
@@ -238,9 +242,9 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
private class ProxyHttpClientTransportOverFCGI extends HttpClientTransportOverFCGI
{
- public ProxyHttpClientTransportOverFCGI(String scriptRoot)
+ private ProxyHttpClientTransportOverFCGI(int selectors, String scriptRoot)
{
- super(scriptRoot);
+ super(selectors, false, scriptRoot);
}
@Override
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
index 5fc8e34813d..cda4db05d1d 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
@@ -258,6 +258,11 @@ public abstract class AbstractProxyServlet extends HttpServlet
*
HttpClient's default
*
The response buffer size, see {@link HttpClient#setResponseBufferSize(int)}
*
+ *
+ *
selectors
+ *
cores / 2
+ *
The number of NIO selectors used by {@link HttpClient}
+ *
*
*
* @see #newHttpClient()
@@ -347,7 +352,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
*/
protected HttpClient newHttpClient()
{
- int selectors = (Runtime.getRuntime().availableProcessors() + 1) / 2;
+ int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
String value = getServletConfig().getInitParameter("selectors");
if (value != null)
selectors = Integer.parseInt(value);
From 386ca510e6a6fa177ad2a55e938fdbd844fb1293 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 3 Jul 2017 14:51:45 +0200
Subject: [PATCH 089/147] Issue #1655 added openAcceptChannel
---
.../eclipse/jetty/server/ServerConnector.java | 62 +++++++++++--------
1 file changed, 35 insertions(+), 27 deletions(-)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
index 4137f226e0c..70dab444d05 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
@@ -279,36 +279,44 @@ public class ServerConnector extends AbstractNetworkConnector
{
if (_acceptChannel == null)
{
- ServerSocketChannel serverChannel = null;
- if (isInheritChannel())
- {
- Channel channel = System.inheritedChannel();
- if (channel instanceof ServerSocketChannel)
- serverChannel = (ServerSocketChannel)channel;
- else
- LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
- }
-
- if (serverChannel == null)
- {
- serverChannel = ServerSocketChannel.open();
-
- InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
- serverChannel.socket().setReuseAddress(getReuseAddress());
- serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
-
- _localPort = serverChannel.socket().getLocalPort();
- if (_localPort <= 0)
- throw new IOException("Server channel not bound");
- }
-
- serverChannel.configureBlocking(true);
- addBean(serverChannel);
-
- _acceptChannel = serverChannel;
+ _acceptChannel = openAcceptChannel();
+ _acceptChannel.configureBlocking(true);
+ _localPort = _acceptChannel.socket().getLocalPort();
+ if (_localPort <= 0)
+ throw new IOException("Server channel not bound");
+ addBean(_acceptChannel);
}
}
+ /**
+ * Called by {@link #open()} to obtain the accepting channel.
+ * @return ServerSocketChannel used to accept connections.
+ * @throws IOException
+ */
+ protected ServerSocketChannel openAcceptChannel() throws IOException
+ {
+ ServerSocketChannel serverChannel = null;
+ if (isInheritChannel())
+ {
+ Channel channel = System.inheritedChannel();
+ if (channel instanceof ServerSocketChannel)
+ serverChannel = (ServerSocketChannel)channel;
+ else
+ LOG.warn("Unable to use System.inheritedChannel() [{}]. Trying a new ServerSocketChannel at {}:{}", channel, getHost(), getPort());
+ }
+
+ if (serverChannel == null)
+ {
+ serverChannel = ServerSocketChannel.open();
+
+ InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
+ serverChannel.socket().setReuseAddress(getReuseAddress());
+ serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
+ }
+
+ return serverChannel;
+ }
+
@Override
public Future shutdown()
{
From 7dc2559c8ba1f5cb98f7316791443d313a3240e6 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 3 Jul 2017 15:34:23 +0200
Subject: [PATCH 090/147] Issue #1655 added setter for accept channel
---
.../org/eclipse/jetty/server/ServerConnector.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
index 70dab444d05..399bff510fe 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
@@ -274,6 +274,20 @@ public class ServerConnector extends AbstractNetworkConnector
_inheritChannel = inheritChannel;
}
+
+ public ServerSocketChannel getAcceptChannel()
+ {
+ return _acceptChannel;
+ }
+
+ public void setAcceptChannel(ServerSocketChannel acceptChannel)
+ {
+ if (isStarted())
+ throw new IllegalStateException(getState());
+ updateBean(_acceptChannel,acceptChannel);
+ _acceptChannel = acceptChannel;
+ }
+
@Override
public void open() throws IOException
{
@@ -288,6 +302,7 @@ public class ServerConnector extends AbstractNetworkConnector
}
}
+
/**
* Called by {@link #open()} to obtain the accepting channel.
* @return ServerSocketChannel used to accept connections.
From 2202d333fe08dc30bc9179a92d0f31460dccb2ea Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 3 Jul 2017 17:48:07 +0200
Subject: [PATCH 091/147] Issue #1655 ServerConnector configured with channel
converted setter to open method
added test harness
---
.../eclipse/jetty/server/ServerConnector.java | 21 ++++----
.../jetty/server/ServerConnectorTest.java | 48 +++++++++++++++++++
2 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
index 399bff510fe..1d296fb82f9 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
@@ -266,7 +266,7 @@ public class ServerConnector extends AbstractNetworkConnector
*
Use it with xinetd/inetd, to launch an instance of Jetty on demand. The port
* used to access pages on the Jetty instance is the same as the port used to
* launch Jetty.
- *
+ * @see ServerConnector#openAcceptChannel()
* @param inheritChannel whether this connector uses a channel inherited from the JVM.
*/
public void setInheritChannel(boolean inheritChannel)
@@ -274,18 +274,22 @@ public class ServerConnector extends AbstractNetworkConnector
_inheritChannel = inheritChannel;
}
-
- public ServerSocketChannel getAcceptChannel()
- {
- return _acceptChannel;
- }
-
- public void setAcceptChannel(ServerSocketChannel acceptChannel)
+ /**
+ * Open the connector using the passed ServerSocketChannel.
+ * This open method can be called before starting the connector to pass it a ServerSocketChannel
+ * that will be used instead of one returned from {@link #openAcceptChannel()}
+ * @param acceptChannel the channel to use
+ * @throws IOException
+ */
+ public void open(ServerSocketChannel acceptChannel) throws IOException
{
if (isStarted())
throw new IllegalStateException(getState());
updateBean(_acceptChannel,acceptChannel);
_acceptChannel = acceptChannel;
+ _localPort = _acceptChannel.socket().getLocalPort();
+ if (_localPort <= 0)
+ throw new IOException("Server channel not bound");
}
@Override
@@ -302,7 +306,6 @@ public class ServerConnector extends AbstractNetworkConnector
}
}
-
/**
* Called by {@link #open()} to obtain the accepting channel.
* @return ServerSocketChannel used to accept connections.
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
index 832ca51f836..d89088a6634 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java
@@ -32,9 +32,11 @@ import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.channels.ServerSocketChannel;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
@@ -52,8 +54,20 @@ import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.hamcrest.Matchers;
+import org.junit.Assert;
import org.junit.Test;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
public class ServerConnectorTest
{
public static class ReuseInfoHandler extends AbstractHandler
@@ -265,5 +279,39 @@ public class ServerConnectorTest
{
server.stop();
}
+ }
+
+ @Test
+ public void testOpenWithServerSocketChannel() throws Exception
+ {
+ Server server = new Server();
+ ServerConnector connector = new ServerConnector(server);
+ server.addConnector(connector);
+
+ ServerSocketChannel channel = ServerSocketChannel.open();
+ channel.bind(new InetSocketAddress(0));
+
+ assertTrue(channel.isOpen());
+ int port = channel.socket().getLocalPort();
+ assertThat(port,greaterThan(0));
+
+ connector.open(channel);
+
+ assertThat(connector.getLocalPort(),is(port));
+
+ server.start();
+
+ assertThat(connector.getLocalPort(),is(port));
+ assertThat(connector.getTransport(),is(channel));
+
+ server.stop();
+
+ assertThat(connector.getTransport(),Matchers.nullValue());
+
+
+
+
+
+
}
}
From 191b6e044f285f4bb131f512b8a20e5f336dbb36 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 4 Jul 2017 11:23:17 +0200
Subject: [PATCH 092/147] Fixes #1656 - Improve configurability of
ConnectionPools.
Introduced ConnectionPool.Factory and HttpClientTransport.connectionPoolFactory.
This allows applications to create a ConnectionPool given the HttpDestination.
---
.../AbstractConnectorHttpClientTransport.java | 183 ++++++++++++++++++
.../client/AbstractHttpClientTransport.java | 160 +--------------
.../eclipse/jetty/client/ConnectionPool.java | 53 +++++
.../jetty/client/HttpClientTransport.java | 10 +
.../eclipse/jetty/client/HttpDestination.java | 5 +-
.../client/MultiplexHttpDestination.java | 6 -
.../jetty/client/PoolingHttpDestination.java | 5 -
.../http/HttpClientTransportOverHTTP.java | 6 +-
.../client/ValidatingConnectionPoolTest.java | 31 +--
.../http/HttpClientTransportOverFCGI.java | 15 +-
.../server/AbstractHttpClientServerTest.java | 29 +--
.../http/HttpClientTransportOverHTTP2.java | 32 ++-
.../jetty/http/client/HttpClientLoadTest.java | 58 ++----
13 files changed, 313 insertions(+), 280 deletions(-)
create mode 100644 jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
new file mode 100644
index 00000000000..e50294ba3f5
--- /dev/null
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectorHttpClientTransport.java
@@ -0,0 +1,183 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.client;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
+import java.util.Map;
+
+import org.eclipse.jetty.client.api.Connection;
+import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.io.ManagedSelector;
+import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.io.SocketChannelEndPoint;
+import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
+import org.eclipse.jetty.util.Promise;
+import org.eclipse.jetty.util.annotation.ManagedAttribute;
+
+public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpClientTransport
+{
+ private final int selectors;
+ private SelectorManager selectorManager;
+
+ protected AbstractConnectorHttpClientTransport(int selectors)
+ {
+ this.selectors = selectors;
+ }
+
+ @ManagedAttribute(value = "The number of selectors", readonly = true)
+ public int getSelectors()
+ {
+ return selectors;
+ }
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ HttpClient httpClient = getHttpClient();
+ selectorManager = newSelectorManager(httpClient);
+ selectorManager.setConnectTimeout(httpClient.getConnectTimeout());
+ addBean(selectorManager);
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ super.doStop();
+ removeBean(selectorManager);
+ }
+
+ @Override
+ public void connect(InetSocketAddress address, Map context)
+ {
+ SocketChannel channel = null;
+ try
+ {
+ channel = SocketChannel.open();
+ HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
+ HttpClient client = destination.getHttpClient();
+ SocketAddress bindAddress = client.getBindAddress();
+ if (bindAddress != null)
+ channel.bind(bindAddress);
+ configure(client, channel);
+
+ context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
+ context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
+
+ if (client.isConnectBlocking())
+ {
+ channel.socket().connect(address, (int)client.getConnectTimeout());
+ channel.configureBlocking(false);
+ selectorManager.accept(channel, context);
+ }
+ else
+ {
+ channel.configureBlocking(false);
+ if (channel.connect(address))
+ selectorManager.accept(channel, context);
+ else
+ selectorManager.connect(channel, context);
+ }
+ }
+ // Must catch all exceptions, since some like
+ // UnresolvedAddressException are not IOExceptions.
+ catch (Throwable x)
+ {
+ // If IPv6 is not deployed, a generic SocketException "Network is unreachable"
+ // exception is being thrown, so we attempt to provide a better error message.
+ if (x.getClass() == SocketException.class)
+ x = new SocketException("Could not connect to " + address).initCause(x);
+
+ try
+ {
+ if (channel != null)
+ channel.close();
+ }
+ catch (IOException xx)
+ {
+ LOG.ignore(xx);
+ }
+ finally
+ {
+ connectFailed(context, x);
+ }
+ }
+ }
+
+ protected void connectFailed(Map context, Throwable x)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Could not connect to {}", context.get(HTTP_DESTINATION_CONTEXT_KEY));
+ @SuppressWarnings("unchecked")
+ Promise promise = (Promise)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
+ promise.failed(x);
+ }
+
+ protected void configure(HttpClient client, SocketChannel channel) throws IOException
+ {
+ channel.socket().setTcpNoDelay(client.isTCPNoDelay());
+ }
+
+ protected SelectorManager newSelectorManager(HttpClient client)
+ {
+ return new ClientSelectorManager(client, getSelectors());
+ }
+
+ protected class ClientSelectorManager extends SelectorManager
+ {
+ private final HttpClient client;
+
+ protected ClientSelectorManager(HttpClient client, int selectors)
+ {
+ super(client.getExecutor(), client.getScheduler(), selectors);
+ this.client = client;
+ }
+
+ @Override
+ protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key)
+ {
+ SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
+ endp.setIdleTimeout(client.getIdleTimeout());
+ return endp;
+ }
+
+ @Override
+ public org.eclipse.jetty.io.Connection newConnection(SelectableChannel channel, EndPoint endPoint, Object attachment) throws IOException
+ {
+ @SuppressWarnings("unchecked")
+ Map context = (Map)attachment;
+ HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
+ return destination.getClientConnectionFactory().newConnection(endPoint, context);
+ }
+
+ @Override
+ protected void connectionFailed(SelectableChannel channel, Throwable x, Object attachment)
+ {
+ @SuppressWarnings("unchecked")
+ Map context = (Map)attachment;
+ connectFailed(context, x);
+ }
+ }
+}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
index 0b120aa6a16..499c170c69e 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpClientTransport.java
@@ -18,24 +18,6 @@
package org.eclipse.jetty.client;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.SocketChannel;
-import java.util.Map;
-
-import org.eclipse.jetty.client.api.Connection;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.io.ManagedSelector;
-import org.eclipse.jetty.io.SelectChannelEndPoint;
-import org.eclipse.jetty.io.SelectorManager;
-import org.eclipse.jetty.io.SocketChannelEndPoint;
-import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
-import org.eclipse.jetty.util.Promise;
-import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
@@ -46,14 +28,8 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
{
protected static final Logger LOG = Log.getLogger(HttpClientTransport.class);
- private final int selectors;
- private volatile HttpClient client;
- private volatile SelectorManager selectorManager;
-
- protected AbstractHttpClientTransport(int selectors)
- {
- this.selectors = selectors;
- }
+ private HttpClient client;
+ private ConnectionPool.Factory factory;
protected HttpClient getHttpClient()
{
@@ -66,137 +42,15 @@ public abstract class AbstractHttpClientTransport extends ContainerLifeCycle imp
this.client = client;
}
- @ManagedAttribute(value = "The number of selectors", readonly = true)
- public int getSelectors()
+ @Override
+ public ConnectionPool.Factory getConnectionPoolFactory()
{
- return selectors;
+ return factory;
}
@Override
- protected void doStart() throws Exception
+ public void setConnectionPoolFactory(ConnectionPool.Factory factory)
{
- selectorManager = newSelectorManager(client);
- selectorManager.setConnectTimeout(client.getConnectTimeout());
- addBean(selectorManager);
- super.doStart();
- }
-
- @Override
- protected void doStop() throws Exception
- {
- super.doStop();
- removeBean(selectorManager);
- }
-
- @Override
- public void connect(InetSocketAddress address, Map context)
- {
- SocketChannel channel = null;
- try
- {
- channel = SocketChannel.open();
- HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
- HttpClient client = destination.getHttpClient();
- SocketAddress bindAddress = client.getBindAddress();
- if (bindAddress != null)
- channel.bind(bindAddress);
- configure(client, channel);
-
- context.put(SslClientConnectionFactory.SSL_PEER_HOST_CONTEXT_KEY, destination.getHost());
- context.put(SslClientConnectionFactory.SSL_PEER_PORT_CONTEXT_KEY, destination.getPort());
-
- if (client.isConnectBlocking())
- {
- channel.socket().connect(address, (int)client.getConnectTimeout());
- channel.configureBlocking(false);
- selectorManager.accept(channel, context);
- }
- else
- {
- channel.configureBlocking(false);
- if (channel.connect(address))
- selectorManager.accept(channel, context);
- else
- selectorManager.connect(channel, context);
- }
- }
- // Must catch all exceptions, since some like
- // UnresolvedAddressException are not IOExceptions.
- catch (Throwable x)
- {
- // If IPv6 is not deployed, a generic SocketException "Network is unreachable"
- // exception is being thrown, so we attempt to provide a better error message.
- if (x.getClass() == SocketException.class)
- x = new SocketException("Could not connect to " + address).initCause(x);
-
- try
- {
- if (channel != null)
- channel.close();
- }
- catch (IOException xx)
- {
- LOG.ignore(xx);
- }
- finally
- {
- connectFailed(context, x);
- }
- }
- }
-
- protected void connectFailed(Map context, Throwable x)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("Could not connect to {}", context.get(HTTP_DESTINATION_CONTEXT_KEY));
- @SuppressWarnings("unchecked")
- Promise promise = (Promise)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY);
- promise.failed(x);
- }
-
- protected void configure(HttpClient client, SocketChannel channel) throws IOException
- {
- channel.socket().setTcpNoDelay(client.isTCPNoDelay());
- }
-
- protected SelectorManager newSelectorManager(HttpClient client)
- {
- return new ClientSelectorManager(client, selectors);
- }
-
- protected class ClientSelectorManager extends SelectorManager
- {
- private final HttpClient client;
-
- protected ClientSelectorManager(HttpClient client, int selectors)
- {
- super(client.getExecutor(), client.getScheduler(), selectors);
- this.client = client;
- }
-
- @Override
- protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key)
- {
- SocketChannelEndPoint endp = new SocketChannelEndPoint(channel, selector, key, getScheduler());
- endp.setIdleTimeout(client.getIdleTimeout());
- return endp;
- }
-
- @Override
- public org.eclipse.jetty.io.Connection newConnection(SelectableChannel channel, EndPoint endPoint, Object attachment) throws IOException
- {
- @SuppressWarnings("unchecked")
- Map context = (Map)attachment;
- HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
- return destination.getClientConnectionFactory().newConnection(endPoint, context);
- }
-
- @Override
- protected void connectionFailed(SelectableChannel channel, Throwable x, Object attachment)
- {
- @SuppressWarnings("unchecked")
- Map context = (Map)attachment;
- connectFailed(context, x);
- }
+ this.factory = factory;
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
index 9bdcc297a44..effaa0da802 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
@@ -22,20 +22,73 @@ import java.io.Closeable;
import org.eclipse.jetty.client.api.Connection;
+/**
+ *
Client-side connection pool abstraction.
+ */
public interface ConnectionPool extends Closeable
{
+ /**
+ * @param connection the connection to test
+ * @return whether the given connection is currently in use
+ */
boolean isActive(Connection connection);
+ /**
+ * @return whether this ConnectionPool has no open connections
+ */
boolean isEmpty();
+ /**
+ * @return whether this ConnectionPool has been closed
+ * @see #close()
+ */
boolean isClosed();
+ /**
+ *
Returns an idle connection, if available, or schedules the opening
+ * of a new connection and returns {@code null}.
+ *
+ * @return an available connection, or null
+ */
Connection acquire();
+ /**
+ *
Returns the given connection, previously obtained via {@link #acquire()},
+ * back to this ConnectionPool.
+ *
+ * @param connection the connection to release
+ * @return true if the connection has been released, false if the connection
+ * was not obtained from the this ConnectionPool
+ */
boolean release(Connection connection);
+ /**
+ *
Removes the given connection from this ConnectionPool.
+ *
+ * @param connection the connection to remove
+ * @return true if the connection was removed from this ConnectionPool
+ */
boolean remove(Connection connection);
+ /**
+ * Closes this ConnectionPool.
+ *
+ * @see #isClosed()
+ */
@Override
void close();
+
+ /**
+ * Factory for ConnectionPool instances.
+ */
+ interface Factory
+ {
+ /**
+ * Creates a new ConnectionPool for the given destination.
+ *
+ * @param destination the destination to create the ConnectionPool for
+ * @return the newly created ConnectionPool
+ */
+ ConnectionPool newConnectionPool(HttpDestination destination);
+ }
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
index 45382531b1d..b799b1be1de 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClientTransport.java
@@ -68,4 +68,14 @@ public interface HttpClientTransport extends ClientConnectionFactory
* @param context the context information to establish the connection
*/
public void connect(InetSocketAddress address, Map context);
+
+ /**
+ * @return the factory for ConnectionPool instances
+ */
+ public ConnectionPool.Factory getConnectionPoolFactory();
+
+ /**
+ * @param factory the factory for ConnectionPool instances
+ */
+ public void setConnectionPoolFactory(ConnectionPool.Factory factory);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
index dbc4ba4f787..bbe3bb375e5 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
@@ -114,7 +114,10 @@ public abstract class HttpDestination extends ContainerLifeCycle implements Dest
removeBean(connectionPool);
}
- protected abstract ConnectionPool newConnectionPool(HttpClient client);
+ protected ConnectionPool newConnectionPool(HttpClient client)
+ {
+ return client.getTransport().getConnectionPoolFactory().newConnectionPool(this);
+ }
protected Queue newExchangeQueue(HttpClient client)
{
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
index 4267a40be15..da168f889f0 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/MultiplexHttpDestination.java
@@ -25,12 +25,6 @@ public abstract class MultiplexHttpDestination extends HttpDestination
super(client, origin);
}
- protected ConnectionPool newConnectionPool(HttpClient client)
- {
- return new MultiplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this,
- client.getMaxRequestsQueuedPerDestination());
- }
-
public int getMaxRequestsPerConnection()
{
ConnectionPool connectionPool = getConnectionPool();
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
index a9ee093e67a..9746052497f 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/PoolingHttpDestination.java
@@ -24,9 +24,4 @@ public abstract class PoolingHttpDestination extends HttpDestination
{
super(client, origin);
}
-
- protected ConnectionPool newConnectionPool(HttpClient client)
- {
- return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
- }
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java
index 931ca304299..1380c52b48b 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java
@@ -21,7 +21,8 @@ package org.eclipse.jetty.client.http;
import java.io.IOException;
import java.util.Map;
-import org.eclipse.jetty.client.AbstractHttpClientTransport;
+import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
+import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.HttpDestination;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Connection;
@@ -30,7 +31,7 @@ import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("The HTTP/1.1 client transport")
-public class HttpClientTransportOverHTTP extends AbstractHttpClientTransport
+public class HttpClientTransportOverHTTP extends AbstractConnectorHttpClientTransport
{
public HttpClientTransportOverHTTP()
{
@@ -40,6 +41,7 @@ public class HttpClientTransportOverHTTP extends AbstractHttpClientTransport
public HttpClientTransportOverHTTP(int selectors)
{
super(selectors);
+ setConnectionPoolFactory(destination -> new DuplexConnectionPool(destination, getHttpClient().getMaxConnectionsPerDestination(), destination));
}
@Override
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java
index 5beda2959fa..5629d2dc938 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ValidatingConnectionPoolTest.java
@@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
-import org.eclipse.jetty.client.http.HttpDestinationOverHTTP;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
@@ -50,7 +49,11 @@ public class ValidatingConnectionPoolTest extends AbstractHttpClientServerTest
@Override
protected void startClient() throws Exception
{
- startClient(new ValidatingHttpClientTransportOverHTTP(1000));
+ long timeout = 1000;
+ HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP(1);
+ transport.setConnectionPoolFactory(destination ->
+ new ValidatingConnectionPool(destination, destination.getHttpClient().getMaxConnectionsPerDestination(), destination, destination.getHttpClient().getScheduler(), timeout));
+ startClient(transport);
}
@Test
@@ -177,28 +180,4 @@ public class ValidatingConnectionPoolTest extends AbstractHttpClientServerTest
ContentResponse response2 = listener2.get(5, TimeUnit.SECONDS);
Assert.assertEquals(200, response2.getStatus());
}
-
- private static class ValidatingHttpClientTransportOverHTTP extends HttpClientTransportOverHTTP
- {
- private final long timeout;
-
- public ValidatingHttpClientTransportOverHTTP(long timeout)
- {
- super(1);
- this.timeout = timeout;
- }
-
- @Override
- public HttpDestination newHttpDestination(Origin origin)
- {
- return new HttpDestinationOverHTTP(getHttpClient(), origin)
- {
- @Override
- protected DuplexConnectionPool newConnectionPool(HttpClient client)
- {
- return new ValidatingConnectionPool(this, client.getMaxConnectionsPerDestination(), this, client.getScheduler(), timeout);
- }
- };
- }
- }
}
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java
index aded21e1b48..693c56fb990 100644
--- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java
+++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java
@@ -21,8 +21,11 @@ package org.eclipse.jetty.fcgi.client.http;
import java.io.IOException;
import java.util.Map;
-import org.eclipse.jetty.client.AbstractHttpClientTransport;
+import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
+import org.eclipse.jetty.client.DuplexConnectionPool;
+import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpDestination;
+import org.eclipse.jetty.client.MultiplexConnectionPool;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Request;
@@ -34,7 +37,7 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("The FastCGI/1.0 client transport")
-public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
+public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTransport
{
private final boolean multiplexed;
private final String scriptRoot;
@@ -49,6 +52,14 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
super(selectors);
this.multiplexed = multiplexed;
this.scriptRoot = scriptRoot;
+ setConnectionPoolFactory(destination ->
+ {
+ HttpClient httpClient = getHttpClient();
+ int maxConnections = httpClient.getMaxConnectionsPerDestination();
+ return isMultiplexed() ?
+ new MultiplexConnectionPool(destination, maxConnections, destination, httpClient.getMaxRequestsQueuedPerDestination()) :
+ new DuplexConnectionPool(destination, maxConnections, destination);
+ });
}
public boolean isMultiplexed()
diff --git a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java
index b9a8346e7ee..58452512ccd 100644
--- a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java
+++ b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java
@@ -20,13 +20,10 @@ package org.eclipse.jetty.fcgi.server;
import java.util.concurrent.atomic.AtomicLong;
-import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.HttpDestination;
+import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
-import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI;
-import org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
@@ -72,28 +69,16 @@ public abstract class AbstractHttpClientServerTest
QueuedThreadPool executor = new QueuedThreadPool();
executor.setName(executor.getName() + "-client");
- client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "")
+ HttpClientTransport transport = new HttpClientTransportOverFCGI(1, false, "");
+ transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
{
@Override
- public HttpDestination newHttpDestination(Origin origin)
+ protected void leaked(LeakDetector.LeakInfo leakInfo)
{
- return new HttpDestinationOverFCGI(client, origin)
- {
- @Override
- protected DuplexConnectionPool newConnectionPool(HttpClient client)
- {
- return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
- {
- @Override
- protected void leaked(LeakDetector.LeakInfo leakInfo)
- {
- connectionLeaks.incrementAndGet();
- }
- };
- }
- };
+ connectionLeaks.incrementAndGet();
}
- }, null);
+ });
+ client = new HttpClient(transport, null);
client.setExecutor(executor);
clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
client.setByteBufferPool(clientBufferPool);
diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
index 81f96481bf6..76a5cf036eb 100644
--- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
+++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2.java
@@ -24,9 +24,10 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory;
+import org.eclipse.jetty.client.AbstractHttpClientTransport;
import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.HttpDestination;
+import org.eclipse.jetty.client.MultiplexConnectionPool;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.ProxyConfiguration;
import org.eclipse.jetty.client.api.Connection;
@@ -42,20 +43,23 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
-import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@ManagedObject("The HTTP/2 client transport")
-public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements HttpClientTransport
+public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
{
private final HTTP2Client client;
private ClientConnectionFactory connectionFactory;
- private HttpClient httpClient;
private boolean useALPN = true;
public HttpClientTransportOverHTTP2(HTTP2Client client)
{
this.client = client;
+ setConnectionPoolFactory(destination ->
+ {
+ HttpClient httpClient = getHttpClient();
+ return new MultiplexConnectionPool(destination, httpClient.getMaxConnectionsPerDestination(), destination, httpClient.getMaxRequestsQueuedPerDestination());
+ });
}
@ManagedAttribute(value = "The number of selectors", readonly = true)
@@ -79,6 +83,7 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
{
if (!client.isStarted())
{
+ HttpClient httpClient = getHttpClient();
client.setExecutor(httpClient.getExecutor());
client.setScheduler(httpClient.getScheduler());
client.setByteBufferPool(httpClient.getByteBufferPool());
@@ -104,34 +109,23 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
removeBean(client);
}
- protected HttpClient getHttpClient()
- {
- return httpClient;
- }
-
- @Override
- public void setHttpClient(HttpClient client)
- {
- httpClient = client;
- }
-
@Override
public HttpDestination newHttpDestination(Origin origin)
{
- return new HttpDestinationOverHTTP2(httpClient, origin);
+ return new HttpDestinationOverHTTP2(getHttpClient(), origin);
}
@Override
public void connect(InetSocketAddress address, Map context)
{
- client.setConnectTimeout(httpClient.getConnectTimeout());
+ client.setConnectTimeout(getHttpClient().getConnectTimeout());
SessionListenerPromise listenerPromise = new SessionListenerPromise(context);
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
SslContextFactory sslContextFactory = null;
if (HttpScheme.HTTPS.is(destination.getScheme()))
- sslContextFactory = httpClient.getSslContextFactory();
+ sslContextFactory = getHttpClient().getSslContextFactory();
client.connect(sslContextFactory, address, listenerPromise, listenerPromise, context);
}
@@ -139,7 +133,7 @@ public class HttpClientTransportOverHTTP2 extends ContainerLifeCycle implements
@Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map context) throws IOException
{
- endPoint.setIdleTimeout(httpClient.getIdleTimeout());
+ endPoint.setIdleTimeout(getHttpClient().getIdleTimeout());
ClientConnectionFactory factory = connectionFactory;
HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2)context.get(HTTP_DESTINATION_CONTEXT_KEY);
diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientLoadTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientLoadTest.java
index 99e65cb44de..4da12ae0527 100644
--- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientLoadTest.java
+++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientLoadTest.java
@@ -34,20 +34,14 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.client.ConnectionPool;
-import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
-import org.eclipse.jetty.client.HttpDestination;
import org.eclipse.jetty.client.LeakTrackingConnectionPool;
-import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
-import org.eclipse.jetty.client.http.HttpDestinationOverHTTP;
import org.eclipse.jetty.client.util.BytesContentProvider;
import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI;
-import org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.io.ArrayByteBufferPool;
@@ -97,55 +91,31 @@ public class HttpClientLoadTest extends AbstractTest
case HTTP:
case HTTPS:
{
- return new HttpClientTransportOverHTTP(1)
+ HttpClientTransport clientTransport = new HttpClientTransportOverHTTP(1);
+ clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
{
@Override
- public HttpDestination newHttpDestination(Origin origin)
+ protected void leaked(LeakDetector.LeakInfo leakInfo)
{
- return new HttpDestinationOverHTTP(getHttpClient(), origin)
- {
- @Override
- protected ConnectionPool newConnectionPool(HttpClient client)
- {
- return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
- {
- @Override
- protected void leaked(LeakDetector.LeakInfo leakInfo)
- {
- super.leaked(leakInfo);
- connectionLeaks.incrementAndGet();
- }
- };
- }
- };
+ super.leaked(leakInfo);
+ connectionLeaks.incrementAndGet();
}
- };
+ });
+ return clientTransport;
}
case FCGI:
{
- return new HttpClientTransportOverFCGI(1, false, "")
+ HttpClientTransport clientTransport = new HttpClientTransportOverFCGI(1, false, "");
+ clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
{
@Override
- public HttpDestination newHttpDestination(Origin origin)
+ protected void leaked(LeakDetector.LeakInfo leakInfo)
{
- return new HttpDestinationOverFCGI(getHttpClient(), origin)
- {
- @Override
- protected ConnectionPool newConnectionPool(HttpClient client)
- {
- return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this)
- {
- @Override
- protected void leaked(LeakDetector.LeakInfo leakInfo)
- {
- super.leaked(leakInfo);
- connectionLeaks.incrementAndGet();
- }
- };
- }
- };
+ super.leaked(leakInfo);
+ connectionLeaks.incrementAndGet();
}
- };
+ });
+ return clientTransport;
}
default:
{
From d63c7a4eb645ae0e237bf4cc36c3d69a25f21955 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Wed, 5 Jul 2017 10:54:57 -0700
Subject: [PATCH 093/147] Updating .gitattributes
---
.gitattributes | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitattributes b/.gitattributes
index 362c7b13a4a..2d74f3a7f01 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,8 @@
*.sh eol=lf
*.bat eol=crlf
*.txt eol=lf
+*.properties eol=lf
+*.java eol=lf
+*.xml eol=lf
+Jenkinsfile eol=lf
*.js eol=lf
\ No newline at end of file
From b8759bc2c7f91a633e3fae4be76f0665c3aa6203 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 10 Jul 2017 18:17:16 -0700
Subject: [PATCH 094/147] Renaming to fit Eclipse Jetty naming guidelines
---
.../jetty-simple-base/pom.xml | 2 +-
.../its/jetty_run_mojo_it/HelloServlet.java | 2 +-
.../its/jetty_run_mojo_it/PingServlet.java | 2 +-
.../main/resources/META-INF/web-fragment.xml | 2 +-
.../jetty-simple-webapp/pom.xml | 4 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 2 +-
.../src/it/jetty-run-forked-mojo-it/pom.xml | 4 +-
.../jetty-simple-base/pom.xml | 2 +-
.../its/jetty_run_mojo_it/HelloServlet.java | 2 +-
.../its/jetty_run_mojo_it/PingServlet.java | 2 +-
.../main/resources/META-INF/web-fragment.xml | 2 +-
.../jetty-simple-webapp/pom.xml | 4 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 2 +-
.../src/it/jetty-run-mojo-it/pom.xml | 4 +-
.../jetty-simple-base/pom.xml | 2 +-
.../its/jetty_run_mojo_it/HelloServlet.java | 2 +-
.../its/jetty_run_mojo_it/PingServlet.java | 2 +-
.../main/resources/META-INF/web-fragment.xml | 2 +-
.../jetty-simple-webapp/pom.xml | 4 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 2 +-
.../it/jetty-run-war-exploded-mojo-it/pom.xml | 4 +-
.../jetty-simple-base/pom.xml | 2 +-
.../its/jetty_run_mojo_it/HelloServlet.java | 2 +-
.../its/jetty_run_mojo_it/PingServlet.java | 2 +-
.../main/resources/META-INF/web-fragment.xml | 2 +-
.../jetty-simple-webapp/pom.xml | 4 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 2 +-
.../src/it/jetty-run-war-mojo-it/pom.xml | 4 +-
.../jetty-simple-base/pom.xml | 2 +-
.../its/jetty_run_mojo_it/HelloServlet.java | 45 -------------------
.../its/jetty_run_mojo_it/PingServlet.java | 41 -----------------
.../its/jetty_run_mojo_it/HelloServlet.java | 45 +++++++++++++++++++
.../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++
.../main/resources/META-INF/web-fragment.xml | 2 +-
.../jetty-simple-webapp/pom.xml | 4 +-
.../jetty_run_mojo_it/TestHelloServlet.java | 2 +-
.../src/it/jetty-start-mojo-it/pom.xml | 4 +-
37 files changed, 129 insertions(+), 129 deletions(-)
rename jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/{com/webtide => org/eclipse}/jetty/its/jetty_run_mojo_it/HelloServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/PingServlet.java (96%)
rename jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/{com/webtide => org/eclipse}/jetty/its/jetty_run_mojo_it/TestHelloServlet.java (97%)
rename jetty-maven-plugin/src/it/{jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/HelloServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/PingServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide => jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse}/jetty/its/jetty_run_mojo_it/TestHelloServlet.java (97%)
rename jetty-maven-plugin/src/it/{jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/HelloServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/PingServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide => jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse}/jetty/its/jetty_run_mojo_it/TestHelloServlet.java (97%)
rename jetty-maven-plugin/src/it/{jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide => jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse}/jetty/its/jetty_run_mojo_it/HelloServlet.java (96%)
rename jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/{com/webtide => org/eclipse}/jetty/its/jetty_run_mojo_it/PingServlet.java (96%)
rename jetty-maven-plugin/src/it/{jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide => jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse}/jetty/its/jetty_run_mojo_it/TestHelloServlet.java (97%)
delete mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
delete mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
create mode 100644 jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
rename jetty-maven-plugin/src/it/{jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide => jetty-start-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse}/jetty/its/jetty_run_mojo_it/TestHelloServlet.java (97%)
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
index 594ddba4c8d..7cb2a2e00be 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-forked-mojo-it
+ org.eclipse.jetty.its.jetty-run-forked-mojo-itjetty-simple-project0.0.1-SNAPSHOT
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
index a6d2a3e256d..b45f5d2c476 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
index f5686592252..c43fe013720 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
index 031012f7fed..a1ec4e27ce4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -14,7 +14,7 @@
Ping
- com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+ org.eclipse.jetty.its.jetty_run_mojo_it.PingServletextra1123
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
index 3c6f21d22ea..fa400e45aa1 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-forked-mojo-it
+ org.eclipse.jetty.its.jetty-run-forked-mojo-itjetty-simple-project0.0.1-SNAPSHOT
@@ -22,7 +22,7 @@
- com.webtide.jetty.its.jetty-run-forked-mojo-it
+ org.eclipse.jetty.its.jetty-run-forked-mojo-itjetty-simple-base
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
similarity index 97%
rename from jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index f48eee38074..31a195c1407 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -16,7 +16,7 @@
// ========================================================================
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
index cada3739cce..fae3f39a0c6 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.webtide.jetty.its.jetty-run-forked-mojo-it
+ org.eclipse.jetty.its.jetty-run-forked-mojo-itjetty-simple-project0.0.1-SNAPSHOTpom
@@ -27,7 +27,7 @@
- com.webtide.jetty.its.jetty-run-forked-mojo-it
+ org.eclipse.jetty.its.jetty-run-forked-mojo-itjetty-simple-base${project.version}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
index c29b270cb61..94e3cf2b8ee 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-mojo-it
+ org.eclipse.jetty.its.jetty-run-mojo-itjetty-simple-project0.0.1-SNAPSHOT
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
index a6d2a3e256d..b45f5d2c476 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
index f5686592252..c43fe013720 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
index 031012f7fed..a1ec4e27ce4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -14,7 +14,7 @@
Ping
- com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+ org.eclipse.jetty.its.jetty_run_mojo_it.PingServletextra1123
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
index ce4d50f13ec..7fb521911d7 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-mojo-it
+ org.eclipse.jetty.its.jetty-run-mojo-itjetty-simple-project0.0.1-SNAPSHOT
@@ -17,7 +17,7 @@
- com.webtide.jetty.its.jetty-run-mojo-it
+ org.eclipse.jetty.its.jetty-run-mojo-itjetty-simple-base
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
similarity index 97%
rename from jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 4e3ced68d91..5d700a60525 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
index 3d303f4caf8..213a79af16b 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.webtide.jetty.its.jetty-run-mojo-it
+ org.eclipse.jetty.its.jetty-run-mojo-itjetty-simple-project0.0.1-SNAPSHOTpom
@@ -27,7 +27,7 @@
- com.webtide.jetty.its.jetty-run-mojo-it
+ org.eclipse.jetty.its.jetty-run-mojo-itjetty-simple-base${project.version}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
index 4425c34f117..3ae1e093bb8 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-exploded-mojo-itjetty-simple-project0.0.1-SNAPSHOT
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
index a6d2a3e256d..b45f5d2c476 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
index f5686592252..c43fe013720 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
index 031012f7fed..a1ec4e27ce4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -14,7 +14,7 @@
Ping
- com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+ org.eclipse.jetty.its.jetty_run_mojo_it.PingServletextra1123
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
index 0489e0e1a2c..6cab86275c0 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-exploded-mojo-itjetty-simple-project0.0.1-SNAPSHOT
@@ -17,7 +17,7 @@
- com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-exploded-mojo-itjetty-simple-base
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
similarity index 97%
rename from jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 4e3ced68d91..5d700a60525 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
index 5b88c8fd196..a6ef2713d27 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-exploded-mojo-itjetty-simple-project0.0.1-SNAPSHOTpom
@@ -27,7 +27,7 @@
- com.webtide.jetty.its.jetty-run-war-exploded-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-exploded-mojo-itjetty-simple-base${project.version}
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
index 8903e68d8a0..8f0aab6e5ad 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-war-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-mojo-itjetty-simple-project0.0.1-SNAPSHOT
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
index a6d2a3e256d..b45f5d2c476 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
similarity index 96%
rename from jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
index f5686592252..c43fe013720 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
index 031012f7fed..a1ec4e27ce4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -14,7 +14,7 @@
Ping
- com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+ org.eclipse.jetty.its.jetty_run_mojo_it.PingServletextra1123
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
index 23109b90f00..f9ba41b965d 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-run-war-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-mojo-itjetty-simple-project0.0.1-SNAPSHOT
@@ -17,7 +17,7 @@
- com.webtide.jetty.its.jetty-run-war-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-mojo-itjetty-simple-base
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
similarity index 97%
rename from jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 4e3ced68d91..5d700a60525 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
index 432f0120781..a48c4d51db1 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.webtide.jetty.its.jetty-run-war-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-mojo-itjetty-simple-project0.0.1-SNAPSHOTpom
@@ -27,7 +27,7 @@
- com.webtide.jetty.its.jetty-run-war-mojo-it
+ org.eclipse.jetty.its.jetty-run-war-mojo-itjetty-simple-base${project.version}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
index 7a9a5382308..a5e1cb9cea5 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-start-mojo-it
+ org.eclipse.jetty.its.jetty-start-mojo-itjetty-simple-project0.0.1-SNAPSHOT
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
deleted file mode 100644
index a6d2a3e256d..00000000000
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// 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 com.webtide.jetty.its.jetty_run_mojo_it;
-
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- *
- */
-@WebServlet("/hello")
-public class HelloServlet
- extends HttpServlet
-{
-
- @Override
- protected void doGet( HttpServletRequest req, HttpServletResponse resp )
- throws ServletException, IOException
- {
- String who = req.getParameter( "name" );
-
- resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
- }
-}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
deleted file mode 100644
index f5686592252..00000000000
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// 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 com.webtide.jetty.its.jetty_run_mojo_it;
-
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public class PingServlet
- extends HttpServlet
-{
-
- @Override
- protected void doGet( HttpServletRequest req, HttpServletResponse resp )
- throws ServletException, IOException
- {
- String who = req.getParameter( "name" );
-
- resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
- }
-}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
new file mode 100644
index 00000000000..b45f5d2c476
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/HelloServlet.java
@@ -0,0 +1,45 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+@WebServlet("/hello")
+public class HelloServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "hello " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
new file mode 100644
index 00000000000..c43fe013720
--- /dev/null
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/org/eclipse/jetty/its/jetty_run_mojo_it/PingServlet.java
@@ -0,0 +1,41 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.its.jetty_run_mojo_it;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class PingServlet
+ extends HttpServlet
+{
+
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ String who = req.getParameter( "name" );
+
+ resp.getWriter().write( "pong " + (who == null ? "unknown" : who) );
+ }
+}
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
index 031012f7fed..a1ec4e27ce4 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml
@@ -14,7 +14,7 @@
Ping
- com.webtide.jetty.its.jetty_run_mojo_it.PingServlet
+ org.eclipse.jetty.its.jetty_run_mojo_it.PingServletextra1123
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
index 38ae1555a4b..fdb6bf16cff 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/pom.xml
@@ -4,7 +4,7 @@
4.0.0
- com.webtide.jetty.its.jetty-start-mojo-it
+ org.eclipse.jetty.its.jetty-start-mojo-itjetty-simple-project0.0.1-SNAPSHOT
@@ -17,7 +17,7 @@
- com.webtide.jetty.its.jetty-start-mojo-it
+ org.eclipse.jetty.its.jetty-start-mojo-itjetty-simple-base
diff --git a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
similarity index 97%
rename from jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
rename to jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 4e3ced68d91..5d700a60525 100644
--- a/jetty-maven-plugin/src/it/jetty-run-war-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -17,7 +17,7 @@
//
-package com.webtide.jetty.its.jetty_run_mojo_it;
+package org.eclipse.jetty.its.jetty_run_mojo_it;
import org.eclipse.jetty.client.HttpClient;
import org.junit.Assert;
diff --git a/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
index 7319c0d604f..58add42c68c 100644
--- a/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- com.webtide.jetty.its.jetty-start-mojo-it
+ org.eclipse.jetty.its.jetty-start-mojo-itjetty-simple-project0.0.1-SNAPSHOTpom
@@ -27,7 +27,7 @@
- com.webtide.jetty.its.jetty-start-mojo-it
+ org.eclipse.jetty.its.jetty-start-mojo-itjetty-simple-base${project.version}
From 15cc8f1d40bc1ba7cfa5090bdbadaa8a2b5aa595 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Wed, 12 Jul 2017 11:34:14 -0400
Subject: [PATCH 095/147] Documentation update for Connectors. Resolves #1663
---
.../configuring/connectors/configuring-connectors.adoc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-connectors.adoc b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-connectors.adoc
index d3df02c9f34..5f9719ae1f7 100644
--- a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-connectors.adoc
+++ b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-connectors.adoc
@@ -41,6 +41,8 @@ link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-ssl.xml[`jetty-ssl.xm
On it's own, this connector is not functional and requires one or more of the following files to also be configured to add link:{JDURL}/org/eclipse/jetty/server/ConnectionFactory.html[`ConnectionFactories`] to make the connector functional.
link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-https.xml[`jetty-https.xml`]::
Adds a link:{JDURL}/org/eclipse/jetty/server/HttpConnectionFactory.html[`HttpConnectionFactory`] to the link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] configured by `jetty-ssl.xml` which combine to provide support for HTTPS.
+link:{GITBROWSEURL}/jetty-server/src/main/config/etc/jetty-http-forwarded.xml[`jetty-http-forwarded.xml`]::
+ Adds a link:{JDURL}/org/eclipse/jetty/server/ForwardedRequestCustomizer.html[`ForwardedRequestCustomizer`]to the HTTP Connector to process forwarded-for style headers from a proxy.
link:{GITBROWSEURL}/jetty-http2/http2-server/src/main/config/etc/jetty-http2.xml[`jetty-http2.xml`]::
Adds a link:{JDURL}/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.html[`Http2ServerConnectionFactory`] to the link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] configured by `jetty-ssl.xml` to support the http2 protocol. Also prepends either `protonego-alpn.xml` or `protonego-npn.xml` so that the next protocol can be negotiated, which allows the same SSL port to handle multiple protocols.
link:{GITBROWSEURL}/jetty-alpn/jetty-alpn-server/src/main/config/etc/jetty-alpn.xml[`jetty-alpn.xml`]::
@@ -49,6 +51,12 @@ link:{GITBROWSEURL}/jetty-alpn/jetty-alpn-server/src/main/config/etc/jetty-alpn.
Typically connectors require very little configuration aside from setting the listening port (see link:#jetty-connectors-network-settings[Network Settings]), and enabling `X-Forwarded-For` customization when applicable. (see link:#jetty-connectors-http-configuration[HTTP Configuration]).
Additional settings are for expert configuration only.
+____
+[NOTE]
+All the connectors discussed in this chapter can be enabled in the Jetty Distribution by enabling them via the module system.
+Please refer to our chapter on link:#startup-modules[Managing Startup Modules] for more information.
+____
+
==== Constructing a ServerConnector
The services a link:{JDURL}/org/eclipse/jetty/server/ServerConnector.html[`ServerConnector`] instance uses are set by constructor injection and once instantiated cannot be changed.
From 6a2dd626e0836a0b31d02f87ca45e558a2853217 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 13 Jul 2017 14:14:36 +0200
Subject: [PATCH 096/147] Issue #1661 Portable onProxyResponseFailure
avoid using sendError(-1)
---
.../jetty/proxy/AbstractProxyServlet.java | 62 +++++++++----------
.../eclipse/jetty/proxy/ProxyServletTest.java | 6 +-
2 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
index cda4db05d1d..9199c27f2e6 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
@@ -638,35 +638,14 @@ public abstract class AbstractProxyServlet extends HttpServlet
if (_log.isDebugEnabled())
_log.debug(getRequestId(clientRequest) + " proxying failed", failure);
- if (proxyResponse.isCommitted())
- {
- try
- {
- // Use Jetty specific behavior to close connection.
- proxyResponse.sendError(-1);
- if (clientRequest.isAsyncStarted())
- {
- AsyncContext asyncContext = clientRequest.getAsyncContext();
- asyncContext.complete();
- }
- }
- catch (Throwable x)
- {
- if (_log.isDebugEnabled())
- _log.debug(getRequestId(clientRequest) + " could not close the connection", failure);
- }
- }
- else
- {
- proxyResponse.resetBuffer();
- int status = failure instanceof TimeoutException ?
- HttpStatus.GATEWAY_TIMEOUT_504 :
- HttpStatus.BAD_GATEWAY_502;
- int serverStatus = serverResponse == null ? status : serverResponse.getStatus();
- if (expects100Continue(clientRequest) && serverStatus >= HttpStatus.OK_200)
- status = serverStatus;
- sendProxyResponseError(clientRequest, proxyResponse, status);
- }
+ int status = failure instanceof TimeoutException ?
+ HttpStatus.GATEWAY_TIMEOUT_504 :
+ HttpStatus.BAD_GATEWAY_502;
+ int serverStatus = serverResponse == null ? status : serverResponse.getStatus();
+ if (expects100Continue(clientRequest) && serverStatus >= HttpStatus.OK_200)
+ status = serverStatus;
+ sendProxyResponseError(clientRequest, proxyResponse, status);
+
}
protected int getRequestId(HttpServletRequest clientRequest)
@@ -676,10 +655,27 @@ public abstract class AbstractProxyServlet extends HttpServlet
protected void sendProxyResponseError(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, int status)
{
- proxyResponse.setStatus(status);
- proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
- if (clientRequest.isAsyncStarted())
- clientRequest.getAsyncContext().complete();
+ try
+ {
+ System.err.println("sendError "+status+" "+proxyResponse.isCommitted());
+ new Throwable().printStackTrace();
+ if (!proxyResponse.isCommitted())
+ {
+ proxyResponse.resetBuffer();
+ proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
+ }
+ proxyResponse.sendError(status);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ _log.ignore(e);
+ }
+ finally
+ {
+ if (clientRequest.isAsyncStarted())
+ clientRequest.getAsyncContext().complete();
+ }
}
protected void onContinue(HttpServletRequest clientRequest, Request proxyRequest)
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
index fe6118e0d62..52fd04c6a4e 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
@@ -1087,10 +1087,10 @@ public class ProxyServletTest
Response response = listener.get(5, TimeUnit.SECONDS);
Assert.assertEquals(504, response.getStatus());
- // Make sure there is no content, as the proxy-to-client response has been reset.
+ // Make sure there is error page content, as the proxy-to-client response has been reset.
InputStream input = listener.getInputStream();
- Assert.assertEquals(-1, input.read());
-
+ String body = IO.toString(input);
+ Assert.assertThat(body,Matchers.containsString("HTTP ERROR: 504"));
chunk1Latch.countDown();
// Result succeeds because a 504 is a valid HTTP response.
From 2b4494e3f649c2f69bd3bccf73db79b0ef05da25 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 13 Jul 2017 14:16:51 +0200
Subject: [PATCH 097/147] Issue #1661 remove debug
---
.../java/org/eclipse/jetty/proxy/AbstractProxyServlet.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
index 9199c27f2e6..d51e14053dc 100644
--- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
+++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java
@@ -657,8 +657,6 @@ public abstract class AbstractProxyServlet extends HttpServlet
{
try
{
- System.err.println("sendError "+status+" "+proxyResponse.isCommitted());
- new Throwable().printStackTrace();
if (!proxyResponse.isCommitted())
{
proxyResponse.resetBuffer();
@@ -668,7 +666,6 @@ public abstract class AbstractProxyServlet extends HttpServlet
}
catch(Exception e)
{
- e.printStackTrace();
_log.ignore(e);
}
finally
From e5f7fee279b03e0d122c96b6b45758f5eede7ab2 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 13 Jul 2017 15:41:21 +0200
Subject: [PATCH 098/147] Fix #1664 CIDR IP
---
.../java/org/eclipse/jetty/util/InetAddressSet.java | 4 ++--
.../org/eclipse/jetty/util/InetAddressSetTest.java | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/InetAddressSet.java b/jetty-util/src/main/java/org/eclipse/jetty/util/InetAddressSet.java
index 0c616878fbf..c42f2a3ea33 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/InetAddressSet.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/InetAddressSet.java
@@ -246,11 +246,11 @@ public class InetAddressSet extends AbstractSet implements Set,
_octets = cidr/8;
_mask = 0xff&(0xff<<(8-cidr%8));
_masked = _mask==0?0:_raw[_octets]&_mask;
-
+
if (cidr>(_raw.length*8))
throw new IllegalArgumentException("CIDR too large: "+pattern);
- if (_mask!=0 && _raw[_octets]!=_masked)
+ if (_mask!=0 && (0xff&_raw[_octets])!=_masked)
throw new IllegalArgumentException("CIDR bits non zero: "+pattern);
for (int o=_octets+(_mask==0?0:1);o<_raw.length;o++)
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/InetAddressSetTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/InetAddressSetTest.java
index c52585291c0..14c650980ea 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/InetAddressSetTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/InetAddressSetTest.java
@@ -134,8 +134,21 @@ public class InetAddressSetTest
set.add("0.0.0.0/0");
assertTrue(set.test(InetAddress.getByName("10.11.0.0")));
+
+ // test #1664
+ set.add("2.144.0.0/14");
+ set.add("2.176.0.0/12");
+ set.add("5.22.0.0/17");
+ set.add("5.22.192.0/19");
+ assertTrue(set.test(InetAddress.getByName("2.144.0.1")));
+ assertTrue(set.test(InetAddress.getByName("2.176.0.1")));
+ assertTrue(set.test(InetAddress.getByName("5.22.0.1")));
+ assertTrue(set.test(InetAddress.getByName("5.22.192.1")));
}
+
+
+
@Test
public void testBadCIDR() throws Exception
{
From e39c66d42568cc63e50d935ad7036bd87dd1bd18 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Thu, 13 Jul 2017 16:03:58 +0200
Subject: [PATCH 099/147] Issue #1645
---
.../org/eclipse/jetty/servlets/DoSFilter.java | 131 +++++++++++++++---
.../jetty/servlets/AbstractDoSFilterTest.java | 21 +++
.../eclipse/jetty/servlets/DoSFilterTest.java | 9 +-
3 files changed, 140 insertions(+), 21 deletions(-)
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
index a5dab447b6b..9920479b944 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
@@ -146,7 +146,8 @@ public class DoSFilter implements Filter
private static final long __DEFAULT_THROTTLE_MS = 30000L;
private static final long __DEFAULT_MAX_REQUEST_MS_INIT_PARAM = 30000L;
private static final long __DEFAULT_MAX_IDLE_TRACKER_MS_INIT_PARAM = 30000L;
-
+
+ static final String NAME = "name";
static final String MANAGED_ATTR_INIT_PARAM = "managedAttr";
static final String MAX_REQUESTS_PER_S_INIT_PARAM = "maxRequestsPerSec";
static final String DELAY_MS_INIT_PARAM = "delayMs";
@@ -181,12 +182,14 @@ public class DoSFilter implements Filter
private volatile boolean _trackSessions;
private volatile boolean _remotePort;
private volatile boolean _enabled;
+ private volatile String _name;
private Semaphore _passes;
private volatile int _throttledRequests;
private volatile int _maxRequestsPerSec;
private Queue[] _queues;
private AsyncListener[] _listeners;
private Scheduler _scheduler;
+ private ServletContext _context;
public void init(FilterConfig filterConfig) throws ServletException
{
@@ -263,11 +266,14 @@ public class DoSFilter implements Filter
parameter = filterConfig.getInitParameter(TOO_MANY_CODE);
setTooManyCode(parameter==null?429:Integer.parseInt(parameter));
- _scheduler = startScheduler();
+ setName(filterConfig.getFilterName());
+ _context = filterConfig.getServletContext();
+ if (_context != null )
+ {
+ _context.setAttribute(filterConfig.getFilterName(), this);
+ }
- ServletContext context = filterConfig.getServletContext();
- if (context != null && Boolean.parseBoolean(filterConfig.getInitParameter(MANAGED_ATTR_INIT_PARAM)))
- context.setAttribute(filterConfig.getFilterName(), this);
+ _scheduler = startScheduler();
}
protected Scheduler startScheduler() throws ServletException
@@ -536,6 +542,11 @@ public class DoSFilter implements Filter
{
return USER_AUTH;
}
+
+ public void schedule (RateTracker tracker)
+ {
+ _scheduler.schedule(tracker, getMaxIdleTrackerMs(), TimeUnit.MILLISECONDS);
+ }
/**
* Return a request rate tracker associated with this connection; keeps
@@ -583,8 +594,9 @@ public class DoSFilter implements Filter
{
boolean allowed = checkWhitelist(request.getRemoteAddr());
int maxRequestsPerSec = getMaxRequestsPerSec();
- tracker = allowed ? new FixedRateTracker(loadId, type, maxRequestsPerSec)
- : new RateTracker(loadId, type, maxRequestsPerSec);
+ tracker = allowed ? new FixedRateTracker(_context, _name, loadId, type, maxRequestsPerSec)
+ : new RateTracker(_context,_name, loadId, type, maxRequestsPerSec);
+ tracker.setContext(_context);
RateTracker existing = _rateTrackers.putIfAbsent(loadId, tracker);
if (existing != null)
tracker = existing;
@@ -603,6 +615,16 @@ public class DoSFilter implements Filter
return tracker;
}
+
+ public void addToRateTracker (RateTracker tracker)
+ {
+ _rateTrackers.put(tracker.getId(), tracker);
+ }
+
+ public void removeFromRateTracker (String id)
+ {
+ _rateTrackers.remove(id);
+ }
protected boolean checkWhitelist(String candidate)
{
@@ -931,6 +953,25 @@ public class DoSFilter implements Filter
_maxIdleTrackerMs = value;
}
+ /**
+ * The unique name of the filter when there is more than
+ * one DosFilter instance.
+ *
+ * @return the name
+ */
+ public String getName()
+ {
+ return _name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
/**
* Check flag to insert the DoSFilter headers into the response.
*
@@ -1103,17 +1144,22 @@ public class DoSFilter implements Filter
* A RateTracker is associated with a connection, and stores request rate
* data.
*/
- class RateTracker implements Runnable, HttpSessionBindingListener, HttpSessionActivationListener, Serializable
+ static class RateTracker implements Runnable, HttpSessionBindingListener, HttpSessionActivationListener, Serializable
{
private static final long serialVersionUID = 3534663738034577872L;
+ protected final String _filterName;
+ protected transient ServletContext _context;
protected final String _id;
protected final int _type;
protected final long[] _timestamps;
+
protected int _next;
- public RateTracker(String id, int type, int maxRequestsPerSecond)
+ public RateTracker(ServletContext context, String filterName, String id, int type, int maxRequestsPerSecond)
{
+ _context = context;
+ _filterName = filterName;
_id = id;
_type = type;
_timestamps = new long[maxRequestsPerSecond];
@@ -1151,40 +1197,87 @@ public class DoSFilter implements Filter
{
if (LOG.isDebugEnabled())
LOG.debug("Value bound: {}", getId());
+ _context = event.getSession().getServletContext();
}
public void valueUnbound(HttpSessionBindingEvent event)
{
//take the tracker out of the list of trackers
- _rateTrackers.remove(_id);
- if (LOG.isDebugEnabled())
- LOG.debug("Tracker removed: {}", getId());
+ DoSFilter filter = (DoSFilter)event.getSession().getServletContext().getAttribute(_filterName);
+ removeFromRateTrackers(filter, _id);
+ _context = null;
}
public void sessionWillPassivate(HttpSessionEvent se)
{
//take the tracker of the list of trackers (if its still there)
- _rateTrackers.remove(_id);
+ DoSFilter filter = (DoSFilter)se.getSession().getServletContext().getAttribute(_filterName);
+ removeFromRateTrackers(filter, _id);
+ _context = null;
}
public void sessionDidActivate(HttpSessionEvent se)
{
RateTracker tracker = (RateTracker)se.getSession().getAttribute(__TRACKER);
- if (tracker!=null)
- _rateTrackers.put(tracker.getId(),tracker);
+ ServletContext context = se.getSession().getServletContext();
+ tracker.setContext(context);
+ DoSFilter filter = (DoSFilter)context.getAttribute(_filterName);
+ if (filter == null)
+ {
+ LOG.info("No filter {} for rate tracker {}", _filterName, tracker);
+ return;
+ }
+ addToRateTrackers(filter, tracker);
+ }
+
+ public void setContext (ServletContext context)
+ {
+ _context = context;
+ }
+
+
+ protected void removeFromRateTrackers (DoSFilter filter, String id)
+ {
+ if (filter == null)
+ return;
+
+ filter.removeFromRateTracker(id);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Tracker removed: {}", getId());
+ }
+
+
+ protected void addToRateTrackers (DoSFilter filter, RateTracker tracker)
+ {
+ if (filter == null)
+ return;
+ filter.addToRateTracker(tracker);
}
@Override
public void run()
{
+ if (_context == null)
+ {
+ LOG.warn("Unknkown context for rate tracker {}", this);
+ return;
+ }
+
int latestIndex = _next == 0 ? (_timestamps.length - 1) : (_next - 1);
long last = _timestamps[latestIndex];
boolean hasRecentRequest = last != 0 && (System.currentTimeMillis() - last) < 1000L;
+ DoSFilter filter = (DoSFilter)_context.getAttribute(_filterName);
+
if (hasRecentRequest)
- _scheduler.schedule(this, getMaxIdleTrackerMs(), TimeUnit.MILLISECONDS);
+ {
+ if (filter != null)
+ filter.schedule(this);
+ else
+ LOG.warn("No filter {}", _filterName);
+ }
else
- _rateTrackers.remove(_id);
+ removeFromRateTrackers(filter, _id);
}
@Override
@@ -1196,9 +1289,9 @@ public class DoSFilter implements Filter
class FixedRateTracker extends RateTracker
{
- public FixedRateTracker(String id, int type, int numRecentRequestsTracked)
+ public FixedRateTracker(ServletContext context, String filterName, String id, int type, int numRecentRequestsTracked)
{
- super(id, type, numRecentRequestsTracked);
+ super(context, filterName, id, type, numRecentRequestsTracked);
}
@Override
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
index 74141ddc872..d1c8f7810bb 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/AbstractDoSFilterTest.java
@@ -18,11 +18,13 @@
package org.eclipse.jetty.servlets;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
@@ -34,12 +36,17 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpURI;
+import org.eclipse.jetty.server.session.DefaultSessionCache;
+import org.eclipse.jetty.server.session.FileSessionDataStore;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletTester;
+import org.eclipse.jetty.toolchain.test.FS;
+import org.eclipse.jetty.toolchain.test.TestingDir;
import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
public abstract class AbstractDoSFilterTest
@@ -49,9 +56,23 @@ public abstract class AbstractDoSFilterTest
protected int _port;
protected long _requestMaxTime = 200;
+ @Rule
+ public TestingDir _testDir = new TestingDir();
+
public void startServer(Class extends Filter> filter) throws Exception
{
_tester = new ServletTester("/ctx");
+
+ DefaultSessionCache sessionCache = new DefaultSessionCache(_tester.getContext().getSessionHandler());
+ FileSessionDataStore fileStore = new FileSessionDataStore();
+
+ Path p = _testDir.getPathFile("sessions");
+ FS.ensureEmpty(p);
+ fileStore.setStoreDir(p.toFile());
+ sessionCache.setSessionDataStore(fileStore);
+
+ _tester.getContext().getSessionHandler().setSessionCache(sessionCache);
+
HttpURI uri = new HttpURI(_tester.createConnector(true));
_host = uri.getHost();
_port = uri.getPort();
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java
index 72bec4061c6..bbbe09bb5e2 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/DoSFilterTest.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.servlets;
+import javax.servlet.ServletContext;
+
+import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.servlets.DoSFilter.RateTracker;
import org.hamcrest.Matchers;
import org.junit.Assert;
@@ -36,7 +39,7 @@ public class DoSFilterTest extends AbstractDoSFilterTest
public void testRateIsRateExceeded() throws InterruptedException
{
DoSFilter doSFilter = new DoSFilter();
-
+ doSFilter.setName("foo");
boolean exceeded = hitRateTracker(doSFilter,0);
Assert.assertTrue("Last hit should have exceeded",exceeded);
@@ -49,6 +52,7 @@ public class DoSFilterTest extends AbstractDoSFilterTest
public void testWhitelist() throws Exception
{
DoSFilter filter = new DoSFilter();
+ filter.setName("foo");
filter.setWhitelist("192.168.0.1/32,10.0.0.0/8,4d8:0:a:1234:ABc:1F:b18:17,4d8:0:a:1234:ABc:1F:0:0/96");
Assert.assertTrue(filter.checkWhitelist("192.168.0.1"));
Assert.assertFalse(filter.checkWhitelist("192.168.0.2"));
@@ -72,7 +76,8 @@ public class DoSFilterTest extends AbstractDoSFilterTest
private boolean hitRateTracker(DoSFilter doSFilter, int sleep) throws InterruptedException
{
boolean exceeded = false;
- RateTracker rateTracker = doSFilter.new RateTracker("test2",0,4);
+ ServletContext context = new ContextHandler.StaticContext();
+ RateTracker rateTracker = new RateTracker(context, doSFilter.getName(), "test2",0,4);
for (int i = 0; i < 5; i++)
{
From e94660b7ba047df0f8cc3bb529fdecb1959b3601 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 13 Jul 2017 16:51:24 +0200
Subject: [PATCH 100/147] fixed merge
---
.../src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
index 52fd04c6a4e..51f9d40ccc3 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
@@ -1090,7 +1090,7 @@ public class ProxyServletTest
// Make sure there is error page content, as the proxy-to-client response has been reset.
InputStream input = listener.getInputStream();
String body = IO.toString(input);
- Assert.assertThat(body,Matchers.containsString("HTTP ERROR: 504"));
+ Assert.assertThat(body,Matchers.containsString("HTTP ERROR 504"));
chunk1Latch.countDown();
// Result succeeds because a 504 is a valid HTTP response.
From b8168f2bb0f1ee3632b26d7d13fe6b381a3fd224 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Fri, 14 Jul 2017 11:17:51 -0400
Subject: [PATCH 101/147] Updates to SSL documentation. Resolves #1667
---
.../connectors/configuring-ssl.adoc | 177 ++++++++++--------
1 file changed, 97 insertions(+), 80 deletions(-)
diff --git a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
index 62a1a3bbdf3..bace232bf7d 100644
--- a/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
+++ b/jetty-documentation/src/main/asciidoc/configuring/connectors/configuring-ssl.adoc
@@ -19,6 +19,16 @@
This document provides an overview of how to configure SSL and TLS for Jetty.
+[[configuring-jetty-for-ssl]]
+===== Configuring Jetty for SSL
+
+To configure Jetty for SSL, complete the tasks in the following sections:
+
+* xref:generating-key-pairs-and-certificates[]
+* xref:requesting-trusted-certificate[]
+* xref:loading-keys-and-certificates[]
+* xref:configuring-sslcontextfactory[]
+
[[tls-and-ssl-versions]]
==== TLS and SSL versions
@@ -78,16 +88,6 @@ Since Apache and other servers commonly use the OpenSSL tool suite to generate a
If you want the option of using the same certificate with Jetty or a web server such as Apache not written in Java, you might prefer to generate your private key and certificate with OpenSSL.
-[[configuring-jetty-for-ssl]]
-===== Configuring Jetty for SSL
-
-To configure Jetty for SSL, complete the tasks in the following sections:
-
-* xref:generating-key-pairs-and-certificates[]
-* xref:requesting-trusted-certificate[]
-* xref:loading-keys-and-certificates[]
-* xref:configuring-sslcontextfactory[]
-
[[generating-key-pairs-and-certificates]]
===== Generating Key Pairs and Certificates
@@ -354,75 +354,16 @@ $ keytool -importkeystore -srckeystore jetty.pkcs12 -srcstoretype PKCS12 -destke
If you are updating your configuration to use a newer certificate, as when the old one is expiring, just load the newer certificate as described in the section, xref:loading-keys-and-certificates[].
If you imported the key and certificate originally using the PKCS12 method, use an alias of "1" rather than "jetty", because that is the alias the PKCS12 process enters into the keystore.
-==== Configuring SSL in Jetty Distribution
-
-For those of you using the Jetty Distribution, enabling SSL support is as easy as activating the `ssl` module.
-
-An example of this setup:
-
-[source, plain, subs="{sub-order}"]
-----
-$ cd /path/to/mybase
-$ java -jar ../start.jar --create-startd
-MKDIR : ${jetty.base}/start.d
-INFO : Base directory was modified
-$ java -jar /path/to/jetty-dist/start.jar --add-to-start=ssl
-INFO : server transitively enabled, ini template available with --add-to-start=server
-INFO : ssl initialized in ${jetty.base}/start.d/ssl.ini
-MKDIR : ${jetty.base}/etc
-COPY : ${jetty.home}/modules/ssl/keystore to ${jetty.base}/etc/keystore
-INFO : Base directory was modified
-$ tree
-.
-├── etc
-│  └── keystore
-└── start.d
- ├── server.ini
- └── ssl.ini
-----
-
-When you open `start.d/ssl.ini`, you will see many commented properties ready for you to configure the `SslContextFactory` basics.
-
-To highlight some of the more commonly used properties:
-
-jetty.ssl.host::
- Configures which interfaces the SSL/TLS Connector should listen on.
-jetty.ssl.port::
- Configures which port the SSL/TLS Connector should listen on.
-jetty.httpConfig.securePort::
- If a webapp needs to redirect to a secure version of the same resource, then this is the port reported back on the response `location` line (having this be separate is useful if you have something sitting in front of Jetty, such as a Load Balancer or proxy).
-jetty.sslContext.keyStorePath::
- Sets the location of the `keystore` that you configured with your certificates.
-jetty.sslContext.keyStorePassword::
- Sets the Password for the `keystore`.
-
-[[two-way-authentication]]
-==== Two Way Authentication
-
-To enable two-way authentication both the `ssl` and `https` modules need to be activated.
-Once enabled, set the `jetty.sslContext.needClientAuth` property to `true`.
-
-[source%nowrap,ini,linenums]
-.$JETTY_BASE/start.d/ssl.ini
-----
-# Module: ssl
---module=ssl
-...
-## whether client certificate authentication is required
-jetty.sslContext.needClientAuth=true
-...
-----
-
[[layout-of-keystore-and-truststore]]
-==== Layout of keystore and truststore
+===== Layout of keystore and truststore
-The server's private key and certificate are contained within the keystore.
+The `keystore` only contains the server's private key and certificate.
[[img-certificate-chain]]
image::images/certificate-chain.png[title="Certificate chain", alt="Certificate chain"]
[literal]
-.The structure of a KeyStore file
+.The structure of KeyStore file:
....
├── PrivateKeyEntry
│  ├── PrivateKey
@@ -436,10 +377,10 @@ image::images/certificate-chain.png[title="Certificate chain", alt="Certificate
  └── Root CA certificate
....
-[TIP]
-====
-`PrivateKeyEntry`, `Certificate chain`, `Intermediary CA certificate` and `Root CA certificate` are all optional values.
-====
+____
+[NOTE]
+Both the `Intermediary CA certificate` and `Root CA certificate` are optional.
+____
[source%nowrap,plain,linenums]
----
@@ -779,8 +720,84 @@ ____
==== Configuring SNI
From Java 8, the JVM contains support for the http://en.wikipedia.org/wiki/Server_Name_Indication[Server Name Indicator (SNI)] extension, which allows a SSL connection handshake to indicate one or more DNS names that it applies to.
-To support this, the `ExtendedSslContextFactory` is used that will look for multiple X509 certificates within the keystore, each of which may have multiple DNS names (including wildcards) associated with the http://en.wikipedia.org/wiki/SubjectAltName[Subject Alternate Name] extension.
-When using the `ExtendedSSlContextFactory`, the correct certificate is automatically selected if the SNI extension is present in the handshake.
+
+To support this, the `SslContextFactory` is used.
+The `SslContextFactory` will look for multiple X509 certificates within the keystore, each of which may have multiple DNS names (including wildcards) associated with the http://en.wikipedia.org/wiki/SubjectAltName[Subject Alternate Name] extension.
+When using the `SslContextFactory`, the correct certificate is automatically selected if the SNI extension is present in the handshake.
+
+
+==== Configuring SSL in Jetty Distribution
+
+For those of you using the Jetty Distribution, enabling SSL support is as easy as activating the `ssl` module.
+
+An example of this setup:
+
+[source, plain, subs="{sub-order}"]
+----
+$ cd /path/to/mybase
+$ java -jar /path/to/jetty-dist/start.jar --add-to-startd=ssl
+INFO : server initialised (transitively) in ${jetty.base}/start.d/server.ini
+INFO : ssl initialised in ${jetty.base}/start.d/ssl.ini
+INFO : Base directory was modified
+$ tree
+.
+├── etc
+│  └── keystore
+└── start.d
+ ├── server.ini
+ └── ssl.ini
+----
+
+When you open `start.d/ssl.ini`, you will see several commented properties ready for use when configuring `SslContextFactory` basics.
+
+To highlight some of the more commonly used properties:
+
+jetty.ssl.host::
+ Configures which interfaces the SSL/TLS Connector should listen on.
+jetty.ssl.port::
+ Configures which port the SSL/TLS Connector should listen on.
+jetty.httpConfig.securePort::
+ If a webapp needs to redirect to a secure version of the same resource, then this is the port reported back on the response `location` line (having this be separate is useful if you have something sitting in front of Jetty, such as a Load Balancer or proxy).
+jetty.sslContext.keyStorePath::
+ Sets the location of the `keystore` that you configured with your certificates.
+jetty.sslContext.keyStorePassword::
+ Sets the Password for the `keystore`.
+
+[[two-way-authentication]]
+==== Two Way Authentication
+
+To enable two-way authentication in the Jetty Distribution, you need to enable the both the `ssl` and `https` modules.
+
+[source, plain, subs="{sub-order}"]
+----
+$ cd /path/to/mybase
+$ java -jar /path/to/jetty-dist/start.jar --add-to-startd=ssl,https
+----
+
+[source%nowrap,ini,linenums]
+.$JETTY_BASE/start.d/ssl.ini
+----
+# Module: ssl
+--module=ssl
+
+jetty.ssl.host=0.0.0.0
+jetty.ssl.port=8583
+jetty.sslContext.keyStorePath=etc/keystore
+jetty.sslContext.trustStorePath=etc/keystore
+jetty.sslContext.keyStorePassword=OBF:
+jetty.sslContext.keyManagerPassword=OBF:
+jetty.sslContext.trustStorePassword=OBF:
+jetty.sslContext.trustStoreType=JKS
+# enable two way authentication
+jetty.sslContext.needClientAuth=true
+----
+
+[source%nowrap,ini,linenums]
+.$JETTY_BASE/start.d/https.ini
+----
+# Module: https
+--module=https
+----
[[configuring-sslcontextfactory-cipherSuites]]
==== Disabling/Enabling Specific Cipher Suites
@@ -796,7 +813,7 @@ Tools like ssllabs.com might report slightly different names which will be ignor
____
____
-[NOTE]
+[IMPORTANT]
It's recommended to install the Java Cryptography Extension (JCE) Unlimited Strength policy files in your JRE to get full strength ciphers such as AES-256.
The files can be found on the http://www.oracle.com/technetwork/java/javase/downloads/index.html[Java download page].
Just overwrite the two present JAR files in `/lib/security/`.
@@ -849,7 +866,7 @@ ____
[NOTE]
The default `SslContextFactory` implementation applies the latest SSL/TLS recommendations surrounding vulnerabilities in SSL/TLS.
Check the release notes (the `VERSION.txt` found in the root of the Jetty Distribution, or the http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.jetty%22%20AND%20a%3A%22jetty-project%22[alternate (classified 'version') artifacts for the `jetty-project` component]on Maven Central) for updates.
-The Java JVM is also applying exclusions at the JVM level and as such if you have a need to enable something that is generally accepted by the industry as being insecure or vulnerable you will likely have to enable it in BOTH the Java JVM and the Jetty configuration.
+The Java JVM also applies exclusions at the JVM level and, as such, if you have a need to enable something that is generally accepted by the industry as being insecure or vulnerable you will likely have to enable it in *both* the Java JVM and your Jetty configuration.
____
____
From c9959fd63347e559b8f5ceed802f08cf08055b33 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Fri, 14 Jul 2017 12:16:00 -0400
Subject: [PATCH 102/147] Restoring SSL dump info
From 0bc9149ff1d0200410a7208863d5e31e24784bba Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 17 Jul 2017 11:37:03 +0200
Subject: [PATCH 103/147] Issue #1671 asymmetric trailer usage on
MetaData.Request
---
.../java/org/eclipse/jetty/server/HttpChannel.java | 13 ++++++++++++-
.../main/java/org/eclipse/jetty/server/Request.java | 13 +++++--------
2 files changed, 17 insertions(+), 9 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 5a929d57cef..251082166e8 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
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Supplier;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
@@ -75,9 +76,18 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
private final HttpChannelState _state;
private final Request _request;
private final Response _response;
+ private final Supplier _trailerSupplier = new Supplier()
+ {
+ @Override
+ public HttpFields get()
+ {
+ return _trailers;
+ }
+ };
private MetaData.Response _committedMetaData;
private RequestLog _requestLog;
private long _oldIdleTimeout;
+ private HttpFields _trailers;
/** Bytes written after interception (eg after compression) */
private long _written;
@@ -581,6 +591,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
if (idleTO>=0 && _oldIdleTimeout!=idleTO)
setIdleTimeout(idleTO);
+ request.setTrailerSupplier(_trailerSupplier);
_request.setMetaData(request);
if (LOG.isDebugEnabled())
@@ -608,7 +619,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
{
if (LOG.isDebugEnabled())
LOG.debug("{} onTrailers {}", this, trailers);
- _request.setTrailers(trailers);
+ _trailers = trailers;
}
public boolean onRequestComplete()
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 d84f7e5713e..0a7f16b7c40 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.function.Supplier;
import java.util.stream.Collectors;
import javax.servlet.AsyncContext;
@@ -199,7 +200,6 @@ public class Request implements HttpServletRequest
private long _timeStamp;
private MultiPartInputStreamParser _multiPartInputStream; //if the request is a multi-part mime
private AsyncContextState _async;
- private HttpFields _trailers;
/* ------------------------------------------------------------ */
public Request(HttpChannel channel, HttpInput input)
@@ -215,9 +215,12 @@ public class Request implements HttpServletRequest
return metadata==null?null:metadata.getFields();
}
+ /* ------------------------------------------------------------ */
public HttpFields getTrailers()
{
- return _trailers;
+ MetaData.Request metadata=_metaData;
+ Supplier trailers = metadata==null?null:metadata.getTrailerSupplier();
+ return trailers==null?null:trailers.get();
}
/* ------------------------------------------------------------ */
@@ -1859,7 +1862,6 @@ public class Request implements HttpServletRequest
_multiPartInputStream = null;
_remote=null;
_input.recycle();
- _trailers = null;
}
/* ------------------------------------------------------------ */
@@ -2228,11 +2230,6 @@ public class Request implements HttpServletRequest
_scope = scope;
}
- public void setTrailers(HttpFields trailers)
- {
- _trailers = trailers;
- }
-
/* ------------------------------------------------------------ */
@Override
public AsyncContext startAsync() throws IllegalStateException
From 91e7087fcdad776501254b7d4deda0b42bfacbb0 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 17 Jul 2017 15:24:33 +0200
Subject: [PATCH 104/147] Fix #1672 Proxy tests HttpTester.from usage
---
.../org/eclipse/jetty/http/HttpTester.java | 8 +-
.../proxy/AbstractConnectHandlerTest.java | 6 --
.../jetty/proxy/ConnectHandlerSSLTest.java | 8 +-
.../jetty/proxy/ConnectHandlerTest.java | 88 +++++++++++--------
4 files changed, 61 insertions(+), 49 deletions(-)
diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java
index 0ade4d7777a..6e5e46a4508 100644
--- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java
+++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpTester.java
@@ -121,11 +121,11 @@ public class HttpTester
public abstract static class Input
{
- final ByteBuffer _buffer;
- boolean _eof=false;
- HttpParser _parser;
+ protected final ByteBuffer _buffer;
+ protected boolean _eof=false;
+ protected HttpParser _parser;
- Input()
+ public Input()
{
this(BufferUtil.allocate(8192));
}
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java
index 29f2430d3df..2b3fb3820c8 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/AbstractConnectHandlerTest.java
@@ -66,12 +66,6 @@ public abstract class AbstractConnectHandlerTest
proxy.stop();
}
- protected HttpTester.Response readResponse(InputStream inputStream) throws IOException
- {
- HttpTester.Input input = HttpTester.from(inputStream);
- return HttpTester.parseResponse(input);
- }
-
protected Socket newSocket() throws IOException
{
Socket socket = new Socket("localhost", proxyConnector.getLocalPort());
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerSSLTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerSSLTest.java
index 084d47a8768..db0d0b04aab 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerSSLTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerSSLTest.java
@@ -81,7 +81,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(socket.getInputStream());
+ HttpTester.Response response = HttpTester.parseResponse(HttpTester.from(socket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
// Upgrade the socket to SSL
@@ -96,7 +96,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(sslSocket.getInputStream());
+ response = HttpTester.parseResponse(HttpTester.from(sslSocket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -119,7 +119,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(socket.getInputStream());
+ HttpTester.Response response = HttpTester.parseResponse(HttpTester.from(socket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
// Upgrade the socket to SSL
@@ -138,7 +138,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(sslSocket.getInputStream());
+ response = HttpTester.parseResponse(HttpTester.from(sslSocket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("POST /echo?param=" + i + "\r\nHELLO", response.getContent());
}
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java
index ca040509897..04e7450c53c 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ConnectHandlerTest.java
@@ -79,7 +79,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(socket.getInputStream());
+ HttpTester.Response response = HttpTester.parseResponse(HttpTester.from(socket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
}
}
@@ -100,7 +100,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(socket.getInputStream());
+ HttpTester.Response response = HttpTester.parseResponse(HttpTester.from(socket.getInputStream()));
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
}
}
@@ -122,7 +122,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -132,7 +133,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -159,7 +160,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 403 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.FORBIDDEN_403, response.getStatus());
// Socket should be closed
@@ -180,7 +182,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -190,7 +193,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -217,7 +220,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 403 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.FORBIDDEN_403, response.getStatus());
// Socket should be closed
@@ -238,7 +242,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -248,7 +253,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -294,7 +299,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 407 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407, response.getStatus());
Assert.assertTrue(response.containsKey("Proxy-Authenticate".toLowerCase(Locale.ENGLISH)));
@@ -318,7 +324,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -328,7 +335,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -370,7 +377,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 500 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals("Response Code", HttpStatus.INTERNAL_SERVER_ERROR_500, response.getStatus());
}
}
@@ -392,7 +400,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -402,7 +411,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -428,11 +437,12 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
// The pipelined request must have gone up to the server as is
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -455,7 +465,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
for (int i = 0; i < 10; ++i)
@@ -467,7 +478,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -491,7 +502,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -501,7 +513,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
@@ -530,7 +542,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -562,7 +575,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -574,7 +588,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("POST /echo\r\nHELLO", response.getContent());
@@ -585,7 +599,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -617,7 +631,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
StringBuilder body = new StringBuilder();
@@ -634,7 +649,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("POST /echo\r\n" + body, response.getContent());
}
@@ -702,7 +717,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
String body = "0123456789ABCDEF";
@@ -715,12 +731,12 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.write(request.getBytes(StandardCharsets.UTF_8));
output.flush();
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("POST /echo\r\n" + body, response.getContent());
}
}
-
+
@Test
public void testCONNECTAndGETPipelinedAndOutputShutdown() throws Exception
{
@@ -742,11 +758,12 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
socket.shutdownOutput();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
// The pipelined request must have gone up to the server as is
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
@@ -769,7 +786,8 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
output.flush();
// Expect 200 OK from the CONNECT request
- HttpTester.Response response = readResponse(input);
+ HttpTester.Input in = HttpTester.from(input);
+ HttpTester.Response response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
request = "" +
@@ -781,7 +799,7 @@ public class ConnectHandlerTest extends AbstractConnectHandlerTest
socket.shutdownOutput();
// The pipelined request must have gone up to the server as is
- response = readResponse(input);
+ response = HttpTester.parseResponse(in);
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
Assert.assertEquals("GET /echo", response.getContent());
}
From a1f614fd0ee12ce145efecad34c0f05f4108f47e Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 17 Jul 2017 14:17:40 -0700
Subject: [PATCH 105/147] Removing Test/Testing related commits from
VERSION.txt
---
VERSION.txt | 88 -----------------------------------------------------
1 file changed, 88 deletions(-)
diff --git a/VERSION.txt b/VERSION.txt
index 0c4e19d0b4f..9aeaa9a38d4 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -38,7 +38,6 @@ jetty-9.4.5.v20170502 - 02 May 2017
+ 1448 StackOverflowError when using URLStreamHandlerFactory in
WebAppClassloader
+ 1475 SIOOBE in ContextHandler startup
- + 1480 Expand URIUtil.canonicalPath() testing
+ 1481 Add convenient method to add user to Realm
+ 1486 redirect to welcome file broken for sub directory
+ 1487 add decoded paths
@@ -84,7 +83,6 @@ jetty-9.4.4.v20170414 - 14 April 2017
WebAppClassloader
+ 1449 Unable to find the JVM Lib directory in WebAppContext
+ 1450 JMX does not export session statistics
- + 1452 Add tests for [want|need]ClientAuth
+ 1454 CachedContentFactory locks filesystem after first read of file
+ 1456 Error dispatch race with async write
+ 1463 SSL Renegotiate limit
@@ -98,10 +96,8 @@ jetty-9.4.4.v20170414 - 14 April 2017
jetty-9.4.3.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
- + 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ 856 Add server/port and auth configuration for mongo sessions
+ 1015 Ensure jetty-distribution excludes git / temp files
- + 1049 test-jetty-osgi test exits/crashes the surefire forked JVM
+ 1184 IllegalStateException for HEAD requests responded with 404
+ 1340 PushCacheFilter question
+ 1351 StringIndexOutOfBoundsException thrown on incomplete Accept-Language
@@ -118,10 +114,8 @@ jetty-9.4.3.v20170317 - 17 March 2017
+ 1387 Windows and paxexam failure due to "renaming bundle"
+ 1389 Update to gcloud datastore-0.9.4-beta
+ 1390 HashLoginService and "this.web-inf.url" property are incompatible
- + 1394 Default OS Locale/Encoding/Charset can cause test failures
+ 1396 Set-Cookie produced by Jetty is invalid for RFC6265 and Chrome
+ 1398 Ensure all SessionDataStores store lastsaved time
- + 1399 SlowClientTest is failing on CI
+ 1401 HttpOutput.recycle() does not clear the write listener
+ 1402 Move RFC syntax validation to jetty-http Syntax class
+ 1403 Move new CookieCompliance class to jetty-http
@@ -137,11 +131,8 @@ jetty-9.3.18.v20170406 - 06 April 2017
jetty-9.3.17.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
- + 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ 1015 Ensure jetty-distribution excludes git / temp files
+ 1047 ReadPendingException and then thread death
- + 1049 test-jetty-osgi test exits/crashes the surefire forked JVM
- + 1282 ByteArrayEndPointTest.testIdle() failure
+ 1296 Introduce HTTP parser "content complete" event
+ 1326 Jetty shutdown command got NullPointerException (http2 module added to
start)
@@ -159,17 +150,13 @@ jetty-9.3.17.v20170317 - 17 March 2017
+ 1387 Windows and paxexam failure due to "renaming bundle"
+ 1389 Update to gcloud datastore-0.9.4-beta
+ 1390 HashLoginService and "this.web-inf.url" property are incompatible
- + 1394 Default OS Locale/Encoding/Charset can cause test failures
+ 1396 Set-Cookie produced by Jetty is invalid for RFC6265 and Chrome
- + 1399 SlowClientTest is failing on CI
+ 1401 HttpOutput.recycle() does not clear the write listener
jetty-9.4.2.v20170220 - 20 February 2017
+ 612 Support HTTP Trailer
+ 1047 ReadPendingException and then thread death
- + 1150 Rationalize the session tests
+ 1226 Undefined JETTY_LOGS breaks jetty.sh
- + 1282 ByteArrayEndPointTest.testIdle() failure
+ 1284 IllegalStateException updating session inactive interval
+ 1290 http2-hpack not visible in OSGi
+ Allow application to hint that chunking should be used
@@ -182,8 +169,6 @@ jetty-9.4.2.v20170220 - 20 February 2017
+ 1313 Insufficient Bytes behavior change in jetty 9.4.x due to HTTP Trailers
support?
+ 1315 Update to gcloud datastore 0.8.3-beta
- + 1317 AsyncProxyServletLoadTest fails
- + 1318 SessionEvictionFailure test fails on Windows
+ 1326 Jetty shutdown command got NullPointerException (http2 module added to
start)
+ 1328 Response.setBufferSize(int) ISE should be more clear on reason
@@ -198,7 +183,6 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 612 Support HTTP Trailer
+ 1044 Unix socket connector blocks for 30 seconds on stopping the server
+ 1073 JDK9 support in Jetty 9.3.x
- + 1114 Add testcase for WSUF for stop/start of the Server
+ 1138 Ensure xml validation works on web descriptors
+ 1139 Support configuration of properties during --add-to-start
+ 1146 jetty.server.HttpInput deadlock
@@ -215,8 +199,6 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 1181 Review buffer underflow cases in SslConnection
+ 1184 IllegalStateException for HEAD requests responded with 404
+ 1185 Connection abruptly closed for HEAD requests
- + 1186 Where can i find SocketConnector .java and
- BlockingChannelConnector.java etc?
+ 1188 Cannot --add-to-start=logback-access due to logback-core dependancy
+ 1195 Problem using STOP.PORT and STOP.KEY with --exec
+ 1197 WebSocketClient not sending `Authorization` request header
@@ -234,7 +216,6 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 1218 ReadPendingException is thrown when using
o.e.j.websocket.api.Session.suspend
+ 1220 PushCacheFilter does not add the context path to pushed resources
- + 1221 Session AbstractCreateAndInvalidateTest needs synchronization
+ 1222 Authenticated sessions throw exception on invalidate
+ 1223 Allow session workername to be null
+ 1224 HttpSessionListener.sessionDestroyed can no longer access session
@@ -243,27 +224,8 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
with WEB-INF/lib/jetty-http.jar present
+ 1234 onBadMessage called from with handled message
- + 1239 Charset=unknown produces Exception during testing
- + 1242
- org.eclipse.jetty.client.HttpRequestAbortTest.testAbortOnCommitWithContent[1]()
- results in EofException
- + 1243
- org.eclipse.jetty.proxy.ProxyServletFailureTest.testServerException[0]()
- results in ServletException
- + 1244
- ProxyServletFailureTest.testProxyRequestStallsContentServerIdlesTimeout()
- has TimeoutException visible
- + 1248
- org.eclipse.jetty.http2.client.StreamResetTest.testServerExceptionConsumesQueuedData
- results in visible Stacktrace
- + 1252
- HttpClientStreamTest.testInputStreamContentProviderThrowingWhileReading[transport:
- HTTPS]() results in Early EOF
+ 1254 9.4.x Server resource handler welcome files forwarding not working
- + 1259 HostnameVerificationTest.simpleGetWithHostnameVerificationEnabledTest
- is broken
+ 1260 Expand system properties in start
- + 1261 Intermittent H2C test failure AsyncIOServletTest.testAsyncReadEarlyEOF
+ 1262 BufferUtil.isMappedBuffer() uses reflection on private JDK fields
+ 1265 JAXB not available in JDK 9
+ 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
@@ -275,10 +237,8 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 1272 Update ALPN versions for 8u111
+ 1274 Distinguish no tlds vs no MetaInfConfiguration tld scanning for
quickstart
- + 1275 Get rid of Mockito
+ 1276 Remove org.eclipse.jetty.websocket.server.WebSocketServerFactory from
SPI
- + 1277 http2 alpn test error
jetty-9.4.0.v20161208 - 08 December 2016
+ 1112 How config async support in jsp tag?
@@ -305,9 +265,6 @@ jetty-9.3.16.v20170120 - 20 January 2017
+ 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
with WEB-INF/lib/jetty-http.jar present
+ 1234 onBadMessage called from with handled message
- + 1259 HostnameVerificationTest.simpleGetWithHostnameVerificationEnabledTest
- is broken
- + 1261 Intermittent H2C test failure AsyncIOServletTest.testAsyncReadEarlyEOF
+ 1262 BufferUtil.isMappedBuffer() uses reflection on private JDK fields
+ 1265 JAXB not available in JDK 9
+ 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
@@ -321,7 +278,6 @@ jetty-9.3.16.v20170120 - 20 January 2017
+ 1275 Get rid of Mockito
+ 1276 Remove org.eclipse.jetty.websocket.server.WebSocketServerFactory from
SPI
- + 1277 http2 alpn test error
jetty-9.3.15.v20161220 - 20 December 2016
+ 240 Missing content for multipart request after upgrade to Jetty > 9.2.7
@@ -350,7 +306,6 @@ jetty-9.3.15.v20161220 - 20 December 2016
+ 1099 PushCacheFilter pushes POST requests
+ 1108 Please improve logging in SslContextFactory when there are no approved
cipher suites
- + 1114 Add testcase for WSUF for stop/start of the Server
+ 1118 Filter.destroy() conflicts with ContainerLifeCycle.destroy() in
WebSocketUpgradeFilter
+ 1123 Broken lifecycle for WebSocket's mappings
@@ -390,7 +345,6 @@ jetty-9.4.0.RC3 - 05 December 2016
WebSocketUpgradeFilter
+ 1123 Broken lifecycle for WebSocket's mappings
+ 1124 Allow configuration of WebSocket mappings from Spring
- + 1127 AsyncMiddleManServletTest Test failure
+ 1128 Stats Servlet hidden from classpath
+ 1130 PROXY protocol support reports incorrect remote address
+ 1134 Jetty HTTP/2 client problems
@@ -439,8 +393,6 @@ jetty-9.4.0.RC2 - 16 November 2016
IPAccessHandler did
+ 1074 Improve HttpInput for non dispatched calls
+ 1075 If read from session data cache fails, fallback to session data store
- + 1076 bad error handling in
- ServerTimeoutsTest.testBlockingReadWithMinimumDataRateBelowLimit
+ 1077 doHandle defined twice for ScopedHandler
+ 1078 DigestAuthentication should use realm from server, even if unknown in
advance
@@ -450,7 +402,6 @@ jetty-9.4.0.RC2 - 16 November 2016
charset=UTF-8"
+ 1099 PushCacheFilter pushes POST requests
+ 1103 AbstractNCSARequestLog reports too much of the Request URI
- + 480764 Suppress stacks in multipart filter tests
jetty-9.4.0.RC1 - 21 October 2016
+ 277 Proxy servlet does not handle HTTP status 100 correctly
@@ -518,7 +469,6 @@ jetty-9.4.0.RC0 - 15 September 2016
String
+ 897 Remove GzipHandler interceptor when out of scope
+ 898 GzipHandler adds multiple Vary header
- + 899 PathFinderTest fails in jetty-9.2.x
+ 902 Expect: 100-Continue does not work with HTTP/2
+ 906 Expose jetty juli log for jasper in osgi
+ 909 Path and Domain not properly matched in addCookie()
@@ -543,20 +493,16 @@ jetty-9.4.0.M1 - 15 August 2016
+ 56 Fix authn issues in LdapLoginModule
+ 592 Support no-value Host header in HttpParser
+ 620 Missing call to setPattern in RewritePatternRule constructor
- + 622 NoSqlSessionManager test for expired session does not use
- session.maxInactiveInterval
+ 623 Add --gzip suffix to 304 responses with ETAGs
+ 624 AsyncContext.onCompleted called twice
+ 627 Use only start.ini or start.d, not both
+ 628 IOException: Unable to open root Jar file
MetaInfConfiguration.getTlds(MetaInfConfiguration.java:406) with Spring boot
loader + WebAppContext + non-expanded war
- + 632 JMX tests rely on fixed port
+ 638 ConnectHandler responses should have Content-Length
+ 639 ServerContainer stores WebSocket sessions twice
+ 640 ClientContainer should store WebSocket sessions as beans
+ 641 MongoSessionIdManager uses deprecated ensureIndex
- + 643 NPE in passing websocket client test
+ 644 Modules for enabling logging
+ 647 HTTP/2 CONTINUATION frame parsing throws IllegalStateException
+ 648 Problem using InputStreamResponseListener to handle HTTP/2 responses
@@ -587,9 +533,6 @@ jetty-9.4.0.M1 - 15 August 2016
+ 689 Drop support for http2 drafts
+ 690 jetty-maven-plugin does not configure AnnotationConfiguration for
jetty:effective-web-xml goal
- + 693 QoSFilterTest failures are not capture by junit
- + 694 http2.client.StreamResetTest.testServerExceptionConsumesQueuedData stack
- not suppressed in test
+ 695 Deprecate LocalConnector.getResponses() in favor of using .getResponse()
+ 696 LocalConnector.getResponse() doesn't find close if using HTTP/1.1
w/Connection: close
@@ -628,15 +571,12 @@ jetty-9.4.0.M1 - 15 August 2016
+ 804 setting default Url Encoding broken in Jetty >= 9.3
+ 815 Simplify infinispan session module
+ 817 NPE in jndi Resource
- + 819 Allow jetty-start Output assertions in TestUseCases
+ 826 Better default for HTTP/2's max concurrent streams
+ 827 HTTPClient fails connecting to HTTPS host through an HTTP proxy
w/authentication
+ 830 Test webapp not properly copied to demo-base
+ 832 ServerWithJNDI example uses wrong webapp
- + 836 Test Failure: HttpClientTransportOverHTTP2Test.testLastStreamId()
+ 837 Update to support apache jasper 8.5.4
- + 839 Test Failure: MaxConcurrentStreamsTest.testOneConcurrentStream()
+ 841 support reset in buffering interceptors
jetty-9.4.0.M0 - 03 June 2016
@@ -650,7 +590,6 @@ jetty-9.4.0.M0 - 03 June 2016
+ 437786 SslContextFactory: Allow Password.getPassword to be overridden
+ 469 Update to Apache Jasper 8.0.33
+ 472675 No main manifest attribute, in jetty-runner regression
- + 473 SessionTest.testBasicEcho_FromClient frequently failing
+ 478918 Change javax.servlet.error,forward,include literals to
RequestDispatcher constants
+ 479179 Fixed NPE from debug
@@ -682,8 +621,6 @@ jetty-9.4.0.M0 - 03 June 2016
+ 482042 New API, Allow customization of ServletHandler path mapping
+ 482056 Compact path before using it in getRequestDispatcher()
+ 482057 MultiPartInputStream temp file permissions should be limited to user
- + 482058 MultiPartInputStream test initial part boundary incorrectly allows
- empty string
+ 482172 Report form key size count in UrlEncoded exceptions
+ 482173 Track original Query string in Rewrite RuleContainer too
+ 483059 Remove cache of authenticated users
@@ -712,11 +649,8 @@ jetty-9.4.0.M0 - 03 June 2016
+ 525 fix blockForContent spin
+ 532 Get rid of generated jetty-start/dependency-reduced-pom.xml
+ 533 Do not hide file resource exception
- + 572 Ignore failing test pending further analysis
+ 605 Guard concurrent calls to WebSocketSession.close()
+ 608 reset encoding set from content type
- + 609 ignore failing test
- + 610 Ignore failing test
jetty-9.3.14.v20161028 - 28 October 2016
+ 292 NPE in SslConnectionFactory newConnection
@@ -733,7 +667,6 @@ jetty-9.3.14.v20161028 - 28 October 2016
${jetty.base}
+ 1039 AttributeNormalizer should not track attributes that are null
+ 1046 Improve HTTP2Flusher error report
- + 480764 Add extra tests for empty multipart
jetty-9.3.13.v20161014 - 14 October 2016
+ 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
@@ -808,7 +741,6 @@ jetty-9.3.11.v20160721 - 21 July 2016
+ 230 customize Content-Type in ErrorHandler's default error page
+ 592 Support no-value Host header in HttpParser
+ 631 SLOTH protection
- + 643 NPE in passing websocket client test
+ 649 LDAPLoginModule should disallow blank username and password
+ 658 Add memcached option for gcloud-sessions in jetty-9.3
+ 660 NullPointerException in Request.getParameter: _parameters is null
@@ -833,9 +765,6 @@ jetty-9.3.11.v20160721 - 21 July 2016
+ 687 AllowSymLinkAliasChecker not normalizing relative symlinks properly
+ 690 jetty-maven-plugin does not configure AnnotationConfiguration for
jetty:effective-web-xml goal
- + 693 QoSFilterTest failures are not capture by junit
- + 694 http2.client.StreamResetTest.testServerExceptionConsumesQueuedData stack
- not suppressed in test
+ 695 Deprecate LocalConnector.getResponses() in favor of using .getResponse()
+ 696 LocalConnector.getResponse() doesn't find close if using HTTP/1.1
w/Connection: close
@@ -871,7 +800,6 @@ jetty-9.2.19.v20160908 - 08 September 2016
+ 882 Add IPv6 support to IPAddressMap in jetty-util
+ 894 When adding servless class, preserve Class instead of going through
String
- + 899 PathFinderTest fails in jetty-9.2.x
jetty-9.2.18.v20160721 - 21 July 2016
+ 425 Incorrect @ServerEndpoint Encoder/Decoder lifecycle
@@ -895,17 +823,12 @@ jetty-9.3.10.v20160621 - 21 June 2016
+ 388 Add methods to send text frames with pre-encoded strings
+ 605 Guard concurrent calls to WebSocketSession.close()
+ 608 reset encoding set from content type?
- + 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
- + 610 HttpClientRedirectTest/testRedirectWithWrongScheme test failing in CI
+ 620 Missing call to setPattern in RewritePatternRule constructor
- + 622 NoSqlSessionManager test for expired session does not use
- session.maxInactiveInterval
+ 623 Add --gzip suffix to 304 responses with ETAGs
+ 624 AsyncContext.onCompleted called twice
+ 628 IOException: Unable to open root Jar file
MetaInfConfiguration.getTlds(MetaInfConfiguration.java:406) with Spring boot
loader + WebAppContext + non-expanded war
- + 632 JMX tests rely on fixed port
+ 633 If jmx and websocket is enabled, redploying a context produces a
NullPointerException
+ 638 ConnectHandler responses should have Content-Length
@@ -947,7 +870,6 @@ jetty-9.3.9.v20160517 - 17 May 2016
+ 558 HTTP/2 server hangs when thread pool is low on threads
+ 560 Jetty Client Proxy Authentication does not work with HTTP Proxy
tunneling
- + 561 Fixed test timer
+ 567 NPE in ErrorPageErrorHandler debug
+ 570 URIUtil.encodePath does not always encode utf8 chars
+ 571 AbstractAuthentication.matchesURI() fails to match scheme
@@ -993,8 +915,6 @@ jetty-9.3.9.M1 - 11 April 2016
+ 418 Add osgi capability for endpoint configurator
+ 424 Jetty impl. of Websocket ServerEndpointConfig.Configurator lifecycle out
of spec
- + 427 Squelch intentional exceptions seen during websocket testing
- + 434 RequestTest stack traces
+ 435 adjust debug log message
+ 437 Avoid NPE on receiving empty message though MessageHandler.Partial
+ 438 File and Path Resources with control characters should be rejected
@@ -1014,7 +934,6 @@ jetty-9.3.9.M1 - 11 April 2016
+ 476 HttpClient should not send absolute-form target with non HttpProxy
jetty-9.3.8.v20160314 - 14 March 2016
- + 107 ResourceHandler range support testcase
+ 124 Don't produce text/html if the request doesn't accept it
+ 247 improving invalid buffer manipulation exception messages
+ 258 Http request to origin server over https proxy contains absolute URL
@@ -1023,8 +942,6 @@ jetty-9.3.8.v20160314 - 14 March 2016
+ 305 NPE when notifying the session listener if the channel is closed before
a session has been opened
+ 316 Add *.chm mimetype mapping
- + 343 ensure release deployment of test-jetty-webapp:war and
- test-proxy-webapp:war
+ 346 HttpParser RFC2616 Compliance mode
+ 353 Jetty Client doesn't forward authentication headers with redirects when
using proxy
@@ -1043,7 +960,6 @@ jetty-9.3.8.v20160314 - 14 March 2016
+ 386 Explicit Authorization header is dropped when handling 407s
+ 397 Multipart EOF handling
+ 402 Don't use Thread.isAlive() in ShutdownMonitor
- + 405 adding testcase for problematic HttpURI parsing of path params
+ 406 GzipHandler: allow to override the Vary response header
+ 407 JSR356 Server WebSocket Sessions no longer being tracked
+ 408 Http client does not work on https with proxy
@@ -1138,7 +1054,6 @@ jetty-9.3.7.RC0 - 05 January 2016
+ 482243 Fixed GzipHandler for Include
+ 482270 Expose upgrade request locales
+ 482272 Fixed relative symlink checking
- + 482506 HTTP/2 load test with h2load fails
+ 482670 HttpURI wrongly parser URI paths starting with /@
+ 482855 Content-Length omitted for POST requests with empty body
+ 482959 Local stream count never decrements when closing a stream causing
@@ -1459,8 +1374,6 @@ jetty-9.3.0.v20150612 - 12 June 2015
+ 452503 Start.jar --add-to-start=jstl results in GraphException: Unable to
expand property in name: jsp-impl/${jsp-impl}-jstl
+ 453487 Recycle HttpChannelOverHTTP2
- + 453627 Fixed FileSystem test for nanosecond filesystems
- + 453636 Improved spin detection on test
+ 453829 Added HeaderRegexRule
+ 453834 CDI Support for WebSocket
+ 454152 Remove mux remnants from WebSocketClient
@@ -1471,7 +1384,6 @@ jetty-9.3.0.v20150612 - 12 June 2015
+ 456956 Reduce ThreadLocal.remove() weak reference garbage
+ 457130 HTTPS request with IP host and HTTP proxy throws
IllegalArgumentException.
- + 457309 Add test to ensure GET and HEAD response headers same for gzip
+ 457508 Add flag to scan exploded jars in jetty-jspc-maven-plugin
+ 457788 Powered By in o.e.j.util.Jetty conditional on sendServerVersion
+ 458478 JarFileResource improve performance of exist method
From 56bf71aec2e222819a68528eb7e566c64f6f8537 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Tue, 18 Jul 2017 09:44:58 +0200
Subject: [PATCH 106/147] Issue #1675
---
.../org/eclipse/jetty/server/session/AbstractSessionCache.java | 3 ++-
.../main/java/org/eclipse/jetty/server/session/Session.java | 2 +-
2 files changed, 3 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 afa00c255a6..4f72e7e8f8e 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
@@ -762,7 +762,8 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
_sessionDataStore.delete(oldId); //delete the session data with the old id
_sessionDataStore.store(newId, session.getSessionData()); //save the session data with the new id
}
- LOG.info("Session id {} swapped for new id {}", oldId, newId);
+ if (LOG.isDebugEnabled())
+ LOG.debug ("Session id {} swapped for new id {}", oldId, newId);
return session;
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java
index 29a3548b6bc..859736992a6 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java
@@ -905,7 +905,7 @@ public class Session implements SessionHandler.SessionIf
}
default:
{
- LOG.info("Session {} already being invalidated", _sessionData.getId());
+ if (LOG.isDebugEnabled()) LOG.debug("Session {} already being invalidated", _sessionData.getId());
}
}
}
From 0fac9c390aeb567cd10dd10342fb2c673cd828e4 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Wed, 19 Jul 2017 21:50:37 +1000
Subject: [PATCH 107/147] simplify code, add more details in junit failure
#1623
Signed-off-by: olivier lamy
---
.../jetty_run_mojo_it/TestHelloServlet.java | 4 +-
.../jetty-simple-webapp/pom.xml | 5 ++
.../jetty_run_mojo_it/TestHelloServlet.java | 4 +-
.../src/it/jetty-run-mojo-it/pom.xml | 6 +++
.../jetty/maven/plugin/JettyRunMojo.java | 53 +++----------------
.../plugin/MavenWebInfConfiguration.java | 4 +-
6 files changed, 23 insertions(+), 53 deletions(-)
diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 31a195c1407..286dcccae2c 100644
--- a/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-forked-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -40,13 +40,13 @@ public class TestHelloServlet
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse hello annotation servlet:" + response );
Assert.assertEquals( "hello beer", response.trim() );
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse ping fragment servlet:" + response );
Assert.assertEquals( "pong beer", response.trim() );
}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
index 7fb521911d7..a7e8ccdba9b 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
@@ -21,6 +21,11 @@
jetty-simple-base
+
+ org.slf4j
+ slf4j-simple
+
+
org.eclipse.jettyjetty-servlet
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
index 5d700a60525..6fc5cb06e25 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/test/java/org/eclipse/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
@@ -41,13 +41,13 @@ public class TestHelloServlet
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse hello annotation servlet:" + response );
Assert.assertEquals( "hello beer", response.trim() );
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
- System.out.println( "httpResponse:" + response );
+ System.out.println( "httpResponse ping fragment servlet:" + response );
Assert.assertEquals( "pong beer", response.trim() );
}
diff --git a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
index 213a79af16b..313904bfff4 100644
--- a/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
+++ b/jetty-maven-plugin/src/it/jetty-run-mojo-it/pom.xml
@@ -46,6 +46,12 @@
1.7.21
+
+ org.slf4j
+ slf4j-simple
+ 1.7.21
+
+
commons-iocommons-io
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index 94102e9db95..a5f0e546ceb 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -283,24 +283,13 @@ public class JettyRunMojo extends AbstractJettyMojo
if (useTestScope && (testClassesDirectory != null))
webApp.setTestClasses (testClassesDirectory);
- List dependencyProjects = getDependencyProjects();
- webApp.getClassPathFiles().addAll( dependencyProjects );
- List dependencyResources = //
- dependencyProjects.stream() //
- .map( file -> Resource.newResource( file ) ) //
- .collect( Collectors.toList() );
- webApp.getMetaData().getContainerResources().addAll( dependencyResources );
- webApp.setWebInfLib (getDependencyFiles());
-// webApp.getWebInfLib().addAll( dependencyResources //
-// .stream() //
-// .map( resource -> toFile(resource) ) //
-// .collect( Collectors.toList() ) );
- webApp.getDependentProjects().addAll( dependencyResources );
+ webApp.setWebInfLib(getDependencyFiles());
+
//get copy of a list of war artifacts
Set matchedWarArtifacts = new HashSet();
//process any overlays and the war type artifacts
- List overlays = new ArrayList();
+ List overlays = new ArrayList<>();
for (OverlayConfig config:warPluginInfo.getMavenWarOverlayConfigs())
{
//overlays can be individually skipped
@@ -596,8 +585,10 @@ public class JettyRunMojo extends AbstractJettyMojo
{
continue;
}
- if (getProjectReferences( artifact, project )!=null)
+ MavenProject mavenProject = getProjectReferences( artifact, project );
+ if (mavenProject != null)
{
+ dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
continue;
}
@@ -614,38 +605,6 @@ public class JettyRunMojo extends AbstractJettyMojo
return dependencyFiles;
}
- private List getDependencyProjects()
- {
- List dependencyFiles = new ArrayList<>();
- for ( Iterator iter = projectArtifacts.iterator(); iter.hasNext(); )
- {
- Artifact artifact = iter.next();
-
- // Include runtime and compile time libraries, and possibly test libs too
- if(artifact.getType().equals("war"))
- {
- continue;
- }
-
- if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
- continue; //never add dependencies of scope=provided to the webapp's classpath (see also param)
-
- if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
- continue; //only add dependencies of scope=test if explicitly required
-
- MavenProject mavenProject = getProjectReferences( artifact, project );
- if (mavenProject != null)
- {
- dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
- getLog().debug( "Adding project reference " + mavenProject.getBuild().getOutputDirectory()
- + " for WEB-INF/classes " );
- }
- }
-
- return dependencyFiles;
- }
-
-
protected MavenProject getProjectReferences( Artifact artifact, MavenProject project )
{
if ( project.getProjectReferences() == null || project.getProjectReferences().isEmpty() )
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
index 440238d22b4..47ce80168eb 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
@@ -93,8 +93,8 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
public void preConfigure(WebAppContext context) throws Exception
{
super.preConfigure(context);
- ((JettyWebAppContext)context).getDependentProjects()
- .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
+// ((JettyWebAppContext)context).getDependentProjects()
+// .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
}
From ce4a8df311fef29c26bfe8bfea41ad18bdf30619 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Wed, 19 Jul 2017 14:51:41 -0700
Subject: [PATCH 108/147] Fixing module [name] warning
---
jetty-jndi/src/main/jndi-config/modules/mail.mod | 2 +-
jetty-plus/src/main/plus-config/modules/transactions.mod | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/jetty-jndi/src/main/jndi-config/modules/mail.mod b/jetty-jndi/src/main/jndi-config/modules/mail.mod
index 1dd711dfc7a..69e8470f9c9 100644
--- a/jetty-jndi/src/main/jndi-config/modules/mail.mod
+++ b/jetty-jndi/src/main/jndi-config/modules/mail.mod
@@ -1,7 +1,7 @@
[description]
Adds the javax.mail implementation to the classpath.
-[name]
+[provides]
mail
[lib]
diff --git a/jetty-plus/src/main/plus-config/modules/transactions.mod b/jetty-plus/src/main/plus-config/modules/transactions.mod
index 025f2cf2dec..9b692f2f755 100644
--- a/jetty-plus/src/main/plus-config/modules/transactions.mod
+++ b/jetty-plus/src/main/plus-config/modules/transactions.mod
@@ -1,7 +1,7 @@
[description]
Puts javax.transaction api on the classpath
-[name]
+[provides]
transactions
[lib]
From 86b4870d140759d4959cdafa63f96fcbc6967e23 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Wed, 19 Jul 2017 15:29:31 -0700
Subject: [PATCH 109/147] Fixed #1679 - making DeploymentManager usable in JMX
without error
---
.../jetty/deploy/DeploymentManager.java | 32 +++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index acccfe5c0aa..a2357f14596 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.stream.Collectors;
import org.eclipse.jetty.deploy.bindings.StandardDeployer;
import org.eclipse.jetty.deploy.bindings.StandardStarter;
@@ -311,7 +312,7 @@ public class DeploymentManager extends ContainerLifeCycle
*/
public Collection getApps(Node node)
{
- List ret = new ArrayList();
+ List ret = new ArrayList<>();
for (AppEntry entry : _apps)
{
if (entry.lifecyleNode == node)
@@ -592,13 +593,40 @@ public class DeploymentManager extends ContainerLifeCycle
{
return _lifecycle.getNodes();
}
+
+ @SuppressWarnings("unused")
+ @ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO")
+ public Collection getNodeNames()
+ {
+ return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList());
+ }
- @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
public Collection getApps(@Name("nodeName") String nodeName)
{
return getApps(_lifecycle.getNodeByName(nodeName));
}
+ @SuppressWarnings("unused")
+ @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
+ public Collection getAppNames(@Name("nodeName") String nodeName)
+ {
+ Node node = _lifecycle.getNodeByName(nodeName);
+ if(node == null)
+ {
+ throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
+ }
+
+ List ret = new ArrayList<>();
+ for (AppEntry entry : _apps)
+ {
+ if (entry.lifecyleNode == node)
+ {
+ ret.add(String.format("contextPath=%s,originId=%s,appProvider=%s", entry.app.getContextPath(), entry.app.getOriginId(), entry.app.getAppProvider().getClass().getName()));
+ }
+ }
+ return ret;
+ }
+
public void scope(XmlConfiguration xmlc, Resource webapp)
throws IOException
{
From 2c60f593251c10328ed5f5f5f3834ebbafef1941 Mon Sep 17 00:00:00 2001
From: olivier lamy
Date: Thu, 20 Jul 2017 14:10:42 +1000
Subject: [PATCH 110/147] some cleanup per Jan review
Signed-off-by: olivier lamy
---
.../jetty/maven/plugin/JettyRunMojo.java | 5 +-
.../maven/plugin/JettyWebAppContext.java | 7 ++-
.../plugin/MavenWebInfConfiguration.java | 48 +++++++------------
3 files changed, 24 insertions(+), 36 deletions(-)
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
index a5f0e546ceb..3db13bf6f90 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunMojo.java
@@ -32,6 +32,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
@@ -588,7 +589,9 @@ public class JettyRunMojo extends AbstractJettyMojo
MavenProject mavenProject = getProjectReferences( artifact, project );
if (mavenProject != null)
{
- dependencyFiles.add( Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile() );
+ File projectPath = Paths.get(mavenProject.getBuild().getOutputDirectory()).toFile();
+ getLog().debug( "Adding project directory " + projectPath.toString() );
+ dependencyFiles.add( projectPath );
continue;
}
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index 3ec20ce8081..fbd9a36e4ec 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -104,7 +104,6 @@ public class JettyWebAppContext extends WebAppContext
private Resource _quickStartWebXml;
private String _originAttribute;
private boolean _generateOrigin;
- private List dependentProjects = new ArrayList<>();
/**
* Set the "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" with a pattern for matching jars on
@@ -320,9 +319,9 @@ public class JettyWebAppContext extends WebAppContext
return _webInfJars;
}
- public List getDependentProjects()
+ public List getWebInfClasses()
{
- return dependentProjects;
+ return _webInfClasses;
}
/* ------------------------------------------------------------ */
@@ -336,7 +335,7 @@ public class JettyWebAppContext extends WebAppContext
{
return _isGenerateQuickStart;
}
-
+
/* ------------------------------------------------------------ */
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
index 47ce80168eb..e875c19c0d7 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java
@@ -84,23 +84,6 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
context.setServerClasses( newServerClasses );
}
-
-
-
- /**
- * @see org.eclipse.jetty.webapp.WebInfConfiguration#preConfigure(org.eclipse.jetty.webapp.WebAppContext)
- */
- public void preConfigure(WebAppContext context) throws Exception
- {
- super.preConfigure(context);
-// ((JettyWebAppContext)context).getDependentProjects()
-// .stream().forEach( resource -> context.getMetaData().addWebInfJar( resource ) );
-
- }
-
-
-
-
/**
* @see org.eclipse.jetty.webapp.AbstractConfiguration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
*/
@@ -197,24 +180,26 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
protected List findJars (WebAppContext context)
throws Exception
{
- List list = new ArrayList();
+ List list = new ArrayList<>();
JettyWebAppContext jwac = (JettyWebAppContext)context;
- if (jwac.getClassPathFiles() != null)
+ List files = jwac.getWebInfLib();
+ if (files != null)
{
- for (File f: jwac.getClassPathFiles())
- {
- if (f.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar"))
+ files.forEach( file -> {
+ if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")
+ || file.isDirectory())
{
try
{
- list.add(Resource.newResource(f.toURI()));
+ LOG.debug( " add resource to resources to examine {}", file );
+ list.add(Resource.newResource(file.toURI()));
}
catch (Exception e)
{
LOG.warn("Bad url ", e);
}
}
- }
+ } );
}
List superList = super.findJars(context);
@@ -234,25 +219,26 @@ public class MavenWebInfConfiguration extends WebInfConfiguration
@Override
protected List findClassDirs(WebAppContext context) throws Exception
{
- List list = new ArrayList();
+ List list = new ArrayList<>();
JettyWebAppContext jwac = (JettyWebAppContext)context;
- if (jwac.getClassPathFiles() != null)
+ List files = jwac.getWebInfClasses();
+ if (files != null)
{
- for (File f: jwac.getClassPathFiles())
- {
- if (f.exists() && f.isDirectory())
+ files.forEach( file -> {
+ if (file.exists() && file.isDirectory())
{
try
{
- list.add(Resource.newResource(f.toURI()));
+ list.add(Resource.newResource(file.toURI()));
}
catch (Exception e)
{
LOG.warn("Bad url ", e);
}
}
- }
+ } );
+
}
List classesDirs = super.findClassDirs(context);
From ccf89b81adfa541bd2c454f5da70a1b937af7186 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Thu, 20 Jul 2017 13:24:46 +0200
Subject: [PATCH 111/147] Issue #1623
Ensure restarts recreate classpath.
---
.../org/eclipse/jetty/maven/plugin/JettyWebAppContext.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
index fbd9a36e4ec..e8240e764fa 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java
@@ -98,7 +98,7 @@ public class JettyWebAppContext extends WebAppContext
private final List _webInfClasses = new ArrayList<>();
private final List _webInfJars = new ArrayList<>();
private final Map _webInfJarMap = new HashMap();
- private List _classpathFiles = new ArrayList<>(); //webInfClasses+testClasses+webInfJars
+ private List _classpathFiles; //webInfClasses+testClasses+webInfJars
private String _jettyEnvXml;
private List _overlays;
private Resource _quickStartWebXml;
@@ -413,6 +413,7 @@ public class JettyWebAppContext extends WebAppContext
_webInfClasses.add(_classes);
// Set up the classpath
+ _classpathFiles = new ArrayList<>();
_classpathFiles.addAll(_webInfClasses);
_classpathFiles.addAll(_webInfJars);
From 9546db266bf5ed84aba384d3ec25aa8d6814c2c2 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Thu, 20 Jul 2017 16:11:19 +0200
Subject: [PATCH 112/147] Issue #1681
(cherry picked from commit 0d99bde0c1e740493b6dfab772b3c4933c1e7d75)
---
.../ReloadedSessionMissingClassTest.java | 3 ---
.../sessions/CachingSessionDataStoreTest.java | 3 ---
...tractClusteredInvalidationSessionTest.java | 2 --
...bstractClusteredSessionScavengingTest.java | 4 ---
...AbstractModifyMaxInactiveIntervalTest.java | 27 -------------------
...ractNonClusteredSessionScavengingTest.java | 6 -----
.../AbstractProxySerializationTest.java | 3 ---
.../session/AbstractSessionExpiryTest.java | 15 +----------
...ctSessionInvalidateCreateScavengeTest.java | 3 ---
.../jetty/server/session/CreationTest.java | 3 ---
.../server/session/DirtyAttributeTest.java | 7 +----
.../jetty/server/session/IdleSessionTest.java | 7 -----
.../server/session/ImmortalSessionTest.java | 3 ---
.../session/ReentrantRequestSessionTest.java | 2 --
.../server/session/RemoveSessionTest.java | 5 +---
.../SameContextForwardedSessionTest.java | 3 ---
.../server/session/SameNodeLoadTest.java | 4 ---
.../server/session/SaveOptimizeTest.java | 17 ------------
.../session/SessionEvictionFailureTest.java | 6 +----
.../server/session/SessionListenerTest.java | 4 ---
.../server/session/SessionRenewTest.java | 1 -
21 files changed, 4 insertions(+), 124 deletions(-)
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 af2bedf084b..a820209cda0 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
@@ -114,8 +114,6 @@ public class ReloadedSessionMissingClassTest
assertTrue(sessionCookie != null);
String sessionId = (String)webApp.getServletContext().getAttribute("foo");
assertNotNull(sessionId);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//Stop the webapp
webApp.stop();
@@ -126,7 +124,6 @@ public class ReloadedSessionMissingClassTest
webApp.start();
Request request = client.newRequest("http://localhost:" + port1 + contextPath + "/bar?action=get");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java
index 4223b905220..488710af8a7 100644
--- a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java
+++ b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java
@@ -83,8 +83,6 @@ public class CachingSessionDataStoreTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String id = TestServer.extractSessionId(sessionCookie);
//check that the memcache contains the session, and the session data store contains the session
@@ -102,7 +100,6 @@ public class CachingSessionDataStoreTest
//
((MockDataStore)persistentStore).zeroLoadCount();
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=update");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertEquals(0, ((MockDataStore)persistentStore).getLoadCount());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
index ccd39817ee0..697c2b431aa 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java
@@ -104,13 +104,11 @@ public abstract class AbstractClusteredInvalidationSessionTest extends AbstractT
// Invalidate on node1
Request request1 = client.newRequest(urls[0] + "?action=invalidate");
- request1.header("Cookie", sessionCookie);
response1 = request1.send();
assertEquals(HttpServletResponse.SC_OK, response1.getStatus());
// Be sure on node2 we don't see the session anymore
request2 = client.newRequest(urls[1] + "?action=test");
- request2.header("Cookie", sessionCookie);
response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
index 1e624e5d5f3..d9b8709e8bd 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java
@@ -117,8 +117,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
SessionHandler m1 = context1.getSessionHandler();
assertEquals(1, m1.getSessionsCreated());
@@ -212,7 +210,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes
// Check that node1 does not have any local session cached
request = client.newRequest(urls[0] + "?action=check");
- request.header("Cookie", sessionCookie);
response1 = request.send();
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
@@ -224,7 +221,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes
// Check that node2 does not have any local session cached
request = client.newRequest(urls[1] + "?action=check");
- request.header("Cookie", sessionCookie);
response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java
index f09a507901f..f05d1d9c7a5 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java
@@ -81,18 +81,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to reduce the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -140,18 +136,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to increase the maxinactive interval, first waiting until the old expiration should have passed
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -199,18 +191,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to reduce the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -258,18 +246,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to reduce the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -314,18 +298,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to change the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+2);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -372,13 +352,10 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request that will sleep long enough for the session expiry time to have passed
//before trying to access the session and ensure it is still there
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=sleep&val="+sleep);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -426,12 +403,9 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//do another request to change the maxinactive interval
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -441,7 +415,6 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
//do another request using the cookie to ensure the session is still there
request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive);
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
index c4695b8aec9..c96237b6faa 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java
@@ -96,8 +96,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Let's wait for the scavenger to run
pause(maxInactivePeriod + scavengePeriod);
@@ -107,7 +105,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
// The session should not be there anymore, but we present an old cookie
// The server should create a new session.
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-create");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
@@ -154,8 +151,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Let's wait for the scavenger to run
pause(2*scavengePeriod);
@@ -164,7 +159,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract
// Test that the session is still there
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-test");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
index 431b17b3805..f40132a25c6 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java
@@ -108,8 +108,6 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//stop the context to be sure the sesssion will be passivated
context.stop();
@@ -119,7 +117,6 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase
// Make another request using the session id from before
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=test");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
index fa2c153b73f..523867b63fb 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java
@@ -141,8 +141,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String sessionId = TestServer.extractSessionId(sessionCookie);
@@ -197,8 +195,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//now stop the server
server1.stop();
@@ -211,7 +207,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
//make another request, the session should not have expired
Request request = client.newRequest(url + "?action=notexpired");
- request.getHeaders().add("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
@@ -268,8 +263,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String sessionId = TestServer.extractSessionId(sessionCookie);
@@ -292,7 +285,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
//make another request, the session should have expired
Request request = client.newRequest(url + "?action=test");
- request.getHeaders().add("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
@@ -343,15 +335,11 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
ContentResponse response = client.GET(url + "?action=init");
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
- assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
+ assertTrue(sessionCookie != null);
//make another request to change the session timeout to a larger value
int newInactivePeriod = 100;
Request request = client.newRequest(url + "?action=change&val="+newInactivePeriod);
- request.getHeaders().add("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -364,7 +352,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase
pause(inactivePeriod);
request = client.newRequest(url + "?action=check");
- request.getHeaders().add("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie2 = response.getHeaders().get("Set-Cookie");
diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
index 88edd817e55..e348ab0a1b6 100644
--- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java
@@ -123,12 +123,9 @@ public abstract class AbstractSessionInvalidateCreateScavengeTest extends Abstra
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Make a request which will invalidate the existing session and create a new one
Request request2 = client.newRequest(url + "?action=test");
- request2.header("Cookie", sessionCookie);
ContentResponse response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java
index 2273b14ab09..c10733a1042 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java
@@ -107,8 +107,6 @@ public class CreationTest
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//session should now be evicted from the cache
String id = TestServer.extractSessionId(sessionCookie);
@@ -118,7 +116,6 @@ public class CreationTest
//make another request for the same session
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping + "?action=test");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
index 7fd488d078b..6790ca15749 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java
@@ -112,12 +112,9 @@ public class DirtyAttributeTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
+
//do another request to change the session attribute
Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=setA");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
@@ -128,7 +125,6 @@ public class DirtyAttributeTest
//do another request using the cookie to try changing the session attribute to the same value again
request= client.newRequest("http://localhost:" + port + "/mod/test?action=setA");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
A_VALUE.assertPassivatesEquals(2);
@@ -138,7 +134,6 @@ public class DirtyAttributeTest
//do another request using the cookie and change to a different value
request= client.newRequest("http://localhost:" + port + "/mod/test?action=setB");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
B_VALUE.assertPassivatesEquals(1);
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
index ec110cac542..b3f52588fc2 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java
@@ -105,8 +105,6 @@ public class IdleSessionTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//and wait until the session should be idled out
pause(evictionSec*3);
@@ -118,7 +116,6 @@ public class IdleSessionTest
//make another request to de-idle the session
Request request = client.newRequest(url + "?action=test");
- request.getHeaders().add("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
@@ -140,7 +137,6 @@ public class IdleSessionTest
//make a request
request = client.newRequest(url + "?action=testfail");
- request.getHeaders().add("Cookie", sessionCookie);
response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
@@ -150,8 +146,6 @@ public class IdleSessionTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
id = TestServer.extractSessionId(sessionCookie);
//and wait until the session should be idled out
@@ -170,7 +164,6 @@ public class IdleSessionTest
//make another request to de-idle the session
request = client.newRequest(url + "?action=testfail");
- request.getHeaders().add("Cookie", sessionCookie);
response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
index 374de0aa68c..fcf9dd7cf3e 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java
@@ -96,8 +96,6 @@ public class ImmortalSessionTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String resp = response.getContentAsString();
assertEquals(resp.trim(),String.valueOf(value));
@@ -107,7 +105,6 @@ public class ImmortalSessionTest
// Be sure the session is still there
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=get");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
index 43707c6b7c3..fa5011e33be 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java
@@ -72,8 +72,6 @@ public class ReentrantRequestSessionTest
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//make a request that will make a simultaneous request for the same session
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=reenter&port=" + port + "&path=" + contextPath + servletMapping);
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 12e37961973..c22c2b4a79b 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
@@ -80,8 +80,7 @@ public class RemoveSessionTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
+
//ensure sessionCreated listener is called
assertTrue (testListener.isCreated());
assertEquals(1, m.getSessionsCreated());
@@ -90,7 +89,6 @@ public class RemoveSessionTest
//now delete the session
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=delete");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
//ensure sessionDestroyed listener is called
@@ -104,7 +102,6 @@ public class RemoveSessionTest
// The session is not there anymore, even if we present an old cookie
request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=check");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertEquals(0, ((DefaultSessionCache)m.getSessionCache()).getSessionsCurrent());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java
index 8040f11e7e3..f63c7a35b75 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java
@@ -93,8 +93,6 @@ public class SameContextForwardedSessionTest
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//wait until all of the request handling has finished
_synchronizer.await();
@@ -105,7 +103,6 @@ public class SameContextForwardedSessionTest
//Make a fresh request
Request request = client.newRequest("http://localhost:" + serverPort + "/context/four");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java
index bbbea552ee2..3720f75ea76 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java
@@ -83,8 +83,6 @@ public class SameNodeLoadTest
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
//simulate 10 clients making 100 requests each
ExecutorService executor = Executors.newCachedThreadPool();
@@ -110,7 +108,6 @@ public class SameNodeLoadTest
// Perform one request to get the result
Request request = client.newRequest( url + "?action=result" );
- request.header("Cookie", sessionCookie);
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
String response = response2.getContentAsString();
@@ -174,7 +171,6 @@ public class SameNodeLoadTest
Thread.currentThread().sleep(pauseMsec);
}
Request request = client.newRequest(url + "?action=increment");
- request.header("Cookie", sessionCookie);
ContentResponse response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java
index 3c9e6549fa1..3b1f47dac95 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java
@@ -159,11 +159,8 @@ public class SaveOptimizeTest
//make a few requests to access the session but not change it
for (int i=0;i<5; i++)
{
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
// Perform a request to contextB with the same session cookie
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session is unchanged
@@ -237,9 +234,7 @@ public class SaveOptimizeTest
// Perform a request to do nothing with the same session cookie
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session not saved
@@ -249,7 +244,6 @@ public class SaveOptimizeTest
// Perform a request to mutate the session
request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=mutate");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session is saved
@@ -316,11 +310,9 @@ public class SaveOptimizeTest
long lastSaved = data.getLastSaved();
//make another request, session should not change
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
// Perform a request to do nothing with the same session cookie
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session not saved
@@ -333,7 +325,6 @@ public class SaveOptimizeTest
// Perform a request to do nothing with the same session cookie
request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session is saved
@@ -401,12 +392,8 @@ public class SaveOptimizeTest
long lastSaved = data.getLastSaved();
assertTrue(lastSaved > 0); //check session created was saved
-
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
// Perform a request to do nothing with the same session cookie, check the session object is different
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop&check=diff");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session not saved
@@ -476,12 +463,8 @@ public class SaveOptimizeTest
long lastSaved = data.getLastSaved();
assertTrue(lastSaved > 0); //check session created was saved
-
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
// Perform a request to change maxInactive on session
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=max&value=60");
- request.header("Cookie", sessionCookie);
response = request.send();
//check session is saved, even though the save optimisation interval has not passed
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
index d21b9493af2..fba4a6cdc36 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
@@ -237,9 +237,7 @@ public class SessionEvictionFailureTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
String sessionCookie = response.getHeaders().get("Set-Cookie");
assertNotNull(sessionCookie);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
+
//Wait for the eviction period to expire - save on evict should fail but session
//should remain in the cache
pause(evictionPeriod+(int)(evictionPeriod*0.5));
@@ -248,7 +246,6 @@ public class SessionEvictionFailureTest
// Make another request to see if the session is still in the cache and can be used,
//allow it to be saved this time
Request request = client.newRequest(url + "?action=test");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertNull(response.getHeaders().get("Set-Cookie")); //check that the cookie wasn't reset
@@ -259,7 +256,6 @@ public class SessionEvictionFailureTest
request = client.newRequest(url + "?action=test");
- request.header("Cookie", sessionCookie);
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
}
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java
index 9baaea02fdc..b94f8d5cd51 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java
@@ -109,15 +109,11 @@ public class SessionListenerTest
assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);
- // Mangle the cookie, replacing Path with $Path, etc.
- sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
-
assertTrue (servlet.listener.bound);
// Make a request which will invalidate the existing session
Request request2 = client.newRequest(url + "?action=test");
- request2.header("Cookie", sessionCookie);
ContentResponse response2 = request2.send();
assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
index ed2909130f2..3b663083aee 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java
@@ -135,7 +135,6 @@ public class SessionRenewTest
//make a request to change the sessionid
Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=renew");
- request.header("Cookie", sessionCookie);
ContentResponse renewResponse = request.send();
assertEquals(HttpServletResponse.SC_OK,renewResponse.getStatus());
From c417a18cc8f7e6d444408600c87492e90811af6a Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Thu, 20 Jul 2017 11:22:54 -0700
Subject: [PATCH 113/147] Fixed #1679 - moving JMX specific behavior to
jmx.DeploymentManagerMBean
---
.../jetty/deploy/DeploymentManager.java | 34 +--------
.../deploy/jmx/DeploymentManagerMBean.java | 74 ++++++++++++-------
2 files changed, 52 insertions(+), 56 deletions(-)
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index a2357f14596..6f631f44848 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.stream.Collectors;
import org.eclipse.jetty.deploy.bindings.StandardDeployer;
import org.eclipse.jetty.deploy.bindings.StandardStarter;
@@ -289,13 +288,13 @@ public class DeploymentManager extends ContainerLifeCycle
public Collection getAppEntries()
{
- return _apps;
+ return Collections.unmodifiableCollection(_apps);
}
@ManagedAttribute("Deployed Apps")
public Collection getApps()
{
- List ret = new ArrayList();
+ List ret = new ArrayList< >();
for (AppEntry entry : _apps)
{
ret.add(entry.app);
@@ -594,38 +593,11 @@ public class DeploymentManager extends ContainerLifeCycle
return _lifecycle.getNodes();
}
- @SuppressWarnings("unused")
- @ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO")
- public Collection getNodeNames()
- {
- return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList());
- }
-
- public Collection getApps(@Name("nodeName") String nodeName)
+ public Collection getApps(String nodeName)
{
return getApps(_lifecycle.getNodeByName(nodeName));
}
- @SuppressWarnings("unused")
- @ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
- public Collection getAppNames(@Name("nodeName") String nodeName)
- {
- Node node = _lifecycle.getNodeByName(nodeName);
- if(node == null)
- {
- throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
- }
-
- List ret = new ArrayList<>();
- for (AppEntry entry : _apps)
- {
- if (entry.lifecyleNode == node)
- {
- ret.add(String.format("contextPath=%s,originId=%s,appProvider=%s", entry.app.getContextPath(), entry.app.getOriginId(), entry.app.getAppProvider().getClass().getName()));
- }
- }
- return ret;
- }
public void scope(XmlConfiguration xmlc, Resource webapp)
throws IOException
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
index 74753452ce5..6abc620b4f9 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.deploy.jmx;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.stream.Collectors;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
@@ -28,54 +29,77 @@ import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.jmx.ObjectMBean;
import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.annotation.ManagedObject;
+import org.eclipse.jetty.util.annotation.ManagedOperation;
+import org.eclipse.jetty.util.annotation.Name;
+@SuppressWarnings("unused")
+@ManagedObject("MBean Wrapper for DeploymentManager")
public class DeploymentManagerMBean extends ObjectMBean
{
private final DeploymentManager _manager;
-
+
public DeploymentManagerMBean(Object managedObject)
{
super(managedObject);
- _manager=(DeploymentManager)managedObject;
- }
-
- public Collection getNodes()
- {
- List nodes = new ArrayList();
- for (Node node: _manager.getNodes())
- nodes.add(node.getName());
- return nodes;
+ _manager = (DeploymentManager) managedObject;
}
+ @ManagedOperation(value = "list apps being tracked", impact = "INFO")
public Collection getApps()
{
- List apps=new ArrayList();
- for (App app: _manager.getApps())
- apps.add(app.getOriginId());
- return apps;
+ List ret = new ArrayList<>();
+ for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
+ {
+ ret.add(toRef(entry.getApp()));
+ }
+ return ret;
}
-
- public Collection getApps(String nodeName)
+
+ @ManagedOperation(value = "list nodes that are tracked by DeploymentManager", impact = "INFO")
+ public Collection getNodes()
{
- List apps=new ArrayList();
- for (App app: _manager.getApps(nodeName))
- apps.add(app.getOriginId());
- return apps;
+ return _manager.getNodes().stream().map(Node::getName).collect(Collectors.toList());
}
-
+
+ @ManagedOperation(value = "list apps that are located at specified App LifeCycle nodes", impact = "ACTION")
+ public Collection getApps(@Name("nodeName") String nodeName)
+ {
+ Node node = _manager.getLifeCycle().getNodeByName(nodeName);
+ if (node == null)
+ {
+ throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
+ }
+
+ List ret = new ArrayList<>();
+ for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
+ {
+ if (entry.getLifecyleNode() == node)
+ {
+ ret.add(toRef(entry.getApp()));
+ }
+ }
+ return ret;
+ }
+
+ private String toRef(App app)
+ {
+ return String.format("originId=%s,contextPath=%s,appProvider=%s", app.getContextPath(), app.getOriginId(), app.getAppProvider().getClass().getName());
+ }
+
public Collection getContexts() throws Exception
{
- List apps=new ArrayList();
- for (App app: _manager.getApps())
+ List apps = new ArrayList();
+ for (App app : _manager.getApps())
apps.add(app.getContextHandler());
return apps;
}
-
+
public Collection getAppProviders()
{
return _manager.getAppProviders();
}
-
+
public void requestAppGoal(String appId, String nodeName)
{
_manager.requestAppGoal(appId, nodeName);
From 489f68c7080638c54eeab2a396a81025a46cb87a Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Mon, 24 Jul 2017 10:08:10 +0200
Subject: [PATCH 114/147] Fixes #1685 - Update ALPN support for Java 8u141.
---
.../config/modules/protonego-impl/alpn-1.8.0_141.mod | 8 ++++++++
.../modules/protonego-impl/alpn-1.8.0_141.mod | 8 ++++++++
pom.xml | 12 ++++++++++++
3 files changed, 28 insertions(+)
create mode 100644 jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod
create mode 100644 jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod
new file mode 100644
index 00000000000..fdd3868701d
--- /dev/null
+++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod
@@ -0,0 +1,8 @@
+[name]
+protonego-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar
diff --git a/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod
new file mode 100644
index 00000000000..fdd3868701d
--- /dev/null
+++ b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod
@@ -0,0 +1,8 @@
+[name]
+protonego-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar
diff --git a/pom.xml b/pom.xml
index 4bf8f67c652..f060d64f768 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1552,6 +1552,18 @@
8.1.11.v20170118
+
+ 8u141
+
+
+ java.version
+ 1.8.0_141
+
+
+
+ 8.1.11.v20170118
+
+
From 8cfd971f926abae48ae0e5793db4905b78de7ff1 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Thu, 6 Jul 2017 13:09:03 +0200
Subject: [PATCH 115/147] JavaDoc clarification.
---
.../src/main/java/org/eclipse/jetty/client/ConnectionPool.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
index effaa0da802..ed344731e1c 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/ConnectionPool.java
@@ -58,7 +58,7 @@ public interface ConnectionPool extends Closeable
*
* @param connection the connection to release
* @return true if the connection has been released, false if the connection
- * was not obtained from the this ConnectionPool
+ * should be closed
*/
boolean release(Connection connection);
From a2d63141e95782c0c37db85f8f627b6b7ab717d3 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Mon, 24 Jul 2017 10:50:48 +0200
Subject: [PATCH 116/147] Fixed location of ALPN files for JDK 8u141.
---
.../modules/{protonego-impl => alpn-impl}/alpn-1.8.0_141.mod | 0
.../modules/{protonego-impl => alpn-impl}/alpn-1.8.0_141.mod | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename jetty-alpn/jetty-alpn-server/src/main/config/modules/{protonego-impl => alpn-impl}/alpn-1.8.0_141.mod (100%)
rename jetty-start/src/test/resources/dist-home/modules/{protonego-impl => alpn-impl}/alpn-1.8.0_141.mod (100%)
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_141.mod
similarity index 100%
rename from jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_141.mod
rename to jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_141.mod
diff --git a/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod b/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_141.mod
similarity index 100%
rename from jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_141.mod
rename to jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_141.mod
From 95bf957b4fee54a453666916dc2b16c5cf63ca79 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Mon, 24 Jul 2017 11:22:49 +0200
Subject: [PATCH 117/147] Updated ALPN documentation for JDK 8u141.
---
.../src/main/asciidoc/administration/alpn/alpn.adoc | 1 +
1 file changed, 1 insertion(+)
diff --git a/jetty-documentation/src/main/asciidoc/administration/alpn/alpn.adoc b/jetty-documentation/src/main/asciidoc/administration/alpn/alpn.adoc
index 0a65b98403b..f09765a8d8a 100644
--- a/jetty-documentation/src/main/asciidoc/administration/alpn/alpn.adoc
+++ b/jetty-documentation/src/main/asciidoc/administration/alpn/alpn.adoc
@@ -245,6 +245,7 @@ The ALPN implementation, relying on modifications of OpenJDK classes, updates ev
|1.8.0u112 |8.1.10.v20161026
|1.8.0u121 |8.1.11.v20170118
|1.8.0u131 |8.1.11.v20170118
+|1.8.0u141 |8.1.11.v20170118
|=============================
[[alpn-build]]
From f04f486f94a6f46bafc15c0bf696b6bba40dae6d Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Mon, 24 Jul 2017 11:35:41 +0200
Subject: [PATCH 118/147] Fixes #1687 - Missing callback notification when
channel not found.
---
.../eclipse/jetty/http2/server/HTTP2ServerConnection.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
index a1f9ed0d394..1d674882c4a 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.http2.server;
-import java.io.Closeable;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -177,6 +177,10 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
if (task != null)
offerTask(task, false);
}
+ else
+ {
+ callback.failed(new IOException("channel_not_found"));
+ }
}
public void onTrailers(IStream stream, HeadersFrame frame)
From be1eb26670f1195f0d34fa7766838ac850770205 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 25 Jul 2017 12:58:54 +0200
Subject: [PATCH 119/147] Fixes #1671 - Asymmetric usage of trailers in
MetaData.Request.
Reviewed with code cleanups.
---
.../java/org/eclipse/jetty/server/HttpChannel.java | 14 ++++----------
.../java/org/eclipse/jetty/server/Request.java | 2 +-
2 files changed, 5 insertions(+), 11 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 251082166e8..ba184350f28 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
@@ -61,7 +61,6 @@ import org.eclipse.jetty.util.thread.Scheduler;
* The HttpChannel signals the switch from passive mode to active mode by returning true to one of the
* HttpParser.RequestHandler callbacks. The completion of the active phase is signalled by a call to
* HttpTransport.completed().
- *
*/
public class HttpChannel implements Runnable, HttpOutput.Interceptor
{
@@ -76,18 +75,11 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
private final HttpChannelState _state;
private final Request _request;
private final Response _response;
- private final Supplier _trailerSupplier = new Supplier()
- {
- @Override
- public HttpFields get()
- {
- return _trailers;
- }
- };
+ private HttpFields _trailers;
+ private final Supplier _trailerSupplier = () -> _trailers;
private MetaData.Response _committedMetaData;
private RequestLog _requestLog;
private long _oldIdleTimeout;
- private HttpFields _trailers;
/** Bytes written after interception (eg after compression) */
private long _written;
@@ -262,6 +254,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
_committedMetaData=null;
_requestLog=_connector==null?null:_connector.getServer().getRequestLog();
_written=0;
+ _trailers=null;
+ _oldIdleTimeout=0;
}
public void asyncReadFillInterested()
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 0a7f16b7c40..c5d533be171 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
@@ -219,7 +219,7 @@ public class Request implements HttpServletRequest
public HttpFields getTrailers()
{
MetaData.Request metadata=_metaData;
- Supplier trailers = metadata==null?null:metadata.getTrailerSupplier();
+ Supplier trailers = metadata==null?null:metadata.getTrailerSupplier();
return trailers==null?null:trailers.get();
}
From 98eb354c46bf26277fe3f125f195c6da055e8595 Mon Sep 17 00:00:00 2001
From: Olivier Lamy
Date: Wed, 26 Jul 2017 16:45:01 +1000
Subject: [PATCH 120/147] use invoker plugin 3.0.1 released version (#1683)
Signed-off-by: olivier lamy
---
jetty-maven-plugin/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml
index b17414749bd..9449376b43d 100644
--- a/jetty-maven-plugin/pom.xml
+++ b/jetty-maven-plugin/pom.xml
@@ -196,7 +196,7 @@
org.apache.maven.pluginsmaven-invoker-plugin
- 3.0.1-SNAPSHOT
+ 3.0.1integration-test
From e81e17d348da3b1a4a4494b7ef32c6ffa977f8e6 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Wed, 26 Jul 2017 09:38:49 +0200
Subject: [PATCH 121/147] Issue #1692
---
.../eclipse/jetty/annotations/AnnotationParser.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
index 4f076cd6284..2ec5516e77d 100644
--- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
+++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java
@@ -978,11 +978,18 @@ public class AnnotationParser
return false;
//skip anything that is not a class file
- if (!name.toLowerCase(Locale.ENGLISH).endsWith(".class"))
+ String lc = name.toLowerCase(Locale.ENGLISH);
+ if (!lc.endsWith(".class"))
{
if (LOG.isDebugEnabled()) LOG.debug("Not a class: {}",name);
return false;
}
+
+ if (lc.equals("module-info.class"))
+ {
+ if (LOG.isDebugEnabled()) LOG.debug("Skipping module-info.class");
+ return false;
+ }
//skip any classfiles that are not a valid java identifier
int c0 = 0;
@@ -990,7 +997,7 @@ public class AnnotationParser
c0 = (ldir > -1 ? ldir+1 : c0);
if (!Character.isJavaIdentifierStart(name.charAt(c0)))
{
- if (LOG.isDebugEnabled()) LOG.debug("Not a java identifier: {}"+name);
+ if (LOG.isDebugEnabled()) LOG.debug("Not a java identifier: {}",name);
return false;
}
From 3eeeb8ec7e0ec76a2bd6d332e2eb167aeed97567 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Wed, 26 Jul 2017 11:08:19 +0200
Subject: [PATCH 122/147] Improved error reporting.
---
.../main/java/org/eclipse/jetty/server/HttpInput.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
index b2efc08d1fe..ad47630d187 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
@@ -793,9 +793,16 @@ public class HttpInput extends ServletInputStream implements Runnable
synchronized (_inputQ)
{
if (_state instanceof ErrorState)
- LOG.warn(x);
+ {
+ Throwable failure = new Throwable(_state.getError());
+ failure.addSuppressed(new Throwable(x));
+ LOG.warn(failure);
+ }
else
- _state = new ErrorState(x);
+ {
+ // Retain the current stack trace by wrapping the failure.
+ _state = new ErrorState(new Throwable(x));
+ }
if (_listener == null)
_inputQ.notify();
From dfd9e43b2df9556557d48662c980c3be78170e46 Mon Sep 17 00:00:00 2001
From: WalkerWatch
Date: Wed, 26 Jul 2017 11:58:49 -0400
Subject: [PATCH 123/147] Updated web-default.xml documentation. Resolves
#1462.
---
.../reference/jetty-xml/webdefault-xml.adoc | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/jetty-documentation/src/main/asciidoc/reference/jetty-xml/webdefault-xml.adoc b/jetty-documentation/src/main/asciidoc/reference/jetty-xml/webdefault-xml.adoc
index d20f29c6f08..5c99225b09c 100644
--- a/jetty-documentation/src/main/asciidoc/reference/jetty-xml/webdefault-xml.adoc
+++ b/jetty-documentation/src/main/asciidoc/reference/jetty-xml/webdefault-xml.adoc
@@ -18,8 +18,8 @@
=== webdefault.xml
The `webdefault.xml` file saves web applications from having to define a lot of house-keeping and container-specific elements in their own `web.xml` files.
-For example, you can use it to set up mime-type mappings and JSP servlet-mappings.
-Jetty applies `webdefault.xml` to a web application _before_ the application's own `WEB-INF/web.xml`, which means that it cannot override values inside the webapp's `web.xml`.
+For example, you can use it to set up MIME-type mappings and JSP servlet-mappings.
+Jetty applies `webdefault.xml` to a web application _before_ the application's own `WEB-INF/web.xml`, which means that it *cannot* override values inside the webapp's `web.xml`.
It uses the xref:jetty-xml-config[] syntax.
Generally, it is convenient for all webapps in a Jetty instance to share the same `webdefault.xml` file.
However, it is certainly possible to provide differentiated ` webdefault.xml` files for individual web applications.
@@ -36,6 +36,22 @@ ____
To ensure your `webdefault.xml` files are validated, you will need to set the `validateXml` attribute to true as described link:#jetty-xml-dtd[here.]
____
+The `webdefault.xml` link:{GITBROWSURL}/jetty-webapp/src/main/config/etc/webdefault.xml[included with the Jetty Distribution] contains several configuration options, such as init params and servlet mappings, and is separated into sections for easy navigation.
+Some of the more common options include, but are not limited to:
+
+dirAllowed::
+If true, directory listings are returned if no welcome file is found.
+Otherwise 403 Forbidden displays.
+precompressed::
+If set to a comma separated list of file extensions, these indicate compressed formats that are known to map to a MIME-type that may be listed in a requests Accept-Encoding header.
+If set to a boolean True, then a default set of compressed formats will be used, otherwise no pre-compressed formats.
+maxCacheSize::
+Maximum total size of the cache or 0 for no cache.
+maxCachedFileSize::
+Maximum size of a file to cache.
+maxCachedFiles::
+Maximum number of files to cache.
+
[[creating-custom-webdefault-xml-one-webapp]]
===== Creating a Custom webdefault.xml for One WebApp
From 7c4f7b13f7b634e098fab2c341253e41d4eeaf0f Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Fri, 28 Jul 2017 11:55:57 +0200
Subject: [PATCH 124/147] Issue #1682
---
.../boot/utils/internal/DefaultFileLocatorHelper.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java
index a2ad48bded7..7230ca1d5b7 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java
@@ -100,7 +100,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
// some osgi frameworks do use the file protocol directly in some
// situations. Do use the FileResource to transform the URL into a
// File: URL#toURI is broken
- return new PathResource(url).getFile().getParentFile().getParentFile();
+ return new PathResource(url).getFile().getParentFile().getParentFile().getCanonicalFile();
}
else if (url.getProtocol().equals("bundleentry"))
{
@@ -131,7 +131,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
FILE_FIELD.setAccessible(true);
}
File f = (File) FILE_FIELD.get(bundleEntry);
- return f.getParentFile().getParentFile();
+ return f.getParentFile().getParentFile().getCanonicalFile();
}
else if (match(bundleEntry.getClass().getName(), ZIP_BUNDLE_ENTRY_CLASSES))
{
@@ -173,7 +173,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
if (location.startsWith("file:/"))
{
URI uri = new URI(URIUtil.encodePath(location));
- return new File(uri);
+ return new File(uri).getCanonicalFile();
}
else if (location.startsWith("file:"))
{
@@ -199,7 +199,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
else if (location.startsWith("reference:file:"))
{
location = URLDecoder.decode(location.substring("reference:".length()), "UTF-8");
- File file = new File(location.substring("file:".length()));
+ File file = new File(location.substring("file:".length())).getCanonicalFile();
return file;
}
}
From d12cde9cfd3e29899379063345c000a3be311d61 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 1 Aug 2017 11:24:56 +1000
Subject: [PATCH 125/147] Fix commit 2e13208758b6cf0036f3e18406e61683b41a0e14
use suppressed exceptions to hold local stacktrace rather than wrapping exception, which hides the exception type.
---
.../main/java/org/eclipse/jetty/server/HttpInput.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
index ad47630d187..3654f23cd93 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
@@ -794,14 +794,15 @@ public class HttpInput extends ServletInputStream implements Runnable
{
if (_state instanceof ErrorState)
{
- Throwable failure = new Throwable(_state.getError());
- failure.addSuppressed(new Throwable(x));
+ IOException failure = new IOException(x);
LOG.warn(failure);
+ _state.getError().addSuppressed(failure);
}
else
{
- // Retain the current stack trace by wrapping the failure.
- _state = new ErrorState(new Throwable(x));
+ // Add a suppressed throwable to capture this stack trace
+ x.addSuppressed(new IOException("HttpInput failed"));
+ _state = new ErrorState(x);
}
if (_listener == null)
From a8ca4d23c6f55657514f194ce3a450b658400a93 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 1 Aug 2017 11:05:30 +0200
Subject: [PATCH 126/147] Fixes #1702 - Update ALPN for JDK 8u144.
---
.../config/modules/protonego-impl/alpn-1.8.0_144.mod | 8 ++++++++
.../modules/protonego-impl/alpn-1.8.0_144.mod | 8 ++++++++
pom.xml | 12 ++++++++++++
3 files changed, 28 insertions(+)
create mode 100644 jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_144.mod
create mode 100644 jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_144.mod
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_144.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_144.mod
new file mode 100644
index 00000000000..fdd3868701d
--- /dev/null
+++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/protonego-impl/alpn-1.8.0_144.mod
@@ -0,0 +1,8 @@
+[name]
+protonego-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar
diff --git a/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_144.mod b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_144.mod
new file mode 100644
index 00000000000..fdd3868701d
--- /dev/null
+++ b/jetty-start/src/test/resources/dist-home/modules/protonego-impl/alpn-1.8.0_144.mod
@@ -0,0 +1,8 @@
+[name]
+protonego-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar
diff --git a/pom.xml b/pom.xml
index f060d64f768..6e5f18030ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1564,6 +1564,18 @@
8.1.11.v20170118
+
+ 8u144
+
+
+ java.version
+ 1.8.0_144
+
+
+
+ 8.1.11.v20170118
+
+
From a705f9a2ca4c7b36ee7dfa631282ee561bc6d019 Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 1 Aug 2017 14:21:49 +0200
Subject: [PATCH 127/147] Fixes #1703 - Improve HttpInput failure logging.
---
.../main/java/org/eclipse/jetty/server/HttpInput.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
index 3654f23cd93..dcaae2593f5 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
@@ -794,14 +794,17 @@ public class HttpInput extends ServletInputStream implements Runnable
{
if (_state instanceof ErrorState)
{
- IOException failure = new IOException(x);
+ // Log both the original and current failure
+ // without modifying the original failure.
+ Throwable failure = new Throwable(((ErrorState)_state).getError());
+ failure.addSuppressed(x);
LOG.warn(failure);
- _state.getError().addSuppressed(failure);
}
else
{
- // Add a suppressed throwable to capture this stack trace
- x.addSuppressed(new IOException("HttpInput failed"));
+ // Add a suppressed throwable to capture this stack
+ // trace without wrapping/hiding the original failure.
+ x.addSuppressed(new Throwable("HttpInput failure"));
_state = new ErrorState(x);
}
From 1a07ddd787b1ad1500e835f47958bd31b4d6d62e Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Wed, 2 Aug 2017 11:52:31 +1000
Subject: [PATCH 128/147] Issue #215 Conscrypt SSL provider
Added module to install Conscrupt SSL provider
---
.../src/main/resources/modules/conscrypt.mod | 27 +++++++++++++++++++
.../resources/modules/conscrypt/conscrypt.xml | 7 +++++
.../src/main/config/etc/jetty-ssl-context.xml | 1 +
jetty-server/src/main/config/modules/ssl.mod | 3 +++
4 files changed, 38 insertions(+)
create mode 100644 jetty-home/src/main/resources/modules/conscrypt.mod
create mode 100644 jetty-home/src/main/resources/modules/conscrypt/conscrypt.xml
diff --git a/jetty-home/src/main/resources/modules/conscrypt.mod b/jetty-home/src/main/resources/modules/conscrypt.mod
new file mode 100644
index 00000000000..f34ccaf452c
--- /dev/null
+++ b/jetty-home/src/main/resources/modules/conscrypt.mod
@@ -0,0 +1,27 @@
+[description]
+Installs the Conscrypt JSSE provider
+
+[tags]
+3rdparty
+
+[depend]
+ssl
+
+[files]
+maven://org.conscrypt/conscrypt-openjdk-uber/${conscrypt.version}|lib/conscrypt/conscrypt-uber-${conscrypt.version}.jar
+basehome:modules/conscrypt/conscrypt.xml|etc/conscrypt.xml
+
+[lib]
+lib/conscrypt/**.jar
+
+[xml]
+etc/conscrypt.xml
+
+[license]
+Conscrypt is distributed under the Apache Licence 2.0
+https://github.com/google/conscrypt/blob/master/LICENSE
+
+[ini]
+conscrypt.version?=1.0.0.RC8
+jetty.sslContext.provider?=AndroidOpenSSL
+
diff --git a/jetty-home/src/main/resources/modules/conscrypt/conscrypt.xml b/jetty-home/src/main/resources/modules/conscrypt/conscrypt.xml
new file mode 100644
index 00000000000..f3c69bd0953
--- /dev/null
+++ b/jetty-home/src/main/resources/modules/conscrypt/conscrypt.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/jetty-server/src/main/config/etc/jetty-ssl-context.xml b/jetty-server/src/main/config/etc/jetty-ssl-context.xml
index 87414a3c58c..e5ed517dee2 100644
--- a/jetty-server/src/main/config/etc/jetty-ssl-context.xml
+++ b/jetty-server/src/main/config/etc/jetty-ssl-context.xml
@@ -11,6 +11,7 @@
-->
+ /
diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod
index cac38448246..109aaba460b 100644
--- a/jetty-server/src/main/config/modules/ssl.mod
+++ b/jetty-server/src/main/config/modules/ssl.mod
@@ -63,6 +63,9 @@ basehome:modules/ssl/keystore|etc/keystore
## Note that OBF passwords are not secure, just protected from casual observation
## See http://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html
+## SSL JSSE Provider
+# jetty.sslContext.provider=
+
## Keystore file path (relative to $jetty.base)
# jetty.sslContext.keyStorePath=etc/keystore
From 1fd3e4ad1b8903bc9033dd24c86a0207996097b1 Mon Sep 17 00:00:00 2001
From: Josh Elser
Date: Tue, 1 Aug 2017 22:18:04 -0400
Subject: [PATCH 129/147] =?UTF-8?q?Sends=20the=20WWW-Authenticate=20header?=
=?UTF-8?q?=20if=20a=20non-Negotiate=20authorization=20he=E2=80=A6=20(#170?=
=?UTF-8?q?0)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Sends the WWW-Authenticate header if a non-Negotiate authorization header was given
Fixes #1698
Signed-off-by: Josh Elser
* Dumb compilation error
Signed-off-by: Josh Elser
* Adds a test to show the challenge is sent.
Signed-off-by: Josh Elser
* Refactor the conditionals per Greg's suggestion
Signed-off-by: Josh Elser
* Add the expected license header
Signed-off-by: Josh Elser
---
.../authentication/SpnegoAuthenticator.java | 43 ++++---
.../SpnegoAuthenticatorTest.java | 113 ++++++++++++++++++
2 files changed, 134 insertions(+), 22 deletions(-)
create mode 100644 jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
index 93e0592eed2..aad1da02967 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
@@ -72,27 +72,8 @@ public class SpnegoAuthenticator extends LoginAuthenticator
return new DeferredAuthentication(this);
}
- // check to see if we have authorization headers required to continue
- if ( header == null )
- {
- try
- {
- if (DeferredAuthentication.isDeferred(res))
- {
- return Authentication.UNAUTHENTICATED;
- }
-
- LOG.debug("SpengoAuthenticator: sending challenge");
- res.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), HttpHeader.NEGOTIATE.asString());
- res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
- return Authentication.SEND_CONTINUE;
- }
- catch (IOException ioe)
- {
- throw new ServerAuthException(ioe);
- }
- }
- else if (header != null && header.startsWith(HttpHeader.NEGOTIATE.asString()))
+ // The client has responded to the challenge we sent previously
+ if (header != null && header.startsWith(HttpHeader.NEGOTIATE.asString().toLowerCase()))
{
String spnegoToken = header.substring(10);
@@ -104,7 +85,25 @@ public class SpnegoAuthenticator extends LoginAuthenticator
}
}
- return Authentication.UNAUTHENTICATED;
+ // A challenge should be sent if any of the following cases are true:
+ // 1. There was no Authorization header provided
+ // 2. There was an Authorization header for a type other than Negotiate
+ try
+ {
+ if (DeferredAuthentication.isDeferred(res))
+ {
+ return Authentication.UNAUTHENTICATED;
+ }
+
+ LOG.debug("SpengoAuthenticator: sending challenge");
+ res.setHeader(HttpHeader.WWW_AUTHENTICATE.asString(), HttpHeader.NEGOTIATE.asString());
+ res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+ return Authentication.SEND_CONTINUE;
+ }
+ catch (IOException ioe)
+ {
+ throw new ServerAuthException(ioe);
+ }
}
@Override
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
new file mode 100644
index 00000000000..8e968b8cb60
--- /dev/null
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
@@ -0,0 +1,113 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// 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.security.authentication;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpURI;
+import org.eclipse.jetty.http.MetaData;
+import org.eclipse.jetty.server.Authentication;
+import org.eclipse.jetty.server.HttpChannel;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpOutput;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.Server;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test class for {@link SpnegoAuthenticator}.
+ */
+public class SpnegoAuthenticatorTest {
+ private SpnegoAuthenticator _authenticator;
+
+ @Before
+ public void setup() throws Exception
+ {
+ _authenticator = new SpnegoAuthenticator();
+ }
+
+ @Test
+ public void testChallengeSentWithNoAuthorization() throws Exception
+ {
+ HttpChannel channel = new HttpChannel(null, new HttpConfiguration(), null, null)
+ {
+ @Override
+ public Server getServer()
+ {
+ return null;
+ }
+ };
+ Request req = new Request(channel, null);
+ HttpOutput out = new HttpOutput(channel)
+ {
+ @Override
+ public void close()
+ {
+ return;
+ }
+ };
+ Response res = new Response(channel, out);
+ MetaData.Request metadata = new MetaData.Request(new HttpFields());
+ metadata.setURI(new HttpURI("http://localhost"));
+ req.setMetaData(metadata);
+
+ assertEquals(Authentication.SEND_CONTINUE, _authenticator.validateRequest(req, res, true));
+ assertEquals(HttpHeader.NEGOTIATE.asString(), res.getHeader(HttpHeader.WWW_AUTHENTICATE.asString()));
+ assertEquals(HttpServletResponse.SC_UNAUTHORIZED, res.getStatus());
+ }
+
+ @Test
+ public void testChallengeSentWithUnhandledAuthorization() throws Exception
+ {
+ HttpChannel channel = new HttpChannel(null, new HttpConfiguration(), null, null)
+ {
+ @Override
+ public Server getServer()
+ {
+ return null;
+ }
+ };
+ Request req = new Request(channel, null);
+ HttpOutput out = new HttpOutput(channel)
+ {
+ @Override
+ public void close()
+ {
+ return;
+ }
+ };
+ Response res = new Response(channel, out);
+ HttpFields http_fields = new HttpFields();
+ // Create a bogus Authorization header. We don't care about the actual credentials.
+ http_fields.add(HttpHeader.AUTHORIZATION, "Basic asdf");
+ MetaData.Request metadata = new MetaData.Request(http_fields);
+ metadata.setURI(new HttpURI("http://localhost"));
+ req.setMetaData(metadata);
+
+ assertEquals(Authentication.SEND_CONTINUE, _authenticator.validateRequest(req, res, true));
+ assertEquals(HttpHeader.NEGOTIATE.asString(), res.getHeader(HttpHeader.WWW_AUTHENTICATE.asString()));
+ assertEquals(HttpServletResponse.SC_UNAUTHORIZED, res.getStatus());
+ }
+}
From 19e539a87d70c3f6bf3ddf81531d7f0c449d48e4 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Wed, 2 Aug 2017 15:37:39 +1000
Subject: [PATCH 130/147] Issue #1623
Remove projects.classes.dirs, using only lib.jars property.
---
.../jetty/maven/plugin/JettyRunForkedMojo.java | 13 -------------
.../org/eclipse/jetty/maven/plugin/Starter.java | 10 ----------
2 files changed, 23 deletions(-)
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
index 4de7f20ae53..f39394bfcfd 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyRunForkedMojo.java
@@ -517,19 +517,6 @@ public class JettyRunForkedMojo extends JettyRunMojo
props.put("testClasses.dir", webApp.getTestClasses().getAbsolutePath());
}
- if ( !webApp.getClassPathFiles().isEmpty() )
- {
- StringBuilder stringBuilder = new StringBuilder();
- for ( File dependency : webApp.getClassPathFiles() )
- {
- if (dependency.isDirectory())
- {
- stringBuilder.append( dependency.getCanonicalPath() ).append( '|' );
- }
- }
- props.put( "projects.classes.dir", stringBuilder.toString() );
- }
-
//web-inf lib
List deps = webApp.getWebInfLib();
StringBuffer strbuff = new StringBuffer();
diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
index 88f542db616..4d13967ad90 100644
--- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
+++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/Starter.java
@@ -314,16 +314,6 @@ public class Starter
jars.add(new File(names[j].trim()));
webApp.setWebInfLib(jars);
}
-
- str = props.getProperty( "projects.classes.dir" );
- if (str != null && !"".equals(str.trim()))
- {
- List classesDirectories = //
- Arrays.stream(str.split( Pattern.quote("|") )) //
- .map( s -> Paths.get( s).toFile() ).collect( Collectors.toList() );
- webApp.getWebInfLib().addAll( classesDirectories );
- }
-
}
public void getConfiguration (String[] args)
From b1b569bd231e5d9c379e6970a1a1b585b0daeb8b Mon Sep 17 00:00:00 2001
From: Simone Bordet
Date: Tue, 25 Aug 2015 15:07:50 +0200
Subject: [PATCH 131/147] 475546 - ClosedChannelException when connecting to
HTTPS over HTTP proxy with CONNECT.
Not closing the connection if the request method is CONNECT.
---
.../client/http/HttpChannelOverHTTP.java | 10 +-
.../eclipse/jetty/client/HttpClientTest.java | 129 +++++++-----------
2 files changed, 54 insertions(+), 85 deletions(-)
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
index d4d14dc3f7d..3153a20ba5e 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java
@@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
public class HttpChannelOverHTTP extends HttpChannel
@@ -143,8 +142,6 @@ public class HttpChannelOverHTTP extends HttpChannel
closeReason = "failure";
else if (receiver.isShutdown())
closeReason = "server close";
- else if (sender.isShutdown())
- closeReason = "client close";
if (closeReason == null)
{
@@ -159,7 +156,7 @@ public class HttpChannelOverHTTP extends HttpChannel
}
else
{
- // HTTP 1.1 closes only if it has an explicit close.
+ // HTTP 1.1 or greater closes only if it has an explicit close.
if (responseHeaders.contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString()))
closeReason = "http/1.1";
}
@@ -173,10 +170,7 @@ public class HttpChannelOverHTTP extends HttpChannel
}
else
{
- if (response.getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101)
- connection.remove();
- else
- release();
+ release();
}
}
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
index b2c7751a537..0a993756633 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpCookie;
-import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URI;
@@ -1582,86 +1581,62 @@ public class HttpClientTest extends AbstractHttpClientServerTest
}
@Test
- public void testCopyRequest() throws Exception
+ public void testCONNECTWithHTTP10() throws Exception
{
- startClient();
-
- assertCopyRequest(client.newRequest("http://example.com/some/url")
- .method(HttpMethod.HEAD)
- .version(HttpVersion.HTTP_2)
- .content(new StringContentProvider("some string"))
- .timeout(321, TimeUnit.SECONDS)
- .idleTimeout(2221, TimeUnit.SECONDS)
- .followRedirects(true)
- .header(HttpHeader.CONTENT_TYPE, "application/json")
- .header("X-Some-Custom-Header", "some-value"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .method(HttpMethod.POST)
- .version(HttpVersion.HTTP_1_0)
- .content(new StringContentProvider("some other string"))
- .timeout(123231, TimeUnit.SECONDS)
- .idleTimeout(232342, TimeUnit.SECONDS)
- .followRedirects(false)
- .header(HttpHeader.ACCEPT, "application/json")
- .header("X-Some-Other-Custom-Header", "some-other-value"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .header(HttpHeader.ACCEPT, "application/json")
- .header(HttpHeader.ACCEPT, "application/xml")
- .header("x-same-name", "value1")
- .header("x-same-name", "value2"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .header(HttpHeader.ACCEPT, "application/json")
- .header(HttpHeader.CONTENT_TYPE, "application/json"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .header("Accept", "application/json")
- .header("Content-Type", "application/json"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .header("X-Custom-Header-1", "value1")
- .header("X-Custom-Header-2", "value2"));
-
- assertCopyRequest(client.newRequest("https://example.com")
- .header("X-Custom-Header-1", "value")
- .header("X-Custom-Header-2", "value"));
- }
-
- @Test
- public void testHostWithHTTP10() throws Exception
- {
- start(new AbstractHandler()
+ try (ServerSocket server = new ServerSocket(0))
{
- @Override
- public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ startClient();
+
+ String host = "localhost";
+ int port = server.getLocalPort();
+
+ Request request = client.newRequest(host, port)
+ .method(HttpMethod.CONNECT)
+ .version(HttpVersion.HTTP_1_0);
+ FuturePromise promise = new FuturePromise<>();
+ client.getDestination("http", host, port).newConnection(promise);
+ Connection connection = promise.get(5, TimeUnit.SECONDS);
+ FutureResponseListener listener = new FutureResponseListener(request);
+ connection.send(request, listener);
+
+ try (Socket socket = server.accept())
{
- baseRequest.setHandled(true);
- Assert.assertThat(request.getHeader("Host"), Matchers.notNullValue());
+ InputStream input = socket.getInputStream();
+ consume(input, false);
+
+ // HTTP/1.0 response, the client must not close the connection.
+ String httpResponse = "" +
+ "HTTP/1.0 200 OK\r\n" +
+ "\r\n";
+ OutputStream output = socket.getOutputStream();
+ output.write(httpResponse.getBytes(StandardCharsets.UTF_8));
+ output.flush();
+
+ ContentResponse response = listener.get(5, TimeUnit.SECONDS);
+ Assert.assertEquals(200, response.getStatus());
+
+ // Because the tunnel was successful, this connection will be
+ // upgraded to an SslConnection, so it will not be fill interested.
+ // This test doesn't upgrade, so it needs to restore the fill interest.
+ ((AbstractConnection)connection).fillInterested();
+
+ // Test that I can send another request on the same connection.
+ request = client.newRequest(host, port);
+ listener = new FutureResponseListener(request);
+ connection.send(request, listener);
+
+ consume(input, false);
+
+ httpResponse = "" +
+ "HTTP/1.1 200 OK\r\n" +
+ "Content-Length: 0\r\n" +
+ "\r\n";
+ output.write(httpResponse.getBytes(StandardCharsets.UTF_8));
+ output.flush();
+
+ listener.get(5, TimeUnit.SECONDS);
}
- });
-
- ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
- .scheme(scheme)
- .version(HttpVersion.HTTP_1_0)
- .timeout(5, TimeUnit.SECONDS)
- .send();
-
- Assert.assertEquals(200, response.getStatus());
- }
-
- private void assertCopyRequest(Request original)
- {
- Request copy = client.copyRequest((HttpRequest) original, original.getURI());
- Assert.assertEquals(original.getURI(), copy.getURI());
- Assert.assertEquals(original.getMethod(), copy.getMethod());
- Assert.assertEquals(original.getVersion(), copy.getVersion());
- Assert.assertEquals(original.getContent(), copy.getContent());
- Assert.assertEquals(original.getIdleTimeout(), copy.getIdleTimeout());
- Assert.assertEquals(original.getTimeout(), copy.getTimeout());
- Assert.assertEquals(original.isFollowRedirects(), copy.isFollowRedirects());
- Assert.assertEquals(original.getHeaders(), copy.getHeaders());
+ }
}
private void consume(InputStream input, boolean eof) throws IOException
From cfeb2a33250025d92874eb7c00b6e0903453fcd9 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Thu, 3 Aug 2017 15:57:28 +1000
Subject: [PATCH 132/147] Issue #215 Conscrypt SSL provider
upgraded to 1.0.0.RC9
---
jetty-home/src/main/resources/modules/conscrypt.mod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-home/src/main/resources/modules/conscrypt.mod b/jetty-home/src/main/resources/modules/conscrypt.mod
index f34ccaf452c..9d2158ea66e 100644
--- a/jetty-home/src/main/resources/modules/conscrypt.mod
+++ b/jetty-home/src/main/resources/modules/conscrypt.mod
@@ -22,6 +22,6 @@ Conscrypt is distributed under the Apache Licence 2.0
https://github.com/google/conscrypt/blob/master/LICENSE
[ini]
-conscrypt.version?=1.0.0.RC8
+conscrypt.version?=1.0.0.RC9
jetty.sslContext.provider?=AndroidOpenSSL
From 10bf0e5edb3c6ba01d1d09a775ea6c3ca782c182 Mon Sep 17 00:00:00 2001
From: Igal
Date: Sun, 6 Aug 2017 17:01:53 -0700
Subject: [PATCH 133/147] fixed typo (#1668)
* fixed typo
* improved text
* corrected typo in readme
---
jetty-distribution/src/main/resources/webapps/README.TXT | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/jetty-distribution/src/main/resources/webapps/README.TXT b/jetty-distribution/src/main/resources/webapps/README.TXT
index e6536844384..eaaa954f2cf 100644
--- a/jetty-distribution/src/main/resources/webapps/README.TXT
+++ b/jetty-distribution/src/main/resources/webapps/README.TXT
@@ -5,12 +5,12 @@ applications to deploy using the following conventions:
+ A directory called example/ will be deployed as a standard web
application if it contains a WEB-INF/ subdirectory, otherwise it will be
deployed as context of static content. The context path will be /example
-(eg http://localhost:8080/example/) unless the base name is root, in
-which case the context path is /. If the directory name ends with ".d"
-it is ignored (by may be used by explicit configuration).
+(eg http://localhost:8080/example/) unless the base name is "root" (not
+case sensitive), in which case the context path is /. If the directory name
+ends with ".d" it is ignored (but may still be used by explicit configuration).
+ A file called example.war will be deployed as a standard web application
-with the context path /example (eg http://localhost:8080/example/). If the
+with the context path /example (eg http://localhost:8080/example/). If the
base name is root, then the context path is /. If example.war and example/
exist, then only the WAR is deployed (which may use the directory as an
unpack location).
From 3b297a2557b1b0d37b404c7d891d418a83e26948 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 7 Aug 2017 10:07:16 +1000
Subject: [PATCH 134/147] Apply #1649
---
.../main/java/org/eclipse/jetty/http/ResourceHttpContent.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/ResourceHttpContent.java b/jetty-http/src/main/java/org/eclipse/jetty/http/ResourceHttpContent.java
index 0b3ce289276..1379a92b000 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/ResourceHttpContent.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/ResourceHttpContent.java
@@ -185,7 +185,7 @@ public class ResourceHttpContent implements HttpContent
public HttpField getContentLength()
{
long l=_resource.length();
- return l==-1?null:new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,_resource.length());
+ return l==-1?null:new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,l);
}
/* ------------------------------------------------------------ */
From 9f285d92e71cc7bf3d1109fc266594e515b232bd Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Mon, 7 Aug 2017 10:30:12 +1000
Subject: [PATCH 135/147] Issue #1637
Limit reserved threads if threadpool is of small size
---
.../util/thread/ReservedThreadExecutor.java | 21 +++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
index 95045b29386..0d62fac9954 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java
@@ -50,12 +50,29 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
/**
* @param executor The executor to use to obtain threads
- * @param capacity The number of threads to preallocate. If less than 0 then the number of available processors is used.
+ * @param capacity The number of threads to preallocate. If less than 0 then capacity
+ * is calculated based on a heuristic from the number of available processors and
+ * thread pool size.
*/
public ReservedThreadExecutor(Executor executor,int capacity)
{
_executor = executor;
- _queue = new ReservedThread[capacity>=0?capacity:Runtime.getRuntime().availableProcessors()];
+
+ if (capacity < 0)
+ {
+ if (executor instanceof ThreadPool)
+ {
+ int threads = ((ThreadPool)executor).getThreads();
+ int cpus = Runtime.getRuntime().availableProcessors();
+ capacity = Math.max(1,Math.min(cpus,threads/8));
+ }
+ else
+ {
+ capacity = Runtime.getRuntime().availableProcessors();
+ }
+ }
+
+ _queue = new ReservedThread[capacity];
}
public Executor getExecutor()
From c6d86122dbd737f2247b01653da0af938075370d Mon Sep 17 00:00:00 2001
From: Josh Elser
Date: Mon, 7 Aug 2017 21:02:44 -0400
Subject: [PATCH 136/147] =?UTF-8?q?Fix=20a=20bug=20around=20handling=20"Ne?=
=?UTF-8?q?gotiate"=20case-insensitively=20in=20SpnegoAut=E2=80=A6=20(#171?=
=?UTF-8?q?0)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Fix a bug around handling "Negotiate" case-insensitively in SpnegoAuthenticator
Closes #1709
Signed-off-by: Josh Elser
* Clean up isAuthSchemeNegotiate(String) since we don't need to use startsWith()
Signed-off-by: Josh Elser
---
.../authentication/SpnegoAuthenticator.java | 44 ++++++++++++++++++-
.../SpnegoAuthenticatorTest.java | 35 +++++++++++++++
2 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
index aad1da02967..f82e55eadd0 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java
@@ -66,6 +66,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
HttpServletResponse res = (HttpServletResponse)response;
String header = req.getHeader(HttpHeader.AUTHORIZATION.asString());
+ String authScheme = getAuthSchemeFromHeader(header);
if (!mandatory)
{
@@ -73,7 +74,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
}
// The client has responded to the challenge we sent previously
- if (header != null && header.startsWith(HttpHeader.NEGOTIATE.asString().toLowerCase()))
+ if (header != null && isAuthSchemeNegotiate(authScheme))
{
String spnegoToken = header.substring(10);
@@ -106,6 +107,47 @@ public class SpnegoAuthenticator extends LoginAuthenticator
}
}
+ /**
+ * Extracts the auth_scheme from the HTTP Authorization header, {@code Authorization: }.
+ *
+ * @param header The HTTP Authorization header or null.
+ * @return The parsed auth scheme from the header, or the empty string.
+ */
+ String getAuthSchemeFromHeader(String header)
+ {
+ // No header provided, return the empty string
+ if (header == null || header.isEmpty())
+ {
+ return "";
+ }
+ // Trim any leading whitespace
+ String trimmed_header = header.trim();
+ // Find the first space, all characters prior should be the auth_scheme
+ int index = trimmed_header.indexOf(' ');
+ if (index > 0) {
+ return trimmed_header.substring(0, index);
+ }
+ // If we don't find a space, this is likely malformed, just return the entire value
+ return trimmed_header;
+ }
+
+ /**
+ * Determines if provided auth scheme text from the Authorization header is case-insensitively
+ * equal to {@code negotiate}.
+ *
+ * @param authScheme The auth scheme component of the Authorization header
+ * @return True if the auth scheme component is case-insensitively equal to {@code negotiate}, False otherwise.
+ */
+ boolean isAuthSchemeNegotiate(String authScheme)
+ {
+ if (authScheme == null || authScheme.length() != HttpHeader.NEGOTIATE.asString().length())
+ {
+ return false;
+ }
+ // Headers should be treated case-insensitively, so we have to jump through some extra hoops.
+ return authScheme.equalsIgnoreCase(HttpHeader.NEGOTIATE.asString());
+ }
+
@Override
public boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, User validatedUser) throws ServerAuthException
{
diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
index 8e968b8cb60..d90519aa3da 100644
--- a/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
+++ b/jetty-security/src/test/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticatorTest.java
@@ -19,6 +19,8 @@
package org.eclipse.jetty.security.authentication;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import javax.servlet.http.HttpServletResponse;
@@ -110,4 +112,37 @@ public class SpnegoAuthenticatorTest {
assertEquals(HttpHeader.NEGOTIATE.asString(), res.getHeader(HttpHeader.WWW_AUTHENTICATE.asString()));
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, res.getStatus());
}
+
+ @Test
+ public void testCaseInsensitiveHeaderParsing()
+ {
+ assertFalse(_authenticator.isAuthSchemeNegotiate(null));
+ assertFalse(_authenticator.isAuthSchemeNegotiate(""));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("Basic"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("basic"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("Digest"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("LotsandLotsandLots of nonsense"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiat asdfasdf"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiated"));
+ assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiate-and-more"));
+
+ assertTrue(_authenticator.isAuthSchemeNegotiate("Negotiate"));
+ assertTrue(_authenticator.isAuthSchemeNegotiate("negotiate"));
+ assertTrue(_authenticator.isAuthSchemeNegotiate("negOtiAte"));
+ }
+
+ @Test
+ public void testExtractAuthScheme()
+ {
+ assertEquals("", _authenticator.getAuthSchemeFromHeader(null));
+ assertEquals("", _authenticator.getAuthSchemeFromHeader(""));
+ assertEquals("", _authenticator.getAuthSchemeFromHeader(" "));
+ assertEquals("Basic", _authenticator.getAuthSchemeFromHeader(" Basic asdfasdf"));
+ assertEquals("Basicasdf", _authenticator.getAuthSchemeFromHeader("Basicasdf asdfasdf"));
+ assertEquals("basic", _authenticator.getAuthSchemeFromHeader(" basic asdfasdf "));
+ assertEquals("Negotiate", _authenticator.getAuthSchemeFromHeader("Negotiate asdfasdf"));
+ assertEquals("negotiate", _authenticator.getAuthSchemeFromHeader("negotiate asdfasdf"));
+ assertEquals("negotiate", _authenticator.getAuthSchemeFromHeader(" negotiate asdfasdf"));
+ assertEquals("negotiated", _authenticator.getAuthSchemeFromHeader(" negotiated asdfasdf"));
+ }
}
From 4c2c0add76d67925792cbef6a1e6d29ed0f0646e Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 8 Aug 2017 11:10:42 +1000
Subject: [PATCH 137/147] Fixed #1713 limit selectors for small thread pool
---
.../org/eclipse/jetty/io/SelectorManager.java | 23 +++++++++++++++++--
.../eclipse/jetty/server/ServerConnector.java | 3 +--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
index 5b86b80c09c..97af8a1394e 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
@@ -37,6 +37,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
import org.eclipse.jetty.util.thread.Scheduler;
+import org.eclipse.jetty.util.thread.ThreadPool;
import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill;
/**
@@ -59,15 +60,33 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
private long _selectorIndex;
private int _reservedThreads = -2;
+ public static int defaultSchedulers(Executor executor)
+ {
+ if (executor instanceof ThreadPool)
+ {
+ int threads = ((ThreadPool)executor).getThreads();
+ int cpus = Runtime.getRuntime().availableProcessors();
+ return Math.max(1,Math.min(cpus/2,threads/16));
+ }
+
+ return Math.max(1,Runtime.getRuntime().availableProcessors()/2);
+ }
+
protected SelectorManager(Executor executor, Scheduler scheduler)
{
- this(executor, scheduler, (Runtime.getRuntime().availableProcessors() + 1) / 2);
+ this(executor, scheduler, -1);
}
+ /**
+ * @param executor The executor to use for handling selected {@link EndPoint}s
+ * @param scheduler The scheduler to use for timing events
+ * @param selectors The number of selectors to use, or -1 for a default derived
+ * from a heuristic over available CPUs and thread pool size.
+ */
protected SelectorManager(Executor executor, Scheduler scheduler, int selectors)
{
if (selectors <= 0)
- throw new IllegalArgumentException("No selectors");
+ selectors = defaultSchedulers(executor);
this.executor = executor;
this.scheduler = scheduler;
_selectors = new ManagedSelector[selectors];
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
index 1d296fb82f9..6258e171589 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java
@@ -219,8 +219,7 @@ public class ServerConnector extends AbstractNetworkConnector
@Name("factories") ConnectionFactory... factories)
{
super(server,executor,scheduler,bufferPool,acceptors,factories);
- _manager = newSelectorManager(getExecutor(), getScheduler(),
- selectors>0?selectors:Math.max(1,Math.min(4,Runtime.getRuntime().availableProcessors()/2)));
+ _manager = newSelectorManager(getExecutor(), getScheduler(),selectors);
addBean(_manager, true);
setAcceptorPriorityDelta(-2);
}
From c917d9e72b236b4f23954cafa4c0162a2812d101 Mon Sep 17 00:00:00 2001
From: Jan Bartel
Date: Tue, 8 Aug 2017 11:31:42 +1000
Subject: [PATCH 138/147] Issue #1714
---
.../server/session/SessionEvictionFailureTest.java | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
index fba4a6cdc36..e962c6a997e 100644
--- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
+++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java
@@ -23,14 +23,13 @@ package org.eclipse.jetty.server.session;
-import java.io.IOException;
-import java.util.Set;
-
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.io.IOException;
+import java.util.Set;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -215,7 +214,8 @@ public class SessionEvictionFailureTest
TestServer server = new TestServer (0, inactivePeriod, scavengePeriod, cacheFactory, storeFactory);
ServletContextHandler context = server.addContext(contextPath);
context.getSessionHandler().getSessionCache().setSaveOnInactiveEviction(true);
- MockSessionDataStore ds = new MockSessionDataStore(new boolean[] {true, false, true, false, true});
+ //test values: allow first save, fail evict save, allow save, fail evict save, allow save, allow save on shutdown
+ MockSessionDataStore ds = new MockSessionDataStore(new boolean[] {true, false, true, false, true, true});
context.getSessionHandler().getSessionCache().setSessionDataStore(ds);
TestServlet servlet = new TestServlet();
@@ -242,7 +242,6 @@ public class SessionEvictionFailureTest
//should remain in the cache
pause(evictionPeriod+(int)(evictionPeriod*0.5));
-
// Make another request to see if the session is still in the cache and can be used,
//allow it to be saved this time
Request request = client.newRequest(url + "?action=test");
@@ -250,11 +249,9 @@ public class SessionEvictionFailureTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertNull(response.getHeaders().get("Set-Cookie")); //check that the cookie wasn't reset
-
//Wait for the eviction period to expire again
pause(evictionPeriod+(int)(evictionPeriod*0.5));
-
request = client.newRequest(url + "?action=test");
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
From 76981a0a15633ad22a7d41f2ea8b8a1a5f79245d Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 8 Aug 2017 11:55:47 +1000
Subject: [PATCH 139/147] Fixed #1715 standardise XML properties and IDs
---
.../jetty/deploy/DeploymentManager.java | 20 +-------
.../webapp/JettyWebXmlConfiguration.java | 14 +++---
.../eclipse/jetty/xml/XmlConfiguration.java | 49 +++++++++++++++++++
3 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index 6f631f44848..6c69f52ac6b 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -598,27 +598,9 @@ public class DeploymentManager extends ContainerLifeCycle
return getApps(_lifecycle.getNodeByName(nodeName));
}
-
public void scope(XmlConfiguration xmlc, Resource webapp)
throws IOException
{
- xmlc.getIdMap().put("Server", getServer());
- Resource home = Resource.newResource(System.getProperty("jetty.home","."));
- xmlc.getProperties().put("jetty.home",home.toString());
- xmlc.getProperties().put("jetty.home.uri",normalizeURI(home.getURI().toString()));
-
- Resource base = Resource.newResource(System.getProperty("jetty.base",home.toString()));
- xmlc.getProperties().put("jetty.base",base.toString());
- xmlc.getProperties().put("jetty.base.uri",normalizeURI(base.getURI().toString()));
-
- xmlc.getProperties().put("jetty.webapp",webapp.toString());
- xmlc.getProperties().put("jetty.webapps",webapp.getFile().toPath().getParent().toString());
- }
-
- private String normalizeURI(String uri)
- {
- if (uri.endsWith("/"))
- return uri.substring(0,uri.length()-1);
- return uri;
+ xmlc.setJettyStandardIdsAndProperties(getServer(),webapp);
}
}
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java
index 8908797769c..774f15fed92 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java
@@ -86,11 +86,10 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
Object xml_attr=context.getAttribute(XML_CONFIGURATION);
context.removeAttribute(XML_CONFIGURATION);
- final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration
- ?(XmlConfiguration)xml_attr
- :new XmlConfiguration(jetty.getURI().toURL());
- setupXmlConfiguration(jetty_config, web_inf);
-
+ final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration?(XmlConfiguration)xml_attr:new XmlConfiguration(jetty.getURI().toURL());
+
+ setupXmlConfiguration(context, jetty_config, web_inf);
+
try
{
WebAppClassLoader.runWithServerClassAccess(()->{jetty_config.configure(context);return null;});
@@ -110,11 +109,12 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
* @param jetty_config The configuration object.
* @param web_inf the WEB-INF location
*/
- private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf) throws IOException
+ private void setupXmlConfiguration(WebAppContext context, XmlConfiguration jetty_config, Resource web_inf) throws IOException
{
+ jetty_config.setJettyStandardIdsAndProperties(context.getServer(),null);
Map props = jetty_config.getProperties();
props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURI().toString());
- props.put(PROPERTY_WEB_INF_URI, web_inf.getURI().toString());
+ props.put(PROPERTY_WEB_INF_URI, XmlConfiguration.normalizeURI(web_inf.getURI().toString()));
props.put(PROPERTY_WEB_INF, web_inf.toString());
}
}
diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
index 742007ba214..db12d70f446 100644
--- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
+++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
@@ -115,6 +115,55 @@ public class XmlConfiguration
return parser;
}
+ /**
+ * Set the standard IDs and properties expected in a jetty XML file:
+ *
+ *
RefId Server
+ *
Property jetty.home
+ *
Property jetty.home.uri
+ *
Property jetty.base
+ *
Property jetty.base.uri
+ *
Property jetty.webapps
+ *
Property jetty.webapps.uri
+ *
+ * @param server The Server object to set
+ * @param webapp The webapps Resource
+ */
+ public void setJettyStandardIdsAndProperties(Object server, Resource webapp)
+ {
+ try
+ {
+ if (server!=null)
+ getIdMap().put("Server", server);
+
+ Resource home = Resource.newResource(System.getProperty("jetty.home","."));
+ getProperties().put("jetty.home",home.toString());
+ getProperties().put("jetty.home.uri",normalizeURI(home.getURI().toString()));
+
+ Resource base = Resource.newResource(System.getProperty("jetty.base",home.toString()));
+ getProperties().put("jetty.base",base.toString());
+ getProperties().put("jetty.base.uri",normalizeURI(base.getURI().toString()));
+
+ if (webapp!=null)
+ {
+ getProperties().put("jetty.webapp",webapp.toString());
+ getProperties().put("jetty.webapps",webapp.getFile().toPath().getParent().toString());
+ getProperties().put("jetty.webapps.uri",normalizeURI(webapp.getURI().toString()));
+ }
+ }
+ catch(Exception e)
+ {
+ LOG.warn(e);
+ }
+ }
+
+ public static String normalizeURI(String uri)
+ {
+ if (uri.endsWith("/"))
+ return uri.substring(0,uri.length()-1);
+ return uri;
+ }
+
private final Map _idMap = new HashMap<>();
private final Map _propertyMap = new HashMap<>();
private final URL _url;
From 94322f7290ef79f5d718424c4eec7db988a4cdbc Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Tue, 8 Aug 2017 16:43:47 +1000
Subject: [PATCH 140/147] simplify reserved thread configuration
---
.../org/eclipse/jetty/io/SelectorManager.java | 21 ++++++++++++-------
jetty-server/src/main/config/modules/http.mod | 4 ++--
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
index 97af8a1394e..afaf27dc0b7 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java
@@ -58,7 +58,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
private final ManagedSelector[] _selectors;
private long _connectTimeout = DEFAULT_CONNECT_TIMEOUT;
private long _selectorIndex;
- private int _reservedThreads = -2;
+ private int _reservedThreads = -1;
public static int defaultSchedulers(Executor executor)
{
@@ -129,20 +129,27 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
* Get the number of preallocated producing threads
* @see EatWhatYouKill
* @see ReservedThreadExecutor
- * @return The number of threads preallocated to producing (default 1).
+ * @return The number of threads preallocated to producing (default -1).
*/
- @ManagedAttribute("The number of preallocated producer threads")
+ @ManagedAttribute("The number of reserved producer threads")
public int getReservedThreads()
{
return _reservedThreads;
}
/**
- * Set the number of preallocated threads for high priority tasks
+ * Set the number of reserved threads for high priority tasks.
+ *
Reserved threads are used to take over producing duties, so that a
+ * producer thread may immediately consume a task it has produced (EatWhatYouKill
+ * scheduling). If a reserved thread is not available, then produced tasks must
+ * be submitted to an executor to be executed by a different thread.
* @see EatWhatYouKill
* @see ReservedThreadExecutor
- * @param threads The number of producing threads to preallocate (default 1).
- * The EatWhatYouKill scheduler will be disabled with a value of 0.
+ * @param threads The number of producing threads to preallocate. If
+ * less that 0 (the default), then a heuristic based on the number of CPUs and
+ * the thread pool size is used to select the number of threads. If 0, no
+ * threads are preallocated and the EatWhatYouKill scheduler will be
+ * disabled and all produced tasks will be executed in a separate thread.
*/
public void setReservedThreads(int threads)
{
@@ -284,7 +291,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
@Override
protected void doStart() throws Exception
{
- addBean(new ReservedThreadExecutor(getExecutor(),_reservedThreads==-2?_selectors.length:_reservedThreads),true);
+ addBean(new ReservedThreadExecutor(getExecutor(),_reservedThreads),true);
for (int i = 0; i < _selectors.length; i++)
{
ManagedSelector selector = newSelector(i);
diff --git a/jetty-server/src/main/config/modules/http.mod b/jetty-server/src/main/config/modules/http.mod
index d833a6da297..86a1ab96a4f 100644
--- a/jetty-server/src/main/config/modules/http.mod
+++ b/jetty-server/src/main/config/modules/http.mod
@@ -40,8 +40,8 @@ etc/jetty-http.xml
## Thread priority delta to give to acceptor threads
# jetty.http.acceptorPriorityDelta=0
-## Reserve threads for high priority tasks (-2 use number of selectors,-1 use number of CPUs, 0 no reserved threads)
-# jetty.http.reservedThreads=-2
+## Reserve threads for high priority tasks (-1 use a heuristic, 0 no reserved threads)
+# jetty.http.reservedThreads=-1
## Connect Timeout in milliseconds
# jetty.http.connectTimeout=15000
From 1311052b1550a91ad71382724dd057ca47573baf Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Tue, 8 Aug 2017 09:47:04 -0700
Subject: [PATCH 141/147] Cleaning up state of branch to match the original
jetty-9.4.x
+ Does not include changes to /jetty-cdi/
+ Does not include changes to /jetty-websocket/ for javax.websocket-1.1
---
Jenkinsfile | 2 +-
VERSION.txt | 524 +++++------
aggregates/jetty-all/pom.xml | 232 ++---
apache-jsp/pom.xml | 77 +-
apache-jstl/pom.xml | 53 +-
examples/async-rest/async-rest-jar/pom.xml | 5 +-
examples/async-rest/async-rest-webapp/pom.xml | 2 +-
examples/async-rest/pom.xml | 4 +-
examples/embedded/pom.xml | 38 +-
examples/pom.xml | 21 +-
jetty-alpn/jetty-alpn-client/pom.xml | 15 +-
jetty-alpn/jetty-alpn-server/pom.xml | 76 +-
.../modules/alpn-impl/alpn-1.8.0_144.mod | 3 -
jetty-alpn/pom.xml | 20 +-
jetty-annotations/pom.xml | 40 +-
jetty-ant/pom.xml | 9 +-
jetty-bom/pom.xml | 5 -
jetty-client/pom.xml | 83 +-
.../client/http/HttpChannelOverHTTP.java | 10 +-
.../eclipse/jetty/client/HttpClientTest.java | 129 +--
jetty-continuation/pom.xml | 31 +-
jetty-deploy/pom.xml | 49 +-
jetty-distribution/pom.xml | 607 ++-----------
.../administration/sessions/chapter.adoc | 26 +-
.../session-configuration-hazelcast.adoc | 86 +-
.../connectors/configuring-ssl.adoc | 14 +-
.../src/main/asciidoc/index-docinfo.xml | 184 ++--
jetty-fcgi/fcgi-client/pom.xml | 2 +-
jetty-fcgi/fcgi-server/pom.xml | 126 ++-
jetty-fcgi/pom.xml | 2 +-
jetty-hazelcast/pom.xml | 86 +-
.../config/etc/sessions/hazelcast/default.xml | 28 +-
.../config/etc/sessions/hazelcast/remote.xml | 26 +-
.../session-store-hazelcast-embedded.mod | 34 +
.../session-store-hazelcast-remote.mod | 36 +
jetty-home/pom.xml | 12 -
jetty-http-spi/pom.xml | 44 +-
.../jetty/http/spi/HttpSpiContextHandler.java | 324 +++----
.../jetty/http/spi/JettyHttpContext.java | 222 ++---
.../http/spi/JettyHttpExchangeDelegate.java | 466 +++++-----
.../http/spi/JettyHttpServerProvider.java | 158 ++--
jetty-http/pom.xml | 32 +-
.../java/org/eclipse/jetty/http/Syntax.java | 284 +++---
.../jetty/http/pathmap/PathMappings.java | 15 +-
.../org/eclipse/jetty/http/SyntaxTest.java | 268 +++---
.../http2/server/HTTP2ServerConnection.java | 1 +
jetty-io/pom.xml | 36 +-
jetty-jaas/pom.xml | 48 +-
jetty-jaspi/pom.xml | 70 +-
jetty-jmx/pom.xml | 55 +-
jetty-jndi/pom.xml | 2 +-
jetty-jspc-maven-plugin/pom.xml | 39 +-
jetty-maven-plugin/pom.xml | 26 +-
.../jetty/maven/plugin/JettyDeployWar.java | 156 ++--
jetty-monitor/pom.xml | 66 +-
jetty-nosql/pom.xml | 55 +-
jetty-osgi/jetty-osgi-alpn/pom.xml | 27 +-
jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 91 +-
jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 38 +-
jetty-osgi/jetty-osgi-boot/pom.xml | 43 +-
jetty-osgi/jetty-osgi-httpservice/pom.xml | 34 +-
jetty-osgi/pom.xml | 27 +-
jetty-osgi/test-jetty-osgi-context/pom.xml | 136 ++-
jetty-osgi/test-jetty-osgi-webapp/pom.xml | 125 +--
jetty-osgi/test-jetty-osgi/pom.xml | 152 ++--
jetty-plus/pom.xml | 55 +-
jetty-proxy/pom.xml | 55 +-
jetty-quickstart/pom.xml | 27 +-
jetty-rewrite/pom.xml | 48 +-
jetty-runner/pom.xml | 86 +-
jetty-security/pom.xml | 33 +-
.../jetty/security/AliasedConstraintTest.java | 368 ++++----
jetty-server/pom.xml | 71 +-
.../eclipse/jetty/server/LocalConnector.java | 12 +-
.../jetty/server/ServerConnectorTest.java | 9 -
jetty-servlet/pom.xml | 52 +-
jetty-servlets/pom.xml | 62 +-
.../jetty/servlets/ThreadStarvationTest.java | 814 +++++++++---------
jetty-spring/pom.xml | 20 +-
jetty-start/pom.xml | 9 +-
.../org/eclipse/jetty/start/BaseHomeTest.java | 428 ++++-----
.../jetty/start/ConfigurationAssert.java | 543 ++++++------
.../modules/alpn-impl/alpn-1.8.0_131.mod | 3 -
.../modules/alpn-impl/alpn-1.8.0_144.mod | 3 -
jetty-util-ajax/pom.xml | 50 +-
jetty-util/pom.xml | 61 +-
.../jetty/util/RolloverFileOutputStream.java | 67 +-
.../jetty/util/SharedBlockingCallback.java | 2 +-
.../util/RolloverFileOutputStreamTest.java | 156 ++--
.../jetty/util/URIUtilCanonicalPathTest.java | 270 +++---
jetty-webapp/pom.xml | 61 +-
.../jetty/webapp/URLStreamHandlerUtil.java | 156 ++--
jetty-xml/pom.xml | 26 +-
pom.xml | 103 +--
tests/pom.xml | 20 +-
tests/test-continuation/pom.xml | 28 +-
tests/test-integration/pom.xml | 42 +-
tests/test-jmx/jmx-webapp-it/pom.xml | 156 +---
tests/test-jmx/jmx-webapp/pom.xml | 25 +-
tests/test-jmx/pom.xml | 19 +-
tests/test-loginservice/pom.xml | 22 +-
tests/test-quickstart/pom.xml | 9 +-
tests/test-sessions/pom.xml | 21 +-
.../test-sessions/test-hash-sessions/pom.xml | 22 +-
.../test-sessions/test-jdbc-sessions/pom.xml | 26 +-
.../test-mongodb-sessions/pom.xml | 22 +-
.../test-sessions-common/pom.xml | 22 +-
tests/test-webapps/pom.xml | 21 +-
tests/test-webapps/test-jaas-webapp/pom.xml | 16 +-
tests/test-webapps/test-jetty-webapp/pom.xml | 112 +--
tests/test-webapps/test-jndi-webapp/pom.xml | 15 +-
.../test-webapps/test-mock-resources/pom.xml | 29 +-
tests/test-webapps/test-proxy-webapp/pom.xml | 54 +-
tests/test-webapps/test-servlet-spec/pom.xml | 2 +-
.../test-container-initializer/pom.xml | 37 +-
.../test-spec-webapp/pom.xml | 77 +-
.../test-web-fragment/pom.xml | 52 +-
.../test-webapps/test-webapp-rfc2616/pom.xml | 22 +-
118 files changed, 4221 insertions(+), 6037 deletions(-)
create mode 100644 jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod
create mode 100644 jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod
diff --git a/Jenkinsfile b/Jenkinsfile
index 0016dc734dd..185f2d6ab31 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -53,7 +53,7 @@ node {
withEnv(mvnEnv) {
timeout(time: 90, unit: 'MINUTES') {
// Run test phase / ignore test failures
- sh "mvn -B install -Dmaven.test.failure.ignore=true"
+ sh "mvn -B install -Dmaven.test.failure.ignore=true -Prun-its"
// Report failures in the jenkins UI
step([$class: 'JUnitResultArchiver',
testResults: '**/target/surefire-reports/TEST-*.xml'])
diff --git a/VERSION.txt b/VERSION.txt
index bfc9e8b6d1f..ca16e0daa48 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1,25 +1,4 @@
-jetty-9.3.22-SNAPSHOT
-
-jetty-9.3.21.M0 - 01 August 2017
- + 1357 RolloverFileOutputStream: No rollout performed at midnight
- + 1469 RolloverFileOutputStream: IllegalStateException Task already scheduled
- + 1507 RolloverFileOutputStream: Negative delay Timer.schedule exception
- + 1513 RolloverFileOutputStream: can't handle multiple instances
- + 1655 Improve extensibility of ServerConnector
- + 1661 AbstractProxyServlet onProxyResponseFailure Error
- + 1664 IPAccessHandler CIDR IP range check is incorrect
- + 1685 Update ALPN support for Java 8u141
- + 1687 HTTP2: Correcting missing callback notification when channel not found
- + 1702 Update ALPN support for Java 8u144
- + 1703 Improve HttpInput failure logging
-
-jetty-9.3.20.v20170531 - 31 May 2017
- + 523 TLS close behaviour breaking session resumption
- + 1108 Please improve logging in SslContextFactory when there are no approved
- cipher suites
- + 1527 Jetty BOM should not depend on jetty-parent
- + 1556 A timing channel in Password.java
- + 1567 XmlConfiguration will start the same object multiple times
+jetty-9.4.7-SNAPSHOT
jetty-9.2.22.v20170606 - 06 June 2017
+ 920 no main manifest attribute, in jetty-runner-9.2.19.v20160908.jar
@@ -33,10 +12,9 @@ jetty-9.2.22.v20170606 - 06 June 2017
+ 1523 Update ALPN support for Java 8u131
+ 1556 A timing channel in Password.java
+ 1590 RolloverFileOutputStream not functioning in Jetty 9.2.21+
-jetty-9.2.23-SNAPSHOT
-jetty-9.2.22.v20170606 - 06 June 2017
- + 920 no main manifest attribute, in jetty-runner-9.2.19.v20160908.jar
+jetty-9.4.6.v20170531 - 31 May 2017
+ + 523 TLS close behaviour breaking session resumption
+ 1108 Please improve logging in SslContextFactory when there are no approved
cipher suites
+ 1505 Adding jetty.base.uri and jetty.home.uri
@@ -63,6 +41,14 @@ jetty-9.2.22.v20170606 - 06 June 2017
+ 1569 Allow setting of maxBinaryMessageSize to 0 in WebSocketPolicy
+ 1579 NPE in Quoted Quality CSV
+jetty-9.3.20.v20170531 - 31 May 2017
+ + 523 TLS close behaviour breaking session resumption
+ + 1108 Please improve logging in SslContextFactory when there are no approved
+ cipher suites
+ + 1527 Jetty BOM should not depend on jetty-parent
+ + 1556 A timing channel in Password.java
+ + 1567 XmlConfiguration will start the same object multiple times
+
jetty-9.4.5.v20170502 - 02 May 2017
+ 304 Review dead code - StringUtil.sidBytesToString
+ 1235 DNS lookup in newSSLEngine(InetSocketAddress address)
@@ -95,6 +81,20 @@ jetty-9.4.5.v20170502 - 02 May 2017
+ 1521 Prevent copy of jetty jars to lib/gcloud
+ 1523 Update ALPN support for Java 8u131
+jetty-9.3.19.v20170502 - 02 May 2017
+ + 877 Programmatic servlet mappings cannot override mappings from
+ webdefault.xml using quickstart
+ + 1348 Add a BOM artifact
+ + 1390 HashLoginService and "this.web-inf.url" property are incompatible
+ + 1463 SSL Renegotiate limit
+ + 1469 IllegalStateException in RolloverFileOutputStream
+ + 1486 redirect to welcome file broken for sub directory
+ + 1487 add decoded paths
+ + 1507 Negative delay Timer.schedule exception due to mismatched local and
+ _logTimeZone values
+ + 1513 RolloverFileOutputStream can't handle multiple instances
+ + 1523 Update ALPN support for Java 8u131
+
jetty-9.4.4.v20170414 - 14 April 2017
+ 612 Support HTTP Trailer
+ 877 Programmatic servlet mappings cannot override mappings from
@@ -128,6 +128,13 @@ jetty-9.4.4.v20170414 - 14 April 2017
+ 1472 Broken *.gz symlinks cause NPE in DefaultServlet
+ 1475 SIOOBE in ContextHandler startup
+jetty-9.3.18.v20170406 - 06 April 2017
+ + 877 Programmatic servlet mappings cannot override mappings from
+ webdefault.xml using quickstart
+ + 1201 X-Forwarded-For incorrectly set in jetty-http-forwarded.xml
+ + 1417 Improve classloader dumping
+ + 1439 Allow UNC paths to function as Resource bases
+
jetty-9.4.3.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
@@ -156,18 +163,14 @@ jetty-9.4.3.v20170317 - 17 March 2017
+ 1403 Move new CookieCompliance class to jetty-http
+ 1405 Cookie name cannot be blank or null
-jetty-9.3.18.v20170406 - 06 April 2017
- + 877 Programmatic servlet mappings cannot override mappings from
- webdefault.xml using quickstart
- + 1201 X-Forwarded-For incorrectly set in jetty-http-forwarded.xml
- + 1417 Improve classloader dumping
- + 1439 Allow UNC paths to function as Resource bases
-
jetty-9.3.17.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
+ + 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ 1015 Ensure jetty-distribution excludes git / temp files
+ 1047 ReadPendingException and then thread death
+ + 1049 test-jetty-osgi test exits/crashes the surefire forked JVM
+ + 1282 ByteArrayEndPointTest.testIdle() failure
+ 1296 Introduce HTTP parser "content complete" event
+ 1326 Jetty shutdown command got NullPointerException (http2 module added to
start)
@@ -185,7 +188,9 @@ jetty-9.3.17.v20170317 - 17 March 2017
+ 1387 Windows and paxexam failure due to "renaming bundle"
+ 1389 Update to gcloud datastore-0.9.4-beta
+ 1390 HashLoginService and "this.web-inf.url" property are incompatible
+ + 1394 Default OS Locale/Encoding/Charset can cause test failures
+ 1396 Set-Cookie produced by Jetty is invalid for RFC6265 and Chrome
+ + 1399 SlowClientTest is failing on CI
+ 1401 HttpOutput.recycle() does not clear the write listener
jetty-9.4.2.v20170220 - 20 February 2017
@@ -275,17 +280,6 @@ jetty-9.4.1.v20170120 - 20 January 2017
+ 1276 Remove org.eclipse.jetty.websocket.server.WebSocketServerFactory from
SPI
-jetty-9.4.0.v20161208 - 08 December 2016
- + 1112 How config async support in jsp tag?
- + 1124 Allow configuration of WebSocket mappings from Spring
- + 1139 Support configuration of properties during --add-to-start
- + 1146 jetty.server.HttpInput deadlock
- + 1148 Support HTTP/2 HEADERS trailer
- + 1151 NPE in ClasspathPattern.match()
- + 1153 Make SessionData easier to subclass
- + 123 AbstractSessionIdManager can't atomically check for uniqueness of new
- session ID
-
jetty-9.3.16.v20170120 - 20 January 2017
+ 486 JDK 9 ALPN implementation
+ 592 Support no-value Host header in HttpParser
@@ -300,6 +294,9 @@ jetty-9.3.16.v20170120 - 20 January 2017
+ 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
with WEB-INF/lib/jetty-http.jar present
+ 1234 onBadMessage called from with handled message
+ + 1259 HostnameVerificationTest.simpleGetWithHostnameVerificationEnabledTest
+ is broken
+ + 1261 Intermittent H2C test failure AsyncIOServletTest.testAsyncReadEarlyEOF
+ 1262 BufferUtil.isMappedBuffer() uses reflection on private JDK fields
+ 1265 JAXB not available in JDK 9
+ 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
@@ -313,6 +310,14 @@ jetty-9.3.16.v20170120 - 20 January 2017
+ 1275 Get rid of Mockito
+ 1276 Remove org.eclipse.jetty.websocket.server.WebSocketServerFactory from
SPI
+ + 1277 http2 alpn test error
+
+jetty-9.2.21.v20170120 - 20 January 2017
+ + 592 Support no-value Host header in HttpParser
+ + 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
+ with WEB-INF/lib/jetty-http.jar present
+ + 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
+ DeferredAuthentication & FormAuthenticator
jetty-9.3.15.v20161220 - 20 December 2016
+ 240 Missing content for multipart request after upgrade to Jetty > 9.2.7
@@ -341,6 +346,7 @@ jetty-9.3.15.v20161220 - 20 December 2016
+ 1099 PushCacheFilter pushes POST requests
+ 1108 Please improve logging in SslContextFactory when there are no approved
cipher suites
+ + 1114 Add testcase for WSUF for stop/start of the Server
+ 1118 Filter.destroy() conflicts with ContainerLifeCycle.destroy() in
WebSocketUpgradeFilter
+ 1123 Broken lifecycle for WebSocket's mappings
@@ -360,12 +366,27 @@ jetty-9.3.15.v20161220 - 20 December 2016
+ 1186 Where can i find SocketConnector .java and
BlockingChannelConnector.java etc?
-jetty-9.2.21.v20170120 - 20 January 2017
- + 592 Support no-value Host header in HttpParser
- + 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
- with WEB-INF/lib/jetty-http.jar present
- + 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
- DeferredAuthentication & FormAuthenticator
+jetty-9.2.20.v20161216 - 16 December 2016
+ + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
+ memory leak
+ + Reset Response buffer size
+ + 1051 NCSARequestLog/RolloverFileOutputStream does not roll day after DST
+ ends
+ + 1057 Improve WebSocketUpgradeFilter fast path performance
+ + 1090 Allow WebSocketUpgradeFilter to be used by WEB-INF/web.xml
+ + 1124 Allow configuration of WebSocket mappings from Spring
+ + 1130 PROXY protocol support reports incorrect remote address
+
+jetty-9.4.0.v20161208 - 08 December 2016
+ + 1112 How config async support in jsp tag?
+ + 1124 Allow configuration of WebSocket mappings from Spring
+ + 1139 Support configuration of properties during --add-to-start
+ + 1146 jetty.server.HttpInput deadlock
+ + 1148 Support HTTP/2 HEADERS trailer
+ + 1151 NPE in ClasspathPattern.match()
+ + 1153 Make SessionData easier to subclass
+ + 123 AbstractSessionIdManager can't atomically check for uniqueness of new
+ session ID
jetty-9.4.0.RC3 - 05 December 2016
+ 1051 NCSARequestLog/RolloverFileOutputStream does not roll day after DST
@@ -438,6 +459,23 @@ jetty-9.4.0.RC2 - 16 November 2016
+ 1099 PushCacheFilter pushes POST requests
+ 1103 AbstractNCSARequestLog reports too much of the Request URI
+jetty-9.3.14.v20161028 - 28 October 2016
+ + 292 NPE in SslConnectionFactory newConnection
+ + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
+ memory leak
+ + 989 InputStreamResponseListener.get() throws with HTTP/2 following redirect
+ + 1009 9.3.x] ThreadLimitHandler has no method setBlockForMs
+ + 1018 Remove dependency on asm types in oej.annotations.Util
+ + 1029 Restore Request.setHttpVersion()
+ + 1031 Improve HttpField pre-encoding
+ + 1032 Remove jetty dependencies in jetty jasper classes
+ + 1037 Don't execute AsyncListener.onTimeout events in spare Scheduler-Thread
+ + 1038 AttributeNormalizer does not favor ${WAR} over other attributes, like
+ ${jetty.base}
+ + 1039 AttributeNormalizer should not track attributes that are null
+ + 1046 Improve HTTP2Flusher error report
+ + 480764 Add extra tests for empty multipart
+
jetty-9.4.0.RC1 - 21 October 2016
+ 277 Proxy servlet does not handle HTTP status 100 correctly
+ 292 NPE in SslConnectionFactory newConnection
@@ -479,6 +517,27 @@ jetty-9.4.0.RC1 - 21 October 2016
+ 1017 Output session configuration for dump
+ 1018 Remove dependency on asm types in oej.annotations.Util
+jetty-9.3.13.v20161014 - 14 October 2016
+ + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
+ memory leak
+ + 926 No LSB Tags on jetty.sh script cause warning on Ubuntu 16.04
+ + 999 Create a Flight Recorder module
+ + 1000 Allow legacy behaviour if 2 servlets map to same path
+
+jetty-9.3.13.M0 - 30 September 2016
+ + 277 Proxy servlet does not handle HTTP status 100 correctly
+ + 870 TLS protocol exclusion broken for SslContextFactory(String)
+ + 915 The jetty-maven-plugin:stop goal doesn't stop everything completely
+ + 918 Support certificates hot reload
+ + 930 Add module instructions to SSL section
+ + 943 Docs: Error in 'Embedding Jetty' page - example 'FileServer'
+ + 948 9.4.0.RC0 jetty-distribution invalid config etc/jetty-http2c.xml
+ + 955 Response listeners not invoked when using Connection.send()
+ + 959 CompleteListener invoked twice for HTTP/2 transport and response content
+ + 960 Async I/O spin when reading early EOF
+ + 965 Link from High Load docs to Garbage Collection Tuning is broken
+ + 966 Remove usages of ConcurrentArrayQueue
+
jetty-9.4.0.RC0 - 15 September 2016
+ 131 Improve Connector Statistic names and values
+ 572 Don't reject HTTP/2 requests without body in low threads mode
@@ -514,6 +573,54 @@ jetty-9.4.0.RC0 - 15 September 2016
+ 922 Implements methods Connection.getBytes[In|Out]()
+ 931 Update gcloud datastore to 0.3.0
+jetty-9.3.12.v20160915 - 15 September 2016
+ + 56 Fix authn issues in LdapLoginModule
+ + 131 Improve Connector Statistic names and values
+ + 185 Implement RFC 7239 (Forwarded header)
+ + 700 Bundle org.eclipse.jetty.http.spi not available via p2 repository
+ + 725 Provide a private way to report security issues
+ + 752 Implement support for HTTP2 SETTINGS_MAX_HEADER_LIST_SIZE
+ + 759 Ensure wrapped Responses will close and commit outputstream or writer
+ + 780 The moved websocket PathSpec is incompatible with cometd 3.0.x
+ + 783 Report name of broken jar file
+ + 784 JSP Session updated before sendRedirect() lose their information
+ + 786 Buffering Response Handler
+ + 790 AsyncContentListener semantic broken with HTTP/2 transport
+ + 792 HTTP/2] Socket seems to be not closed completely
+ + 797 MimeTypes resource loading incorrect on OSGi
+ + 798 async IO Write closed race
+ + 804 setting default Url Encoding broken in Jetty >= 9.3
+ + 806 Jetty HttpClient authentication - missing any realm option
+ + 817 NPE in jndi Resource
+ + 826 Better default for HTTP/2's max concurrent streams
+ + 827 HTTPClient fails connecting to HTTPS host through an HTTP proxy
+ w/authentication
+ + 830 Test webapp not properly copied to demo-base
+ + 832 ServerWithJNDI example uses wrong webapp
+ + 841 support reset in buffering interceptors
+ + 844 Implement a Thread Limit Handler
+ + 845 Improve blocking IO for data rate limiting
+ + 851 MBeanContainer no longer unregisters MBeans when "stopped"
+ + 854 If container.destroy() is called, calling container.start() again should
+ throw an IllegalStateException
+ + 855 JMXify MBeanContainer
+ + 860 Only TLS 1.2 Supported
+ + 868 ClassLoader leak with Jetty and Karaf - static instances of
+ java.lang.Throwable
+ + 880 Refactor jetty-http's HostPortHttpField logic into new jetty-util class
+ + 882 Add IPv6 support to IPAddressMap in jetty-util
+ + 889 ConstantThrowable.name can be removed
+ + 894 When adding servless class, preserve Class instead of going through
+ String
+ + 897 Remove GzipHandler interceptor when out of scope
+ + 898 GzipHandler adds multiple Vary header
+ + 902 Expect: 100-Continue does not work with HTTP/2
+ + 909 Path and Domain not properly matched in addCookie()
+ + 911 Request.getRequestURI() gets decoded after startAsync(req, resp) is
+ invoked
+ + 913 Unprotected debug in WebAppClassLoader
+ + 922 Implements methods Connection.getBytes[In|Out]()
+
jetty-9.4.0.M1 - 15 August 2016
+ 185 Implement RFC 7239 (Forwarded header)
+ 213 jetty.osgi.boot requires Server services registered before
@@ -614,6 +721,117 @@ jetty-9.4.0.M1 - 15 August 2016
+ 837 Update to support apache jasper 8.5.4
+ 841 support reset in buffering interceptors
+jetty-9.3.11.v20160721 - 21 July 2016
+ + 230 customize Content-Type in ErrorHandler's default error page
+ + 592 Support no-value Host header in HttpParser
+ + 631 SLOTH protection
+ + 643 NPE in passing websocket client test
+ + 649 LDAPLoginModule should disallow blank username and password
+ + 658 Add memcached option for gcloud-sessions in jetty-9.3
+ + 660 NullPointerException in Request.getParameter: _parameters is null
+ + 663 Update gcloud datastore to 0.2.3
+ + 667 Introduce optional `jetty.deploy.monitoredPath` for jetty-deploy paths
+ outside of ${jetty.base}
+ + 668 Introduce optional `jetty.deploy.defaultsDescriptorPath` for
+ jetty-deploy defaults descriptor outside of ${jetty.home}
+ + 669 Support UNC paths in PathResource
+ + 671 Incorrect ALPN default protocol
+ + 672 Allow logging configuration announcement to be programmatically disabled
+ + 673 ClasspathPattern needs a match all pattern
+ + 675 Slf4jLog.ignore() should produce at DEBUG level
+ + 676 JavaUtilLog.ignore() should produce at DEBUG level
+ + 677 Logging of .ignore() should indicate that it was an "Ignored Exception"
+ + 678 Log at less than DEBUG level when annotation scanning takes significant
+ time
+ + 682 Quickstart should not scan all container path jars
+ + 684 HttpClient proxies (HttpProxy and Socks4Proxy) do not support
+ authentication
+ + 685 SecureRequestCustomizer SSLSession attribute not set
+ + 687 AllowSymLinkAliasChecker not normalizing relative symlinks properly
+ + 690 jetty-maven-plugin does not configure AnnotationConfiguration for
+ jetty:effective-web-xml goal
+ + 693 QoSFilterTest failures are not capture by junit
+ + 694 http2.client.StreamResetTest.testServerExceptionConsumesQueuedData stack
+ not suppressed in test
+ + 695 Deprecate LocalConnector.getResponses() in favor of using .getResponse()
+ + 696 LocalConnector.getResponse() doesn't find close if using HTTP/1.1
+ w/Connection: close
+ + 701 Document CachingWebAppClassLoader
+ + 706 org.apache.jasper.compiler.disablejsr199 is no longer present in Jetty
+ 9.3+
+ + 708 SslContextFactory: newSslServerSocket/newSslSocket customization
+ + 717 GzipHandler.minGzipSize still compresses small responses
+ + 718 Document HttpClient transports
+ + 720 asciiToLowerCase throws NullPointerException
+ + 721 HTTP Response header value encoding is invalid for RFC7230
+ + 723 Improve bad/missing mime.properties reporting
+ + 726 Http2 Client parse error
+ + 730 "Slow" client causes IllegalStateException
+ + 733 Allow setCharacterEncoding after getOutputStream
+ + 739 Illegal WindowUpdate frame with delta=0
+ + 742 Fixed link to webtide.com
+ + 745 Removed README.txt
+ + 747 Update documentation to reflect TLS and SSL support
+ + 751 Remove usages of ArrayQueue
+ + 752 Implement support for HTTP2 SETTINGS_MAX_HEADER_LIST_SIZE
+ + 755 NPE in HttpChannelOverHTTP2.requestContent()
+ + 756 Filter problematic headers from CGI and FastCGIProxy
+
+jetty-9.2.19.v20160908 - 08 September 2016
+ + 817 NPE in jndi Resource
+ + 830 Test webapp not properly copied to demo-base
+ + 832 ServerWithJNDI example uses wrong webapp
+ + 851 MBeanContainer no longer unregisters MBeans when "stopped"
+ + 868 ClassLoader leak with Jetty and Karaf - static instances of
+ java.lang.Throwable
+ + 880 Refactor jetty-http's HostPortHttpField logic into new jetty-util class
+ + 882 Add IPv6 support to IPAddressMap in jetty-util
+ + 894 When adding servless class, preserve Class instead of going through
+ String
+ + 899 PathFinderTest fails in jetty-9.2.x
+
+jetty-9.2.18.v20160721 - 21 July 2016
+ + 425 Incorrect @ServerEndpoint Encoder/Decoder lifecycle
+ + 649 LDAPLoginModule should disallow blank username and password
+ + 654 Jetty 9.3 ServletContext.getResourceAsStream("/") returns an unusable
+ stream
+ + 661 JsrExtension is missing hashCode() and equals()
+ + 756 Filter problematic headers from CGI and FastCGIProxy
+
+jetty-9.3.11.M0 - 22 June 2016
+ + 425 Incorrect @ServerEndpoint Encoder/Decoder lifecycle
+ + 624 AsyncContext.onCompleted called twice
+ + 645 jetty-requestlog.xml default log path
+ + 654 Jetty 9.3 ServletContext.getResourceAsStream("/") returns an unusable
+ stream
+ + 659 CONNECT request fails spuriously
+ + 660 NullPointerException in Request.getParameter: _parameters is null
+ + 661 JsrExtension is missing hashCode() and equals()
+
+jetty-9.3.10.v20160621 - 21 June 2016
+ + 388 Add methods to send text frames with pre-encoded strings
+ + 605 Guard concurrent calls to WebSocketSession.close()
+ + 608 reset encoding set from content type?
+ + 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ + 610 HttpClientRedirectTest/testRedirectWithWrongScheme test failing in CI
+ + 620 Missing call to setPattern in RewritePatternRule constructor
+ + 622 NoSqlSessionManager test for expired session does not use
+ session.maxInactiveInterval
+ + 623 Add --gzip suffix to 304 responses with ETAGs
+ + 624 AsyncContext.onCompleted called twice
+ + 628 IOException: Unable to open root Jar file
+ MetaInfConfiguration.getTlds(MetaInfConfiguration.java:406) with Spring boot
+ loader + WebAppContext + non-expanded war
+ + 632 JMX tests rely on fixed port
+ + 633 If jmx and websocket is enabled, redploying a context produces a
+ NullPointerException
+ + 638 ConnectHandler responses should have Content-Length
+ + 639 ServerContainer stores WebSocket sessions twice
+ + 640 ClientContainer should store WebSocket sessions as beans
+ + 641 MongoSessionIdManager uses deprecated ensureIndex
+ + 647 HTTP/2 CONTINUATION frame parsing throws IllegalStateException
+ + 648 Problem using InputStreamResponseListener to handle HTTP/2 responses
+
jetty-9.4.0.M0 - 03 June 2016
+ 356 Element error-page/location must start with a '/'
+ 360 Improve HTTP/2 stream interleaving
@@ -687,203 +905,6 @@ jetty-9.4.0.M0 - 03 June 2016
+ 605 Guard concurrent calls to WebSocketSession.close()
+ 608 reset encoding set from content type
-jetty-9.2.20.v20161216 - 16 December 2016
- + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
- memory leak
- + Reset Response buffer size
- + 1051 NCSARequestLog/RolloverFileOutputStream does not roll day after DST
- ends
- + 1057 Improve WebSocketUpgradeFilter fast path performance
- + 1090 Allow WebSocketUpgradeFilter to be used by WEB-INF/web.xml
- + 1124 Allow configuration of WebSocket mappings from Spring
- + 1130 PROXY protocol support reports incorrect remote address
-
-jetty-9.3.14.v20161028 - 28 October 2016
- + 292 NPE in SslConnectionFactory newConnection
- + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
- memory leak
- + 989 InputStreamResponseListener.get() throws with HTTP/2 following redirect
- + 1009 9.3.x] ThreadLimitHandler has no method setBlockForMs
- + 1018 Remove dependency on asm types in oej.annotations.Util
- + 1029 Restore Request.setHttpVersion()
- + 1031 Improve HttpField pre-encoding
- + 1032 Remove jetty dependencies in jetty jasper classes
- + 1037 Don't execute AsyncListener.onTimeout events in spare Scheduler-Thread
- + 1038 AttributeNormalizer does not favor ${WAR} over other attributes, like
- ${jetty.base}
- + 1039 AttributeNormalizer should not track attributes that are null
- + 1046 Improve HTTP2Flusher error report
-
-jetty-9.3.13.v20161014 - 14 October 2016
- + 295 Ensure Jetty Client use of Deflater / Inflater calls .end() to avoid
- memory leak
- + 926 No LSB Tags on jetty.sh script cause warning on Ubuntu 16.04
- + 999 Create a Flight Recorder module
- + 1000 Allow legacy behaviour if 2 servlets map to same path
-
-jetty-9.3.13.M0 - 30 September 2016
- + 277 Proxy servlet does not handle HTTP status 100 correctly
- + 870 TLS protocol exclusion broken for SslContextFactory(String)
- + 915 The jetty-maven-plugin:stop goal doesn't stop everything completely
- + 918 Support certificates hot reload
- + 930 Add module instructions to SSL section
- + 943 Docs: Error in 'Embedding Jetty' page - example 'FileServer'
- + 948 9.4.0.RC0 jetty-distribution invalid config etc/jetty-http2c.xml
- + 955 Response listeners not invoked when using Connection.send()
- + 959 CompleteListener invoked twice for HTTP/2 transport and response content
- + 960 Async I/O spin when reading early EOF
- + 965 Link from High Load docs to Garbage Collection Tuning is broken
- + 966 Remove usages of ConcurrentArrayQueue
-
-jetty-9.3.12.v20160915 - 15 September 2016
- + 56 Fix authn issues in LdapLoginModule
- + 131 Improve Connector Statistic names and values
- + 185 Implement RFC 7239 (Forwarded header)
- + 700 Bundle org.eclipse.jetty.http.spi not available via p2 repository
- + 725 Provide a private way to report security issues
- + 752 Implement support for HTTP2 SETTINGS_MAX_HEADER_LIST_SIZE
- + 759 Ensure wrapped Responses will close and commit outputstream or writer
- + 780 The moved websocket PathSpec is incompatible with cometd 3.0.x
- + 783 Report name of broken jar file
- + 784 JSP Session updated before sendRedirect() lose their information
- + 786 Buffering Response Handler
- + 790 AsyncContentListener semantic broken with HTTP/2 transport
- + 792 HTTP/2] Socket seems to be not closed completely
- + 797 MimeTypes resource loading incorrect on OSGi
- + 798 async IO Write closed race
- + 804 setting default Url Encoding broken in Jetty >= 9.3
- + 806 Jetty HttpClient authentication - missing any realm option
- + 817 NPE in jndi Resource
- + 826 Better default for HTTP/2's max concurrent streams
- + 827 HTTPClient fails connecting to HTTPS host through an HTTP proxy
- w/authentication
- + 830 Test webapp not properly copied to demo-base
- + 832 ServerWithJNDI example uses wrong webapp
- + 841 support reset in buffering interceptors
- + 844 Implement a Thread Limit Handler
- + 845 Improve blocking IO for data rate limiting
- + 851 MBeanContainer no longer unregisters MBeans when "stopped"
- + 854 If container.destroy() is called, calling container.start() again should
- throw an IllegalStateException
- + 855 JMXify MBeanContainer
- + 860 Only TLS 1.2 Supported
- + 868 ClassLoader leak with Jetty and Karaf - static instances of
- java.lang.Throwable
- + 880 Refactor jetty-http's HostPortHttpField logic into new jetty-util class
- + 882 Add IPv6 support to IPAddressMap in jetty-util
- + 889 ConstantThrowable.name can be removed
- + 894 When adding servless class, preserve Class instead of going through
- String
- + 897 Remove GzipHandler interceptor when out of scope
- + 898 GzipHandler adds multiple Vary header
- + 902 Expect: 100-Continue does not work with HTTP/2
- + 909 Path and Domain not properly matched in addCookie()
- + 911 Request.getRequestURI() gets decoded after startAsync(req, resp) is
- invoked
- + 913 Unprotected debug in WebAppClassLoader
- + 922 Implements methods Connection.getBytes[In|Out]()
-
-jetty-9.3.11.v20160721 - 21 July 2016
- + 230 customize Content-Type in ErrorHandler's default error page
- + 592 Support no-value Host header in HttpParser
- + 631 SLOTH protection
- + 649 LDAPLoginModule should disallow blank username and password
- + 658 Add memcached option for gcloud-sessions in jetty-9.3
- + 660 NullPointerException in Request.getParameter: _parameters is null
- + 663 Update gcloud datastore to 0.2.3
- + 667 Introduce optional `jetty.deploy.monitoredPath` for jetty-deploy paths
- outside of ${jetty.base}
- + 668 Introduce optional `jetty.deploy.defaultsDescriptorPath` for
- jetty-deploy defaults descriptor outside of ${jetty.home}
- + 669 Support UNC paths in PathResource
- + 671 Incorrect ALPN default protocol
- + 672 Allow logging configuration announcement to be programmatically disabled
- + 673 ClasspathPattern needs a match all pattern
- + 675 Slf4jLog.ignore() should produce at DEBUG level
- + 676 JavaUtilLog.ignore() should produce at DEBUG level
- + 677 Logging of .ignore() should indicate that it was an "Ignored Exception"
- + 678 Log at less than DEBUG level when annotation scanning takes significant
- time
- + 682 Quickstart should not scan all container path jars
- + 684 HttpClient proxies (HttpProxy and Socks4Proxy) do not support
- authentication
- + 685 SecureRequestCustomizer SSLSession attribute not set
- + 687 AllowSymLinkAliasChecker not normalizing relative symlinks properly
- + 690 jetty-maven-plugin does not configure AnnotationConfiguration for
- jetty:effective-web-xml goal
- + 695 Deprecate LocalConnector.getResponses() in favor of using .getResponse()
- + 696 LocalConnector.getResponse() doesn't find close if using HTTP/1.1
- w/Connection: close
- + 701 Document CachingWebAppClassLoader
- + 706 org.apache.jasper.compiler.disablejsr199 is no longer present in Jetty
- 9.3+
- + 708 SslContextFactory: newSslServerSocket/newSslSocket customization
- + 717 GzipHandler.minGzipSize still compresses small responses
- + 718 Document HttpClient transports
- + 720 asciiToLowerCase throws NullPointerException
- + 721 HTTP Response header value encoding is invalid for RFC7230
- + 723 Improve bad/missing mime.properties reporting
- + 726 Http2 Client parse error
- + 730 "Slow" client causes IllegalStateException
- + 733 Allow setCharacterEncoding after getOutputStream
- + 739 Illegal WindowUpdate frame with delta=0
- + 742 Fixed link to webtide.com
- + 745 Removed README.txt
- + 747 Update documentation to reflect TLS and SSL support
- + 751 Remove usages of ArrayQueue
- + 752 Implement support for HTTP2 SETTINGS_MAX_HEADER_LIST_SIZE
- + 755 NPE in HttpChannelOverHTTP2.requestContent()
- + 756 Filter problematic headers from CGI and FastCGIProxy
-
-jetty-9.2.19.v20160908 - 08 September 2016
- + 817 NPE in jndi Resource
- + 830 Test webapp not properly copied to demo-base
- + 832 ServerWithJNDI example uses wrong webapp
- + 851 MBeanContainer no longer unregisters MBeans when "stopped"
- + 868 ClassLoader leak with Jetty and Karaf - static instances of
- java.lang.Throwable
- + 880 Refactor jetty-http's HostPortHttpField logic into new jetty-util class
- + 882 Add IPv6 support to IPAddressMap in jetty-util
- + 894 When adding servless class, preserve Class instead of going through
- String
-
-jetty-9.2.18.v20160721 - 21 July 2016
- + 425 Incorrect @ServerEndpoint Encoder/Decoder lifecycle
- + 649 LDAPLoginModule should disallow blank username and password
- + 654 Jetty 9.3 ServletContext.getResourceAsStream("/") returns an unusable
- stream
- + 661 JsrExtension is missing hashCode() and equals()
- + 756 Filter problematic headers from CGI and FastCGIProxy
-
-jetty-9.3.11.M0 - 22 June 2016
- + 425 Incorrect @ServerEndpoint Encoder/Decoder lifecycle
- + 624 AsyncContext.onCompleted called twice
- + 645 jetty-requestlog.xml default log path
- + 654 Jetty 9.3 ServletContext.getResourceAsStream("/") returns an unusable
- stream
- + 659 CONNECT request fails spuriously
- + 660 NullPointerException in Request.getParameter: _parameters is null
- + 661 JsrExtension is missing hashCode() and equals()
-
-jetty-9.3.10.v20160621 - 21 June 2016
- + 388 Add methods to send text frames with pre-encoded strings
- + 605 Guard concurrent calls to WebSocketSession.close()
- + 608 reset encoding set from content type?
- + 620 Missing call to setPattern in RewritePatternRule constructor
- + 623 Add --gzip suffix to 304 responses with ETAGs
- + 624 AsyncContext.onCompleted called twice
- + 628 IOException: Unable to open root Jar file
- MetaInfConfiguration.getTlds(MetaInfConfiguration.java:406) with Spring boot
- loader + WebAppContext + non-expanded war
- + 633 If jmx and websocket is enabled, redploying a context produces a
- NullPointerException
- + 638 ConnectHandler responses should have Content-Length
- + 639 ServerContainer stores WebSocket sessions twice
- + 640 ClientContainer should store WebSocket sessions as beans
- + 641 MongoSessionIdManager uses deprecated ensureIndex
- + 647 HTTP/2 CONTINUATION frame parsing throws IllegalStateException
- + 648 Problem using InputStreamResponseListener to handle HTTP/2 responses
-
jetty-9.3.10.M0 - 26 May 2016
+ 354 Spin loop in case of exception thrown during accept()
+ 464 Improve reporting of SSLHandshakeException
@@ -916,6 +937,7 @@ jetty-9.3.9.v20160517 - 17 May 2016
+ 558 HTTP/2 server hangs when thread pool is low on threads
+ 560 Jetty Client Proxy Authentication does not work with HTTP Proxy
tunneling
+ + 561 Fixed test timer
+ 567 NPE in ErrorPageErrorHandler debug
+ 570 URIUtil.encodePath does not always encode utf8 chars
+ 571 AbstractAuthentication.matchesURI() fails to match scheme
@@ -961,6 +983,8 @@ jetty-9.3.9.M1 - 11 April 2016
+ 418 Add osgi capability for endpoint configurator
+ 424 Jetty impl. of Websocket ServerEndpointConfig.Configurator lifecycle out
of spec
+ + 427 Squelch intentional exceptions seen during websocket testing
+ + 434 RequestTest stack traces
+ 435 adjust debug log message
+ 437 Avoid NPE on receiving empty message though MessageHandler.Partial
+ 438 File and Path Resources with control characters should be rejected
@@ -980,6 +1004,7 @@ jetty-9.3.9.M1 - 11 April 2016
+ 476 HttpClient should not send absolute-form target with non HttpProxy
jetty-9.3.8.v20160314 - 14 March 2016
+ + 107 ResourceHandler range support testcase
+ 124 Don't produce text/html if the request doesn't accept it
+ 247 improving invalid buffer manipulation exception messages
+ 258 Http request to origin server over https proxy contains absolute URL
@@ -988,6 +1013,8 @@ jetty-9.3.8.v20160314 - 14 March 2016
+ 305 NPE when notifying the session listener if the channel is closed before
a session has been opened
+ 316 Add *.chm mimetype mapping
+ + 343 ensure release deployment of test-jetty-webapp:war and
+ test-proxy-webapp:war
+ 346 HttpParser RFC2616 Compliance mode
+ 353 Jetty Client doesn't forward authentication headers with redirects when
using proxy
@@ -1006,6 +1033,7 @@ jetty-9.3.8.v20160314 - 14 March 2016
+ 386 Explicit Authorization header is dropped when handling 407s
+ 397 Multipart EOF handling
+ 402 Don't use Thread.isAlive() in ShutdownMonitor
+ + 405 adding testcase for problematic HttpURI parsing of path params
+ 406 GzipHandler: allow to override the Vary response header
+ 407 JSR356 Server WebSocket Sessions no longer being tracked
+ 408 Http client does not work on https with proxy
@@ -1100,6 +1128,7 @@ jetty-9.3.7.RC0 - 05 January 2016
+ 482243 Fixed GzipHandler for Include
+ 482270 Expose upgrade request locales
+ 482272 Fixed relative symlink checking
+ + 482506 HTTP/2 load test with h2load fails
+ 482670 HttpURI wrongly parser URI paths starting with /@
+ 482855 Content-Length omitted for POST requests with empty body
+ 482959 Local stream count never decrements when closing a stream causing
@@ -1420,6 +1449,8 @@ jetty-9.3.0.v20150612 - 12 June 2015
+ 452503 Start.jar --add-to-start=jstl results in GraphException: Unable to
expand property in name: jsp-impl/${jsp-impl}-jstl
+ 453487 Recycle HttpChannelOverHTTP2
+ + 453627 Fixed FileSystem test for nanosecond filesystems
+ + 453636 Improved spin detection on test
+ 453829 Added HeaderRegexRule
+ 453834 CDI Support for WebSocket
+ 454152 Remove mux remnants from WebSocketClient
@@ -1430,6 +1461,7 @@ jetty-9.3.0.v20150612 - 12 June 2015
+ 456956 Reduce ThreadLocal.remove() weak reference garbage
+ 457130 HTTPS request with IP host and HTTP proxy throws
IllegalArgumentException.
+ + 457309 Add test to ensure GET and HEAD response headers same for gzip
+ 457508 Add flag to scan exploded jars in jetty-jspc-maven-plugin
+ 457788 Powered By in o.e.j.util.Jetty conditional on sendServerVersion
+ 458478 JarFileResource improve performance of exist method
diff --git a/aggregates/jetty-all/pom.xml b/aggregates/jetty-all/pom.xml
index 665303d7575..d20d594368e 100644
--- a/aggregates/jetty-all/pom.xml
+++ b/aggregates/jetty-all/pom.xml
@@ -2,108 +2,121 @@
org.eclipse.jettyjetty-project
- 9.2.23-SNAPSHOT
+ 9.4.7-SNAPSHOT../../pom.xml4.0.0org.eclipse.jetty.aggregatejetty-allJetty :: Aggregate :: All core Jetty
+ UberJar for Core Jetty features
+ pomhttp://www.eclipse.org/jetty
+
+ ${project.build.directory}/${project.artifactId}-${project.version}-uber.jar
+ ${project.build.directory}/gen-resources
+
- ${project.build.directory}/sourcesorg.apache.maven.plugins
- maven-dependency-plugin
+ maven-resources-plugin