From d6bbe9ab125387829f72ea07aa8ae6c532a431c6 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 3 Mar 2016 09:28:05 -0700 Subject: [PATCH 01/21] Issue #388 - Provide pluggable RemoteEndpoint service --- .../common/RemoteEndpointFactory.java | 27 +++++++++++++++++++ .../websocket/common/WebSocketSession.java | 22 +++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java new file mode 100644 index 00000000000..27afcd7559e --- /dev/null +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java @@ -0,0 +1,27 @@ +// +// ======================================================================== +// 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 org.eclipse.jetty.websocket.common; + +import org.eclipse.jetty.websocket.api.BatchMode; +import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; + +public interface RemoteEndpointFactory +{ + WebSocketRemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode); +} diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java index e32a52cb919..8b70367531d 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java @@ -22,9 +22,11 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.URI; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.ServiceLoader; import java.util.concurrent.Executor; import org.eclipse.jetty.io.ByteBufferPool; @@ -59,7 +61,7 @@ import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope; import org.eclipse.jetty.websocket.common.scopes.WebSocketSessionScope; @ManagedObject("A Jetty WebSocket Session") -public class WebSocketSession extends ContainerLifeCycle implements Session, WebSocketSessionScope, IncomingFrames, Connection.Listener, ConnectionStateListener +public class WebSocketSession extends ContainerLifeCycle implements Session, RemoteEndpointFactory, WebSocketSessionScope, IncomingFrames, Connection.Listener, ConnectionStateListener { private static final Logger LOG = Log.getLogger(WebSocketSession.class); private static final Logger LOG_OPEN = Log.getLogger(WebSocketSession.class.getName() + "_OPEN"); @@ -70,6 +72,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web private final Executor executor; private ClassLoader classLoader; private ExtensionFactory extensionFactory; + private RemoteEndpointFactory remoteEndpointFactory; private String protocolVersion; private Map parameterMap = new HashMap<>(); private WebSocketRemoteEndpoint remote; @@ -141,6 +144,16 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web if(LOG.isDebugEnabled()) LOG.debug("starting - {}",this); + Iterator iter = ServiceLoader.load(RemoteEndpointFactory.class).iterator(); + if (iter.hasNext()) + remoteEndpointFactory = iter.next(); + + if (remoteEndpointFactory == null) + remoteEndpointFactory = this; + + if (LOG.isDebugEnabled()) + LOG.debug("Using RemoteEndpointFactory: {}", remoteEndpointFactory); + super.doStart(); } @@ -460,6 +473,11 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web break; } } + + public WebSocketRemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode) + { + return new WebSocketRemoteEndpoint(connection,outgoingHandler,getBatchMode()); + } /** * Open/Activate the session @@ -481,7 +499,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Web connection.getIOState().onConnected(); // Connect remote - remote = new WebSocketRemoteEndpoint(connection,outgoingHandler,getBatchMode()); + remote = remoteEndpointFactory.newRemoteEndpoint(connection,outgoingHandler,getBatchMode()); if(LOG_OPEN.isDebugEnabled()) LOG_OPEN.debug("[{}] {}.open() remote={}",policy.getBehavior(),this.getClass().getSimpleName(),remote); From 89032b7eac1456c467c0f1f1bfd6b20b82f87815 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 2 Jun 2016 14:24:18 +1000 Subject: [PATCH 02/21] improved test isolation --- .../org/eclipse/jetty/server/LocalAsyncContextTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java index 163efad3c7b..8049c43fa08 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java @@ -44,17 +44,19 @@ import org.junit.Test; public class LocalAsyncContextTest { - protected Server _server = new Server(); - protected SuspendHandler _handler = new SuspendHandler(); + protected Server _server; + protected SuspendHandler _handler; protected Connector _connector; @Before public void init() throws Exception { + _server = new Server(); _connector = initConnector(); _server.setConnectors(new Connector[]{ _connector }); SessionHandler session = new SessionHandler(); + _handler = new SuspendHandler(); session.setHandler(_handler); _server.setHandler(session); @@ -547,7 +549,6 @@ public class LocalAsyncContextTest private static AsyncListener __asyncListener = new AsyncListener() { - @Override public void onComplete(AsyncEvent event) throws IOException { From ec7871718c335d209b238abd14d6e218915de5a6 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 2 Jun 2016 17:38:36 +1000 Subject: [PATCH 03/21] added delay to improve SSL tcpClose test --- .../java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java index a82fbcd1e54..b32f3ce84e9 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointSslTest.java @@ -225,6 +225,7 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest filled=client.read(sslIn); Assert.assertEquals(-1,filled); + Thread.sleep(100); // TODO This should not be needed Assert.assertFalse(server.isOpen()); } From a2309057dc14b7307658c081d976f08a2d86cf83 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 3 Jun 2016 14:15:25 +1000 Subject: [PATCH 04/21] Test Harness for #596 Test harness to try to repeat problem with #596 of content-length added to a HEAD response. In the process added a much better getResponse mechanism to the local connector that avoids using the idle time. --- .../eclipse/jetty/io/ByteArrayEndPoint.java | 126 +++++++++---- .../eclipse/jetty/server/LocalConnector.java | 173 +++++++++++++++++- .../org/eclipse/jetty/server/DumpHandler.java | 3 +- .../jetty/server/HttpConnectionTest.java | 55 +++++- .../jetty/server/LocalConnectorTest.java | 51 ++++++ .../org/eclipse/jetty/util/thread/Locker.java | 61 ++---- .../eclipse/jetty/util/thread/LockerTest.java | 22 +-- 7 files changed, 378 insertions(+), 113 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java index 4b5a4077805..6e9684bf050 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java @@ -26,6 +26,8 @@ import java.nio.channels.ClosedChannelException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Queue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Condition; import org.eclipse.jetty.util.ArrayQueue; import org.eclipse.jetty.util.BufferUtil; @@ -55,6 +57,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint }; private final Locker _locker = new Locker(); + private final Condition _hasOutput = _locker.newCondition(); private final Queue _inQ = new ArrayQueue<>(); private ByteBuffer _out; private boolean _ishut; @@ -182,6 +185,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint _runFillable.run(); } + /* ------------------------------------------------------------ */ public void addInputAndExecute(ByteBuffer in) { boolean fillable=false; @@ -223,7 +227,10 @@ public class ByteArrayEndPoint extends AbstractEndPoint */ public ByteBuffer getOutput() { - return _out; + try(Locker.Lock lock = _locker.lock()) + { + return _out; + } } /* ------------------------------------------------------------ */ @@ -251,8 +258,36 @@ public class ByteArrayEndPoint extends AbstractEndPoint */ public ByteBuffer takeOutput() { - ByteBuffer b=_out; - _out=BufferUtil.allocate(b.capacity()); + ByteBuffer b; + + try(Locker.Lock lock = _locker.lock()) + { + b=_out; + _out=BufferUtil.allocate(b.capacity()); + } + getWriteFlusher().completeWrite(); + return b; + } + + /* ------------------------------------------------------------ */ + /** Wait for some output + * @param time Time to wait + * @param unit Units for time to wait + * @return The buffer of output + * @throws InterruptedException + */ + public ByteBuffer waitForOutput(long time,TimeUnit unit) throws InterruptedException + { + ByteBuffer b; + + try(Locker.Lock lock = _locker.lock()) + { + if (BufferUtil.isEmpty(_out)) + _hasOutput.await(time,unit); + + b=_out; + _out=BufferUtil.allocate(b.capacity()); + } getWriteFlusher().completeWrite(); return b; } @@ -283,7 +318,10 @@ public class ByteArrayEndPoint extends AbstractEndPoint */ public void setOutput(ByteBuffer out) { - _out = out; + try(Locker.Lock lock = _locker.lock()) + { + _out = out; + } getWriteFlusher().completeWrite(); } @@ -349,6 +387,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint try(Locker.Lock lock = _locker.lock()) { _oshut=true; + _hasOutput.signalAll(); if (_ishut && !_closed) close=_closed=true; } @@ -368,6 +407,8 @@ public class ByteArrayEndPoint extends AbstractEndPoint { if (!_closed) close=_closed=_ishut=_oshut=true; + + _hasOutput.signalAll(); } if (close) super.close(); @@ -439,41 +480,47 @@ public class ByteArrayEndPoint extends AbstractEndPoint @Override public boolean flush(ByteBuffer... buffers) throws IOException { - if (_closed) - throw new IOException("CLOSED"); - if (_oshut) - throw new IOException("OSHUT"); - boolean flushed=true; - boolean idle=true; - - for (ByteBuffer b : buffers) + try(Locker.Lock lock = _locker.lock()) { - if (BufferUtil.hasContent(b)) + if (_closed) + throw new IOException("CLOSED"); + if (_oshut) + throw new IOException("OSHUT"); + + boolean idle=true; + + for (ByteBuffer b : buffers) { - if (_growOutput && b.remaining()>BufferUtil.space(_out)) - { - BufferUtil.compact(_out); - if (b.remaining()>BufferUtil.space(_out)) - { - ByteBuffer n = BufferUtil.allocate(_out.capacity()+b.remaining()*2); - BufferUtil.append(n,_out); - _out=n; - } - } - - if (BufferUtil.append(_out,b)>0) - idle=false; - if (BufferUtil.hasContent(b)) { - flushed=false; - break; + if (_growOutput && b.remaining()>BufferUtil.space(_out)) + { + BufferUtil.compact(_out); + if (b.remaining()>BufferUtil.space(_out)) + { + ByteBuffer n = BufferUtil.allocate(_out.capacity()+b.remaining()*2); + BufferUtil.append(n,_out); + _out=n; + } + } + + if (BufferUtil.append(_out,b)>0) + idle=false; + + if (BufferUtil.hasContent(b)) + { + flushed=false; + break; + } } } + if (!idle) + { + notIdle(); + _hasOutput.signalAll(); + } } - if (!idle) - notIdle(); return flushed; } @@ -483,13 +530,16 @@ public class ByteArrayEndPoint extends AbstractEndPoint */ public void reset() { - getFillInterest().onClose(); - getWriteFlusher().onClose(); - _ishut=false; - _oshut=false; - _closed=false; - _inQ.clear(); - BufferUtil.clear(_out); + try(Locker.Lock lock = _locker.lock()) + { + getFillInterest().onClose(); + getWriteFlusher().onClose(); + _ishut=false; + _oshut=false; + _closed=false; + _inQ.clear(); + BufferUtil.clear(_out); + } } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java index 5251235d896..aa9c8b83860 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java @@ -27,10 +27,14 @@ import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.http.HttpField; +import org.eclipse.jetty.http.HttpParser; +import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.util.ByteArrayOutputStream2; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.Scheduler; @@ -76,7 +80,8 @@ public class LocalConnector extends AbstractConnector * returned to the level it was before the requests. *

* This methods waits until the connection is closed or - * is idle for 1s before returning the responses. + * is idle for 5s before returning the responses. + *

Use {@link #getResponse(String)} for an alternative that does not wait for idle. * @param requests the requests * @return the responses * @throws Exception if the requests fail @@ -92,6 +97,7 @@ public class LocalConnector extends AbstractConnector *

* This methods waits until the connection is closed or * an idle period before returning the responses. + *

Use {@link #getResponse(String)} for an alternative that does not wait for idle. * @param requests the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor @@ -109,7 +115,8 @@ public class LocalConnector extends AbstractConnector * returned to the level it was before the requests. *

* This methods waits until the connection is closed or - * is idle for 1s before returning the responses. + * is idle for 5s before returning the responses. + *

Use {@link #getResponse(ByteBuffer)} for an alternative that does not wait for idle. * @param requestsBuffer the requests * @return the responses * @throws Exception if the requests fail @@ -147,7 +154,7 @@ public class LocalConnector extends AbstractConnector /** * Execute a request and return the EndPoint through which - * responses can be received. + * multiple responses can be received or more input provided. * @param rawRequest the request * @return the local endpoint */ @@ -181,9 +188,70 @@ public class LocalConnector extends AbstractConnector connection.onOpen(); } + + /** Get a single response using a parser to search for the end of the message. + * @param requestsBuffer The request to send + * @return ByteBuffer containing response or null. + * @throws Exception If there is a problem + */ + public ByteBuffer getResponse(ByteBuffer requestsBuffer) throws Exception + { + return getResponse(requestsBuffer,false,10,TimeUnit.SECONDS); + } + + /** Get a single response using a parser to search for the end of the message. + * @param requestsBuffer The request to send + * @param head True if the response is for a head request + * @param time The time to wait + * @param unit The units of the wait + * @return ByteBuffer containing response or null. + * @throws Exception If there is a problem + */ + public ByteBuffer getResponse(ByteBuffer requestsBuffer,boolean head, long time,TimeUnit unit) throws Exception + { + if (LOG.isDebugEnabled()) + LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); + LocalEndPoint endp = executeRequest(requestsBuffer); + return endp.waitForResponse(head,time,unit); + } + + + /** Get a single response using a parser to search for the end of the message. + * @param rawRequest The request to send + * @return ByteBuffer containing response or null. + * @throws Exception If there is a problem + */ + public String getResponse(String rawRequest) throws Exception + { + return getResponse(rawRequest,false,10,TimeUnit.SECONDS); + } + + /** Get a single response using a parser to search for the end of the message. + * @param rawRequest The request to send + * @param head True if the response is for a head request + * @param time The time to wait + * @param unit The units of the wait + * @return ByteBuffer containing response or null. + * @throws Exception If there is a problem + */ + public String getResponse(String rawRequest,boolean head, long time,TimeUnit unit) throws Exception + { + ByteBuffer requestsBuffer = BufferUtil.toBuffer(rawRequest, StandardCharsets.ISO_8859_1); + if (LOG.isDebugEnabled()) + LOG.debug("request {}", BufferUtil.toUTF8String(requestsBuffer)); + LocalEndPoint endp = executeRequest(requestsBuffer); + + return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1); + } + + + + /** Local EndPoint + */ public class LocalEndPoint extends ByteArrayEndPoint { private final CountDownLatch _closed = new CountDownLatch(1); + private ByteBuffer _responseData; public LocalEndPoint() { @@ -264,5 +332,104 @@ public class LocalConnector extends AbstractConnector } } } + + + /** Wait for a response using a parser to detect the end of message + * @param head + * @param time + * @param unit + * @return Buffer containing full response or null for EOF; + * @throws Exception + */ + public ByteBuffer waitForResponse(boolean head, long time,TimeUnit unit) throws Exception + { + HttpParser.ResponseHandler handler = new HttpParser.ResponseHandler() + { + @Override + public void parsedHeader(HttpField field) + { + } + + @Override + public boolean messageComplete() + { + return true; + } + + @Override + public boolean headerComplete() + { + return false; + } + + @Override + public int getHeaderCacheSize() + { + return 0; + } + + @Override + public void earlyEOF() + { + } + + @Override + public boolean content(ByteBuffer item) + { + return false; + } + + @Override + public void badMessage(int status, String reason) + { + } + + @Override + public boolean startResponse(HttpVersion version, int status, String reason) + { + return false; + } + }; + + + HttpParser parser = new HttpParser(handler); + parser.setHeadResponse(head); + try(ByteArrayOutputStream2 bout = new ByteArrayOutputStream2();) + { + loop: while(true) + { + // read a chunk of response + ByteBuffer chunk = BufferUtil.hasContent(_responseData) + ? _responseData : waitForOutput(time,unit); + _responseData=null; + + // Parse the content of this chunk + while (BufferUtil.hasContent(chunk)) + { + int pos=chunk.position(); + boolean complete=parser.parseNext(chunk); + if (chunk.position()==pos) + { + // Nothing consumed + if (BufferUtil.isEmpty(chunk)) + break; + return null; + } + + // Add all consumed bytes to the output stream + bout.write(chunk.array(),chunk.arrayOffset()+pos,chunk.position()-pos); + + // If we are complete then break the outer loop + if (complete) + { + if (BufferUtil.hasContent(chunk)) + _responseData=chunk; + break loop; + } + } + } + return ByteBuffer.wrap(bout.getBuf(),0,bout.getCount()); + } + } } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java index 806d413b941..c7b56204fe0 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java @@ -223,7 +223,8 @@ public class DumpHandler extends AbstractHandler writer.flush(); // commit now - response.setContentLength(buf.size()+1000); + if (!Boolean.valueOf(request.getParameter("no-content-length"))) + response.setContentLength(buf.size()+1000); response.addHeader("Before-Flush",response.isCommitted()?"Committed???":"Not Committed"); buf.writeTo(out); out.flush(); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index 876b9fc333e..3b6d32cf9aa 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -283,9 +283,9 @@ public class HttpConnectionTest public void testHead() throws Exception { String responsePOST=connector.getResponses("POST /R1 HTTP/1.1\r\n"+ - "Host: localhost\r\n"+ - "Connection: close\r\n"+ - "\r\n"); + "Host: localhost\r\n"+ + "Connection: close\r\n"+ + "\r\n"); String responseHEAD=connector.getResponses("HEAD /R1 HTTP/1.1\r\n"+ "Host: localhost\r\n"+ @@ -330,6 +330,55 @@ public class HttpConnectionTest assertTrue(postHeaders.equals(headHeaders)); } + @Test + public void testHeadChunked() throws Exception + { + String responsePOST=connector.getResponse("POST /R1?no-content-length=true HTTP/1.1\r\n"+ + "Host: localhost\r\n"+ + "\r\n",false,1,TimeUnit.SECONDS); + + String responseHEAD=connector.getResponse("HEAD /R1?no-content-length=true HTTP/1.1\r\n"+ + "Host: localhost\r\n"+ + "\r\n",true,1,TimeUnit.SECONDS); + + String postLine; + boolean postDate=false; + Set postHeaders = new HashSet<>(); + try(BufferedReader in = new BufferedReader(new StringReader(responsePOST))) + { + postLine = in.readLine(); + String line=in.readLine(); + while (line!=null && line.length()>0) + { + if (line.startsWith("Date:")) + postDate=true; + else + postHeaders.add(line); + line=in.readLine(); + } + } + String headLine; + boolean headDate=false; + Set headHeaders = new HashSet<>(); + try(BufferedReader in = new BufferedReader(new StringReader(responseHEAD))) + { + headLine = in.readLine(); + String line=in.readLine(); + while (line!=null && line.length()>0) + { + if (line.startsWith("Date:")) + headDate=true; + else + headHeaders.add(line); + line=in.readLine(); + } + } + + assertThat(postLine,equalTo(headLine)); + assertThat(postDate,equalTo(headDate)); + assertTrue(postHeaders.equals(headHeaders)); + } + @Test public void testBadHostPort() throws Exception { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java index 853463413d0..ecb02645a24 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalConnectorTest.java @@ -22,10 +22,12 @@ import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import java.nio.charset.StandardCharsets; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.io.Connection; +import org.eclipse.jetty.util.BufferUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -91,7 +93,35 @@ public class LocalConnectorTest assertThat(response,containsString("HTTP/1.1 200 OK")); assertThat(response,containsString("pathInfo=/R1")); } + + @Test + public void testOneResponse_10() throws Exception + { + String response=_connector.getResponse("GET /R1 HTTP/1.0\r\n\r\n"); + assertThat(response,containsString("HTTP/1.1 200 OK")); + assertThat(response,containsString("pathInfo=/R1")); + } + @Test + public void testOneResponse_10_keep_alive() throws Exception + { + String response=_connector.getResponse("GET /R1 HTTP/1.0\r\n" + + "Connection: keep-alive\r\n" + + "\r\n"); + assertThat(response,containsString("HTTP/1.1 200 OK")); + assertThat(response,containsString("pathInfo=/R1")); + } + + @Test + public void testOneResponse_11() throws Exception + { + String response=_connector.getResponse("GET /R1 HTTP/1.1\r\n" + + "Host: localhost\r\n" + + "\r\n"); + assertThat(response,containsString("HTTP/1.1 200 OK")); + assertThat(response,containsString("pathInfo=/R1")); + } + @Test public void testStopStart() throws Exception { @@ -125,6 +155,27 @@ public class LocalConnectorTest assertThat(response,containsString("pathInfo=/R2")); } + @Test + public void testTwoGETsParsed() throws Exception + { + LocalConnector.LocalEndPoint endp = _connector.executeRequest( + "GET /R1 HTTP/1.1\r\n"+ + "Host: localhost\r\n"+ + "\r\n"+ + "GET /R2 HTTP/1.1\r\n"+ + "Host: localhost\r\n"+ + "\r\n"); + + String response = BufferUtil.toString(endp.waitForResponse(false,10,TimeUnit.SECONDS),StandardCharsets.ISO_8859_1); + assertThat(response,containsString("HTTP/1.1 200 OK")); + assertThat(response,containsString("pathInfo=/R1")); + + response = BufferUtil.toString(endp.waitForResponse(false,10,TimeUnit.SECONDS),StandardCharsets.ISO_8859_1); + assertThat(response,containsString("HTTP/1.1 200 OK")); + assertThat(response,containsString("pathInfo=/R2")); + } + + @Test public void testManyGETs() throws Exception { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Locker.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Locker.java index fae9c8a86ca..9348f3f3806 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Locker.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/Locker.java @@ -18,15 +18,12 @@ package org.eclipse.jetty.util.thread; -import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; /** - *

This is a lock designed to protect VERY short sections of - * critical code. Threads attempting to take the lock will wait - * until the lock is available, thus it is important that - * the code protected by this lock is extremely simple and non - * blocking.

+ * Convenience Lock Wrapper. + * *
  * try(SpinLock.Lock lock = locker.lock())
  * {
@@ -36,62 +33,24 @@ import java.util.concurrent.locks.ReentrantLock;
  */
 public class Locker
 {
-    private static final boolean SPIN = Boolean.getBoolean(Locker.class.getName() + ".spin");
-
-    private final boolean _spin;
     private final ReentrantLock _lock = new ReentrantLock();
-    private final AtomicReference _spinLockState = new AtomicReference<>(null);
     private final Lock _unlock = new Lock();
 
     public Locker()
     {
-        this(SPIN);
-    }
-
-    public Locker(boolean spin)
-    {
-        this._spin = spin;
     }
 
     public Lock lock()
-    {
-        if (_spin)
-            spinLock();
-        else
-            concLock();
-        return _unlock;
-    }
-
-    private void spinLock()
-    {
-        Thread current = Thread.currentThread();
-        while (true)
-        {
-            // Using test-and-test-and-set for better performance.
-            Thread locker = _spinLockState.get();
-            if (locker != null || !_spinLockState.compareAndSet(null, current))
-            {
-                if (locker == current)
-                    throw new IllegalStateException("Locker is not reentrant");
-                continue;
-            }
-            return;
-        }
-    }
-
-    private void concLock()
     {
         if (_lock.isHeldByCurrentThread())
             throw new IllegalStateException("Locker is not reentrant");
         _lock.lock();
+        return _unlock;
     }
 
     public boolean isLocked()
     {
-        if (_spin)
-            return _spinLockState.get() != null;
-        else
-            return _lock.isLocked();
+        return _lock.isLocked();
     }
 
     public class Lock implements AutoCloseable
@@ -99,10 +58,12 @@ public class Locker
         @Override
         public void close()
         {
-            if (_spin)
-                _spinLockState.set(null);
-            else
-                _lock.unlock();
+            _lock.unlock();
         }
     }
+    
+    public Condition newCondition()
+    {
+        return _lock.newCondition();
+    }
 }
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/LockerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/LockerTest.java
index be5714231bc..2450c0cddbc 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/LockerTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/LockerTest.java
@@ -18,38 +18,24 @@
 
 package org.eclipse.jetty.util.thread;
 
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-@RunWith(Parameterized.class)
 public class LockerTest
 {
-    @Parameterized.Parameters
-    public static Collection parameters()
+    public LockerTest()
     {
-        return Arrays.asList(new Object[]{true}, new Object[]{false});
-    }
-
-    private boolean spin;
-
-    public LockerTest(boolean spin)
-    {
-        this.spin = spin;
     }
 
     @Test
     public void testLocked()
     {
-        Locker lock = new Locker(spin);
+        Locker lock = new Locker();
         assertFalse(lock.isLocked());
 
         try(Locker.Lock l = lock.lock())
@@ -67,7 +53,7 @@ public class LockerTest
     @Test
     public void testLockedException()
     {
-        Locker lock = new Locker(spin);
+        Locker lock = new Locker();
         assertFalse(lock.isLocked());
 
         try(Locker.Lock l = lock.lock())
@@ -90,7 +76,7 @@ public class LockerTest
     @Test
     public void testContend() throws Exception
     {
-        final Locker lock = new Locker(spin);
+        final Locker lock = new Locker();
 
         final CountDownLatch held0 = new CountDownLatch(1);
         final CountDownLatch hold0 = new CountDownLatch(1);

From 16f3ea82c1fe2f7bf72908b65e121b67041f09e0 Mon Sep 17 00:00:00 2001
From: Jesse McConnell 
Date: Fri, 3 Jun 2016 09:45:10 -0500
Subject: [PATCH 05/21] fix javadoc

---
 .../java/org/eclipse/jetty/util/SharedBlockingCallback.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/SharedBlockingCallback.java b/jetty-util/src/main/java/org/eclipse/jetty/util/SharedBlockingCallback.java
index 649fbcdec77..27daefd7f17 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/SharedBlockingCallback.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/SharedBlockingCallback.java
@@ -125,7 +125,7 @@ public class SharedBlockingCallback
     /**
      * A Closeable Callback.
      * Uses the auto close mechanism to check block has been called OK.
-     * 

Implements {@link Callback.NonBlocking} because calls to this + *

Implements {@link Callback} because calls to this * callback do not blocak, rather they wakeup the thread that is blocked * in {@link #block()} */ From c05e265c5bda2025bdef480561cebf0f6cac58e3 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 3 Jun 2016 17:57:59 +0200 Subject: [PATCH 06/21] Moved scheme checks to the right place. --- .../java/org/eclipse/jetty/client/HttpClient.java | 14 +++++++------- .../jetty/client/HttpClientRedirectTest.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java index b62b8f3adc3..7b749d5dc80 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java @@ -491,6 +491,11 @@ public class HttpClient extends ContainerLifeCycle protected HttpDestination destinationFor(String scheme, String host, int port) { + if (!HttpScheme.HTTP.is(scheme) && !HttpScheme.HTTPS.is(scheme)) + throw new IllegalArgumentException("Invalid protocol " + scheme); + + scheme = scheme.toLowerCase(Locale.ENGLISH); + host = host.toLowerCase(Locale.ENGLISH); port = normalizePort(scheme, port); Origin origin = new Origin(scheme, host, port); @@ -525,17 +530,12 @@ public class HttpClient extends ContainerLifeCycle */ public List getDestinations() { - return new ArrayList(destinations.values()); + return new ArrayList<>(destinations.values()); } protected void send(final HttpRequest request, List listeners) { - String scheme = request.getScheme().toLowerCase(Locale.ENGLISH); - if (!HttpScheme.HTTP.is(scheme) && !HttpScheme.HTTPS.is(scheme)) - throw new IllegalArgumentException("Invalid protocol " + scheme); - - String host = request.getHost().toLowerCase(Locale.ENGLISH); - HttpDestination destination = destinationFor(scheme, host, request.getPort()); + HttpDestination destination = destinationFor(request.getScheme(), request.getHost(), request.getPort()); destination.send(request, listeners); } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java index 667e291cb9b..6e697f5d6d7 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientRedirectTest.java @@ -271,7 +271,7 @@ public class HttpClientRedirectTest extends AbstractHttpClientServerTest { baseRequest.setHandled(true); response.setStatus(303); - response.setHeader("Location", "ssh://localhost/path"); + response.setHeader("Location", "ssh://localhost:" + connector.getLocalPort() + "/path"); } }); From f814c3d46cd4ddd8db62d62109f6187330b8c31d Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 3 Jun 2016 10:14:09 -0700 Subject: [PATCH 07/21] Adding looptest for help with CI only flappy test failures --- scripts/looptest.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/looptest.sh diff --git a/scripts/looptest.sh b/scripts/looptest.sh new file mode 100755 index 00000000000..8ef3ce57feb --- /dev/null +++ b/scripts/looptest.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +git fetch origin + +git reset HEAD + +git checkout $BRANCH + +mvn clean install -DskipTests + +cd $MODULE + +let count=0 + +while mvn test $TESTNAME 2>&1 > target/lastbuild.log +do + now=`date` + echo "Test Run $count - $now" >> target/looptest.log + let count=$count+1 +done + From 661a5aeef455bcfa9070642bcda2e360e9483db0 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 3 Jun 2016 11:42:08 -0700 Subject: [PATCH 08/21] Experimenting with looptest and jenkins --- scripts/looptest.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index 8ef3ce57feb..2298d136e44 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -1,10 +1,6 @@ #!/bin/bash -git fetch origin - -git reset HEAD - -git checkout $BRANCH +set mvn clean install -DskipTests From f495053e9b56644c66f468c8fbc42ffc9735a505 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 3 Jun 2016 13:13:53 -0700 Subject: [PATCH 09/21] More looptest experimentation --- scripts/looptest.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index 2298d136e44..37c9019055d 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -2,6 +2,8 @@ set +export PATH=$M3/bin:$PATH + mvn clean install -DskipTests cd $MODULE From 58f8d44ae24ec34db95da4f7bd2395ad9b6e4a86 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Fri, 3 Jun 2016 23:14:18 +0200 Subject: [PATCH 10/21] Improved looptest.sh. Fixed reference to test class. Added DEBUG logging. --- scripts/looptest.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index 2298d136e44..60e760c3932 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -8,10 +8,9 @@ cd $MODULE let count=0 -while mvn test $TESTNAME 2>&1 > target/lastbuild.log +while mvn test -Dtest=$TESTNAME -Dorg.eclipse.jetty.LEVEL=DEBUG 2>&1 > target/lastbuild.log do now=`date` echo "Test Run $count - $now" >> target/looptest.log let count=$count+1 done - From 5e3a534d5d63a5bfad9db2cc6705053a63dcf016 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 3 Jun 2016 14:17:28 -0700 Subject: [PATCH 11/21] More looptest experimentation --- scripts/looptest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index 37c9019055d..5f1dc46346a 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -10,7 +10,7 @@ cd $MODULE let count=0 -while mvn test $TESTNAME 2>&1 > target/lastbuild.log +while mvn test -Dtest=$TESTNAME 2>&1 > target/lastbuild.log do now=`date` echo "Test Run $count - $now" >> target/looptest.log From 40526513f4d208fb2a715fe5b996c9977af9b19a Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 3 Jun 2016 14:27:33 -0700 Subject: [PATCH 12/21] More looptest experimentation --- scripts/looptest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index 5f1dc46346a..f745b6d58df 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -13,7 +13,7 @@ let count=0 while mvn test -Dtest=$TESTNAME 2>&1 > target/lastbuild.log do now=`date` - echo "Test Run $count - $now" >> target/looptest.log + echo "Test Run $count - $now" let count=$count+1 done From 4ce35feb41902e8af85668074c5422d405586bae Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 6 Jun 2016 07:01:48 -0700 Subject: [PATCH 13/21] Adding OPTS --- scripts/looptest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/looptest.sh b/scripts/looptest.sh index f745b6d58df..4099a948517 100755 --- a/scripts/looptest.sh +++ b/scripts/looptest.sh @@ -10,7 +10,7 @@ cd $MODULE let count=0 -while mvn test -Dtest=$TESTNAME 2>&1 > target/lastbuild.log +while mvn $OPTS test -Dtest=$TESTNAME 2>&1 > target/lastbuild.log do now=`date` echo "Test Run $count - $now" From 8758cbb6073ccf0f6c41af1ef94da5f9912f7fc0 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 6 Jun 2016 07:24:59 -0700 Subject: [PATCH 14/21] Fixes #388 - Provide pluggable RemoteEndpoint service --- .../misbehaving/MisbehavingClassTest.java | 6 +- .../jsr356/server/OnPartialTest.java | 1 + .../test/resources/jetty-logging.properties | 4 +- .../jetty/websocket/api/RemoteEndpoint.java | 8 ++ .../common/RemoteEndpointFactory.java | 3 +- .../common/WebSocketRemoteEndpoint.java | 8 +- .../websocket/common/WebSocketSession.java | 2 +- .../common/events/EventDriverTest.java | 21 +++-- .../io/CloseableLocalWebSocketSession.java | 57 ++++++++++++ .../message/MessageOutputStreamTest.java | 7 +- .../common/message/MessageWriterTest.java | 7 +- .../websocket/server/WebSocketCloseTest.java | 8 +- .../AnnotatedRuntimeOnConnectSocket.java | 6 +- .../ListenerRuntimeOnConnectSocket.java | 6 +- .../misbehaving/MisbehavingClassTest.java | 93 +++++++++---------- 15 files changed, 154 insertions(+), 83 deletions(-) create mode 100644 jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/CloseableLocalWebSocketSession.java diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java index 7c910944059..962f5468916 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java +++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java @@ -33,8 +33,8 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.log.StacklessLogging; +import org.eclipse.jetty.websocket.common.WebSocketSession; import org.eclipse.jetty.websocket.jsr356.EchoHandler; -import org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -90,7 +90,7 @@ public class MisbehavingClassTest WebSocketContainer container = ContainerProvider.getWebSocketContainer(); EndpointRuntimeOnOpen socket = new EndpointRuntimeOnOpen(); - try (StacklessLogging logging = new StacklessLogging(EndpointRuntimeOnOpen.class,JsrEndpointEventDriver.class)) + try (StacklessLogging logging = new StacklessLogging(EndpointRuntimeOnOpen.class, WebSocketSession.class)) { // expecting ArrayIndexOutOfBoundsException during onOpen Session session = container.connectToServer(socket,serverUri); @@ -111,7 +111,7 @@ public class MisbehavingClassTest WebSocketContainer container = ContainerProvider.getWebSocketContainer(); AnnotatedRuntimeOnOpen socket = new AnnotatedRuntimeOnOpen(); - try (StacklessLogging logging = new StacklessLogging(AnnotatedRuntimeOnOpen.class)) + try (StacklessLogging logging = new StacklessLogging(AnnotatedRuntimeOnOpen.class, WebSocketSession.class)) { // expecting ArrayIndexOutOfBoundsException during onOpen Session session = container.connectToServer(socket,serverUri); diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java index e8bb104bb22..6628a026ad4 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java @@ -88,6 +88,7 @@ public class OnPartialTest @SuppressWarnings("resource") JsrSession session = new JsrSession(container,id,requestURI,driver,connection); session.setPolicy(policy); + session.start(); session.open(); return driver; } diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties b/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties index 9681d9168b4..34c2b7be12f 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties @@ -6,8 +6,8 @@ org.eclipse.jetty.LEVEL=WARN # org.eclipse.jetty.websocket.LEVEL=WARN # org.eclipse.jetty.websocket.common.io.LEVEL=DEBUG -org.eclipse.jetty.websocket.common.WebSocketSession.LEVEL=DEBUG -org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG +# org.eclipse.jetty.websocket.common.WebSocketSession.LEVEL=DEBUG +# org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG ### Show state changes on BrowserDebugTool # -- LEAVE THIS AT DEBUG LEVEL -- diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java index a4b2f2da0bd..3564a2dc28c 100644 --- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java +++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.websocket.api; import java.io.IOException; +import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.concurrent.Future; @@ -160,6 +161,13 @@ public interface RemoteEndpoint * @see #flush() */ void setBatchMode(BatchMode mode); + + /** + * Get the InetSocketAddress for the established connection. + * + * @return the InetSocketAddress for the established connection. (or null, if the connection is no longer established) + */ + InetSocketAddress getInetSocketAddress(); /** * Flushes messages that may have been batched by the implementation. diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java index 27afcd7559e..413fcd63b91 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/RemoteEndpointFactory.java @@ -19,9 +19,10 @@ package org.eclipse.jetty.websocket.common; import org.eclipse.jetty.websocket.api.BatchMode; +import org.eclipse.jetty.websocket.api.RemoteEndpoint; import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; public interface RemoteEndpointFactory { - WebSocketRemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode); + RemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode); } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java index 6c27acfa769..4211d10bb0a 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java @@ -216,9 +216,15 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint } } - + /** + * Get the InetSocketAddress for the established connection. + * + * @return the InetSocketAddress for the established connection. (or null, if the connection is no longer established) + */ public InetSocketAddress getInetSocketAddress() { + if(connection == null) + return null; return connection.getRemoteAddress(); } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java index 8b70367531d..cd4d14e0c04 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java @@ -75,7 +75,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem private RemoteEndpointFactory remoteEndpointFactory; private String protocolVersion; private Map parameterMap = new HashMap<>(); - private WebSocketRemoteEndpoint remote; + private RemoteEndpoint remote; private IncomingFrames incomingHandler; private OutgoingFrames outgoingHandler; private WebSocketPolicy policy; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java index 333e32377c7..9df0fbb24c0 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java @@ -29,6 +29,7 @@ import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; import org.eclipse.jetty.websocket.common.frames.TextFrame; +import org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession; import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession; import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope; import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope; @@ -67,12 +68,12 @@ public class EventDriverTest } @Test - public void testAdapter_ConnectClose() throws IOException + public void testAdapter_ConnectClose() throws Exception { AdapterConnectCloseSocket socket = new AdapterConnectCloseSocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.open(); driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -84,12 +85,12 @@ public class EventDriverTest } @Test - public void testAnnotated_ByteArray() throws IOException + public void testAnnotated_ByteArray() throws Exception { AnnotatedBinaryArraySocket socket = new AnnotatedBinaryArraySocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.open(); driver.incomingFrame(makeBinaryFrame("Hello World",true)); @@ -103,12 +104,12 @@ public class EventDriverTest } @Test - public void testAnnotated_Error() throws IOException + public void testAnnotated_Error() throws Exception { AnnotatedTextSocket socket = new AnnotatedTextSocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.open(); driver.incomingError(new WebSocketException("oof")); @@ -122,12 +123,12 @@ public class EventDriverTest } @Test - public void testAnnotated_Frames() throws IOException + public void testAnnotated_Frames() throws Exception { AnnotatedFramesSocket socket = new AnnotatedFramesSocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.open(); driver.incomingFrame(new PingFrame().setPayload("PING")); @@ -151,7 +152,7 @@ public class EventDriverTest AnnotatedBinaryStreamSocket socket = new AnnotatedBinaryStreamSocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.open(); driver.incomingFrame(makeBinaryFrame("Hello World",true)); @@ -170,7 +171,7 @@ public class EventDriverTest ListenerBasicSocket socket = new ListenerBasicSocket(); EventDriver driver = wrap(socket); - try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver)) + try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container,testname,driver)) { conn.start(); conn.open(); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/CloseableLocalWebSocketSession.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/CloseableLocalWebSocketSession.java new file mode 100644 index 00000000000..9ff78cffaef --- /dev/null +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/CloseableLocalWebSocketSession.java @@ -0,0 +1,57 @@ +// +// ======================================================================== +// 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 org.eclipse.jetty.websocket.common.io; + +import org.eclipse.jetty.websocket.common.events.EventDriver; +import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope; +import org.junit.rules.TestName; + +public class CloseableLocalWebSocketSession extends LocalWebSocketSession implements AutoCloseable +{ + public CloseableLocalWebSocketSession(WebSocketContainerScope containerScope, TestName testname, EventDriver driver) + { + super(containerScope, testname, driver); + // LifeCycle start + try + { + start(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + @Override + public void close() + { + // WebSocketSession.close(); + super.close(); + + // LifeCycle Stop + try + { + stop(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } +} diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java index 25b73a60483..f364cb97930 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java @@ -61,13 +61,14 @@ public class MessageOutputStreamTest private LocalWebSocketSession session; @After - public void closeSession() + public void closeSession() throws Exception { session.close(); + session.stop(); } @Before - public void setupSession() + public void setupSession() throws Exception { policy = WebSocketPolicy.newServerPolicy(); policy.setInputBufferSize(1024); @@ -91,6 +92,8 @@ public class MessageOutputStreamTest session.setPolicy(policy); // talk to our remote socket session.setOutgoingHandler(socketPipe); + // start session + session.start(); // open connection session.open(); } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java index b94357a08da..3d58434b5a8 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java @@ -59,13 +59,14 @@ public class MessageWriterTest private LocalWebSocketSession session; @After - public void closeSession() + public void closeSession() throws Exception { session.close(); + session.stop(); } @Before - public void setupSession() + public void setupSession() throws Exception { policy = WebSocketPolicy.newServerPolicy(); policy.setInputBufferSize(1024); @@ -89,6 +90,8 @@ public class MessageWriterTest session.setPolicy(policy); // talk to our remote socket session.setOutgoingHandler(socketPipe); + // start session + session.start(); // open connection session.open(); } diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketCloseTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketCloseTest.java index 1fea2cd8e66..f9dfe45e126 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketCloseTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketCloseTest.java @@ -18,8 +18,9 @@ package org.eclipse.jetty.websocket.server; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.Collection; @@ -38,7 +39,6 @@ import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.WebSocketSession; -import org.eclipse.jetty.websocket.common.events.AbstractEventDriver; import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.common.test.BlockheadClient; import org.eclipse.jetty.websocket.common.test.IBlockheadClient; @@ -257,7 +257,7 @@ public class WebSocketCloseTest { client.setProtocols("fastfail"); client.setTimeout(1,TimeUnit.SECONDS); - try (StacklessLogging scope = new StacklessLogging(AbstractEventDriver.class)) + try (StacklessLogging scope = new StacklessLogging(FastFailSocket.class, WebSocketSession.class)) { client.connect(); client.sendStandardRequest(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/AnnotatedRuntimeOnConnectSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/AnnotatedRuntimeOnConnectSocket.java index 2de44225008..b4020bad77f 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/AnnotatedRuntimeOnConnectSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/AnnotatedRuntimeOnConnectSocket.java @@ -39,11 +39,7 @@ public class AnnotatedRuntimeOnConnectSocket public void onWebSocketConnect(Session sess) { // Intentional runtime exception. - int[] arr = new int[5]; - for (int i = 0; i < 10; i++) - { - arr[i] = 222; - } + throw new RuntimeException("Intentional Exception from onWebSocketConnect"); } @OnWebSocketClose diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/ListenerRuntimeOnConnectSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/ListenerRuntimeOnConnectSocket.java index eefb6cafdb9..d8f08218769 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/ListenerRuntimeOnConnectSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/ListenerRuntimeOnConnectSocket.java @@ -37,11 +37,7 @@ public class ListenerRuntimeOnConnectSocket extends WebSocketAdapter super.onWebSocketConnect(sess); // Intentional runtime exception. - int[] arr = new int[5]; - for (int i = 0; i < 10; i++) - { - arr[i] = 222; - } + throw new RuntimeException("Intentional Exception from onWebSocketConnect"); } @Override diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/MisbehavingClassTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/MisbehavingClassTest.java index 326a38af9e1..4906bac3246 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/MisbehavingClassTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/MisbehavingClassTest.java @@ -18,8 +18,9 @@ package org.eclipse.jetty.websocket.server.misbehaving; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; import java.util.concurrent.TimeUnit; @@ -29,7 +30,7 @@ import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.WebSocketFrame; -import org.eclipse.jetty.websocket.common.events.AbstractEventDriver; +import org.eclipse.jetty.websocket.common.WebSocketSession; import org.eclipse.jetty.websocket.common.test.BlockheadClient; import org.eclipse.jetty.websocket.common.test.IBlockheadClient; import org.eclipse.jetty.websocket.server.SimpleServletServer; @@ -63,72 +64,70 @@ public class MisbehavingClassTest @Test public void testListenerRuntimeOnConnect() throws Exception { - try (IBlockheadClient client = new BlockheadClient(server.getServerUri())) + try (IBlockheadClient client = new BlockheadClient(server.getServerUri()); + StacklessLogging scope = new StacklessLogging(ListenerRuntimeOnConnectSocket.class, WebSocketSession.class)) { client.setProtocols("listener-runtime-connect"); client.setTimeout(1,TimeUnit.SECONDS); - try (StacklessLogging scope = new StacklessLogging(AbstractEventDriver.class)) - { - ListenerRuntimeOnConnectSocket socket = badSocketsServlet.listenerRuntimeConnect; - socket.reset(); - client.connect(); - client.sendStandardRequest(); - client.expectUpgradeResponse(); + ListenerRuntimeOnConnectSocket socket = badSocketsServlet.listenerRuntimeConnect; + socket.reset(); - EventQueue frames = client.readFrames(1,1,TimeUnit.SECONDS); - WebSocketFrame frame = frames.poll(); - assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); - CloseInfo close = new CloseInfo(frame); - assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.SERVER_ERROR)); + client.connect(); + client.sendStandardRequest(); + client.expectUpgradeResponse(); - client.write(close.asFrame()); // respond with close + EventQueue frames = client.readFrames(1,1,TimeUnit.SECONDS); + WebSocketFrame frame = frames.poll(); + assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); + CloseInfo close = new CloseInfo(frame); + assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.SERVER_ERROR)); - // ensure server socket got close event - assertThat("Close Latch",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true)); - assertThat("closeStatusCode",socket.closeStatusCode,is(StatusCode.SERVER_ERROR)); + client.write(close.asFrame()); // respond with close - // Validate errors - assertThat("socket.onErrors",socket.errors.size(),is(1)); - Throwable cause = socket.errors.pop(); - assertThat("Error type",cause,instanceOf(ArrayIndexOutOfBoundsException.class)); - } + // ensure server socket got close event + assertThat("Close Latch",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true)); + assertThat("closeStatusCode",socket.closeStatusCode,is(StatusCode.SERVER_ERROR)); + + // Validate errors + assertThat("socket.onErrors",socket.errors.size(),is(1)); + Throwable cause = socket.errors.pop(); + assertThat("Error type",cause,instanceOf(RuntimeException.class)); } } @Test public void testAnnotatedRuntimeOnConnect() throws Exception { - try (IBlockheadClient client = new BlockheadClient(server.getServerUri())) + try (IBlockheadClient client = new BlockheadClient(server.getServerUri()); + StacklessLogging scope = new StacklessLogging(AnnotatedRuntimeOnConnectSocket.class, WebSocketSession.class)) { client.setProtocols("annotated-runtime-connect"); client.setTimeout(1,TimeUnit.SECONDS); - try (StacklessLogging scope = new StacklessLogging(AbstractEventDriver.class)) - { - AnnotatedRuntimeOnConnectSocket socket = badSocketsServlet.annotatedRuntimeConnect; - socket.reset(); - client.connect(); - client.sendStandardRequest(); - client.expectUpgradeResponse(); + AnnotatedRuntimeOnConnectSocket socket = badSocketsServlet.annotatedRuntimeConnect; + socket.reset(); - EventQueue frames = client.readFrames(1,1,TimeUnit.SECONDS); - WebSocketFrame frame = frames.poll(); - assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); - CloseInfo close = new CloseInfo(frame); - assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.SERVER_ERROR)); + client.connect(); + client.sendStandardRequest(); + client.expectUpgradeResponse(); - client.write(close.asFrame()); // respond with close + EventQueue frames = client.readFrames(1,1,TimeUnit.SECONDS); + WebSocketFrame frame = frames.poll(); + assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); + CloseInfo close = new CloseInfo(frame); + assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.SERVER_ERROR)); - // ensure server socket got close event - assertThat("Close Latch",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true)); - assertThat("closeStatusCode",socket.closeStatusCode,is(StatusCode.SERVER_ERROR)); + client.write(close.asFrame()); // respond with close - // Validate errors - assertThat("socket.onErrors",socket.errors.size(),is(1)); - Throwable cause = socket.errors.pop(); - assertThat("Error type",cause,instanceOf(ArrayIndexOutOfBoundsException.class)); - } + // ensure server socket got close event + assertThat("Close Latch",socket.closeLatch.await(1,TimeUnit.SECONDS),is(true)); + assertThat("closeStatusCode",socket.closeStatusCode,is(StatusCode.SERVER_ERROR)); + + // Validate errors + assertThat("socket.onErrors",socket.errors.size(),is(1)); + Throwable cause = socket.errors.pop(); + assertThat("Error type",cause,instanceOf(RuntimeException.class)); } } } From a8f25b550ffb2eba4fce168e81f3e8e6490972f3 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 6 Jun 2016 21:28:51 +0200 Subject: [PATCH 15/21] Fixes #487 - JDK 9 build compatibility. Fixes #306 - Merge jetty-parent into jetty-project. - Removed jetty.parent dependency, moving all relevant sections to jetty.project's pom.xml. - Introduced profiles for JDK 8 only modules and configuration, and for JDK 9 only modules and configurations. - Major cleanup of pom.xml files. - All Maven Plugin now declared in alphabetical order in pluginManagement section of jetty.project's pom.xml. --- apache-jsp/pom.xml | 27 +- examples/async-rest/pom.xml | 3 +- examples/embedded/pom.xml | 1 - examples/pom.xml | 3 +- header-template.txt | 2 +- jetty-alpn/jetty-alpn-server/pom.xml | 1 - jetty-cdi/test-cdi-webapp/pom.xml | 1 - jetty-documentation/pom.xml | 17 - jetty-http2/http2-alpn-tests/pom.xml | 75 +- .../http2-http-client-transport/pom.xml | 73 +- jetty-infinispan/pom.xml | 17 - jetty-osgi/jetty-osgi-boot-jsp/pom.xml | 23 - jetty-osgi/jetty-osgi-boot-warurl/pom.xml | 28 +- jetty-osgi/jetty-osgi-boot/pom.xml | 27 +- jetty-osgi/jetty-osgi-httpservice/pom.xml | 23 - jetty-osgi/test-jetty-osgi-context/pom.xml | 123 +- jetty-osgi/test-jetty-osgi-webapp/pom.xml | 108 +- jetty-osgi/test-jetty-osgi/pom.xml | 18 +- .../TestJettyOSGiBootWebAppAsService.java | 16 +- jetty-websocket/pom.xml | 51 +- jetty-websocket/websocket-common/pom.xml | 1 - pom.xml | 1040 +++++++++++------ tests/pom.xml | 1 - tests/test-continuation/pom.xml | 7 +- tests/test-http-client-transport/pom.xml | 74 +- tests/test-jmx/jmx-webapp/pom.xml | 6 - tests/test-quickstart/pom.xml | 3 +- tests/test-webapps/pom.xml | 1 - tests/test-webapps/test-jetty-webapp/pom.xml | 1 - tests/test-webapps/test-jndi-webapp/pom.xml | 9 +- tests/test-webapps/test-proxy-webapp/pom.xml | 1 - .../test-container-initializer/pom.xml | 23 - 32 files changed, 962 insertions(+), 842 deletions(-) diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml index 66ecfd4fcff..3916db1835c 100644 --- a/apache-jsp/pom.xml +++ b/apache-jsp/pom.xml @@ -21,7 +21,7 @@ Jetty-specific ServletContainerInitializer for Jasper - org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", + org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)" @@ -30,29 +30,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - @@ -67,7 +44,7 @@ jetty-server ${project.version} - + org.eclipse.jetty.toolchain diff --git a/examples/async-rest/pom.xml b/examples/async-rest/pom.xml index 3a3f023f0dd..52a426a2bca 100644 --- a/examples/async-rest/pom.xml +++ b/examples/async-rest/pom.xml @@ -3,8 +3,7 @@ org.eclipse.jetty.examples examples-parent 9.4.0-SNAPSHOT - ../pom.xml - + 4.0.0 org.eclipse.jetty example-async-rest diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml index 4d4c8af3a29..aef61743119 100644 --- a/examples/embedded/pom.xml +++ b/examples/embedded/pom.xml @@ -3,7 +3,6 @@ org.eclipse.jetty.examples examples-parent 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 org.eclipse.jetty diff --git a/examples/pom.xml b/examples/pom.xml index 230e23de74c..68b7ae52fd0 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -5,7 +5,6 @@ org.eclipse.jetty jetty-project 9.4.0-SNAPSHOT - ../pom.xml org.eclipse.jetty.examples examples-parent @@ -25,7 +24,7 @@ async-rest diff --git a/header-template.txt b/header-template.txt index 07cd15e8ee9..7756b0e88da 100644 --- a/header-template.txt +++ b/header-template.txt @@ -12,4 +12,4 @@ http://www.opensource.org/licenses/apache2.0.php You may elect to redistribute this code under either of these licenses. - ======================================================================== \ No newline at end of file + ======================================================================== diff --git a/jetty-alpn/jetty-alpn-server/pom.xml b/jetty-alpn/jetty-alpn-server/pom.xml index a6fc725bb46..80a0f425eb4 100644 --- a/jetty-alpn/jetty-alpn-server/pom.xml +++ b/jetty-alpn/jetty-alpn-server/pom.xml @@ -28,7 +28,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.7 parse-version diff --git a/jetty-cdi/test-cdi-webapp/pom.xml b/jetty-cdi/test-cdi-webapp/pom.xml index 8044dc39123..5fa23abfb82 100644 --- a/jetty-cdi/test-cdi-webapp/pom.xml +++ b/jetty-cdi/test-cdi-webapp/pom.xml @@ -52,7 +52,6 @@ org.apache.maven.plugins maven-assembly-plugin - 2.5.3 with-weld diff --git a/jetty-documentation/pom.xml b/jetty-documentation/pom.xml index ea21beb1a71..2518c076397 100644 --- a/jetty-documentation/pom.xml +++ b/jetty-documentation/pom.xml @@ -10,24 +10,12 @@ Jetty :: Documentation pom - UTF-8 - 1.5.3 ${project.build.directory}/current - - - - org.apache.felix - maven-bundle-plugin - 3.0.1 - - - maven-resources-plugin - 2.6 copy-assets @@ -52,7 +40,6 @@ org.asciidoctor asciidoctor-maven-plugin - ${asciidoctor.version} output-html @@ -83,7 +70,6 @@ com.agilejava.docbkx docbkx-maven-plugin - 2.0.14 html @@ -132,7 +118,6 @@ net.sf.docbook docbook-xml - 5.1b4-all resources zip @@ -154,7 +139,6 @@ maven-assembly-plugin - 2.6 src/main/assembly/html.xml @@ -210,7 +194,6 @@ org.asciidoctor asciidoctor-maven-plugin - ${asciidoctor.version} org.asciidoctor diff --git a/jetty-http2/http2-alpn-tests/pom.xml b/jetty-http2/http2-alpn-tests/pom.xml index 8a1521e4b40..ac3f7fc780c 100644 --- a/jetty-http2/http2-alpn-tests/pom.xml +++ b/jetty-http2/http2-alpn-tests/pom.xml @@ -14,40 +14,49 @@ ${project.groupId}.alpn.tests - - - - maven-dependency-plugin - - - copy - generate-resources - - copy - + + + jdk8 + + [1.8,1.9) + + + + + maven-dependency-plugin + + + copy + generate-resources + + copy + + + + + org.mortbay.jetty.alpn + alpn-boot + ${alpn.version} + jar + false + ${project.build.directory}/alpn + + + + + + + + maven-surefire-plugin - - - org.mortbay.jetty.alpn - alpn-boot - ${alpn.version} - jar - false - ${project.build.directory}/alpn - - + -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar + - - - - - maven-surefire-plugin - - -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar - - - - + + + + + @@ -85,5 +94,5 @@ test - + diff --git a/jetty-http2/http2-http-client-transport/pom.xml b/jetty-http2/http2-http-client-transport/pom.xml index e5aab8ad053..7197df72668 100644 --- a/jetty-http2/http2-http-client-transport/pom.xml +++ b/jetty-http2/http2-http-client-transport/pom.xml @@ -14,40 +14,49 @@ ${project.groupId}.client.http - - - - maven-dependency-plugin - - - copy - generate-resources - - copy - + + + jdk8 + + [1.8,1.9) + + + + + maven-dependency-plugin + + + copy + generate-resources + + copy + + + + + org.mortbay.jetty.alpn + alpn-boot + ${alpn.version} + jar + false + ${project.build.directory}/alpn + + + + + + + + maven-surefire-plugin - - - org.mortbay.jetty.alpn - alpn-boot - ${alpn.version} - jar - false - ${project.build.directory}/alpn - - + -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar + - - - - - maven-surefire-plugin - - -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar - - - - + + + + + diff --git a/jetty-infinispan/pom.xml b/jetty-infinispan/pom.xml index 37c7f33cac6..2a5cb160a3a 100644 --- a/jetty-infinispan/pom.xml +++ b/jetty-infinispan/pom.xml @@ -32,23 +32,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml index 578c2ad42e9..fed4cedb270 100644 --- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml @@ -46,29 +46,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - org.apache.felix maven-bundle-plugin diff --git a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml index 6c3bf6185a8..4a0019d4480 100644 --- a/jetty-osgi/jetty-osgi-boot-warurl/pom.xml +++ b/jetty-osgi/jetty-osgi-boot-warurl/pom.xml @@ -3,7 +3,6 @@ org.eclipse.jetty.osgi jetty-osgi-project 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 jetty-osgi-boot-warurl @@ -19,36 +18,13 @@ jetty-util - org.eclipse.osgi - org.eclipse.osgi + org.eclipse.osgi + org.eclipse.osgi - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - org.apache.felix maven-bundle-plugin diff --git a/jetty-osgi/jetty-osgi-boot/pom.xml b/jetty-osgi/jetty-osgi-boot/pom.xml index d2bb7fd340e..e3c1d125308 100644 --- a/jetty-osgi/jetty-osgi-boot/pom.xml +++ b/jetty-osgi/jetty-osgi-boot/pom.xml @@ -30,8 +30,8 @@ jetty-jmx - org.eclipse.osgi - org.eclipse.osgi + org.eclipse.osgi + org.eclipse.osgi org.eclipse.osgi @@ -62,29 +62,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - org.apache.felix maven-bundle-plugin diff --git a/jetty-osgi/jetty-osgi-httpservice/pom.xml b/jetty-osgi/jetty-osgi-httpservice/pom.xml index ad95aa1592d..41bb8e078b5 100644 --- a/jetty-osgi/jetty-osgi-httpservice/pom.xml +++ b/jetty-osgi/jetty-osgi-httpservice/pom.xml @@ -56,29 +56,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - org.apache.felix maven-bundle-plugin diff --git a/jetty-osgi/test-jetty-osgi-context/pom.xml b/jetty-osgi/test-jetty-osgi-context/pom.xml index 561adbaf7a3..2d9c2799980 100644 --- a/jetty-osgi/test-jetty-osgi-context/pom.xml +++ b/jetty-osgi/test-jetty-osgi-context/pom.xml @@ -19,78 +19,55 @@ ${project.version} - org.eclipse.osgi - org.eclipse.osgi - provided + org.eclipse.osgi + org.eclipse.osgi + provided - org.eclipse.osgi - org.eclipse.osgi.services - provided + org.eclipse.osgi + org.eclipse.osgi.services + provided - org.eclipse.jetty.toolchain - jetty-schemas + org.eclipse.jetty.toolchain + jetty-schemas - - - - src/main/resources - - - src/main/context - - + + + + src/main/resources + + + src/main/context + + - - - org.apache.maven.plugins - maven-deploy-plugin - - - true - - - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.eclipse.jetty.osgi.testcontext;singleton:=true - Jetty OSGi Test Context - com.acme.osgi.Activator - J2SE-1.5 - - <_nouses>true - + + + org.apache.maven.plugins + maven-deploy-plugin + + + true + + + + org.apache.felix + maven-bundle-plugin + true + + + org.eclipse.jetty.osgi.testcontext;singleton:=true + Jetty OSGi Test Context + com.acme.osgi.Activator + J2SE-1.5 + + <_nouses>true + javax.servlet;version="[3.1,3.2)", javax.servlet.resources;version="[3.1,3.2)", org.osgi.framework, @@ -100,17 +77,17 @@ org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.slf4j;resolution:=optional, - org.slf4j.spi;resolution:=optional, + org.slf4j.spi;resolution:=optional, org.slf4j.helpers;resolution:=optional, org.xml.sax, org.xml.sax.helpers, * - - org.eclipse.jetty.*;version="[9.1,10.0)" - - - - - - + + org.eclipse.jetty.*;version="[9.1,10.0)" + + + + + + diff --git a/jetty-osgi/test-jetty-osgi-webapp/pom.xml b/jetty-osgi/test-jetty-osgi-webapp/pom.xml index eeacbb70a59..2af5c55fca1 100644 --- a/jetty-osgi/test-jetty-osgi-webapp/pom.xml +++ b/jetty-osgi/test-jetty-osgi-webapp/pom.xml @@ -3,7 +3,6 @@ org.eclipse.jetty.osgi jetty-osgi-project 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-osgi-webapp @@ -19,70 +18,41 @@ jetty-webapp - org.eclipse.osgi - org.eclipse.osgi - provided + org.eclipse.osgi + org.eclipse.osgi + provided - org.eclipse.osgi - org.eclipse.osgi.services - provided + org.eclipse.osgi + org.eclipse.osgi.services + provided - - - - src/main/resources - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - - true - - - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - test-jar - - test-jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.eclipse.jetty.osgi.testapp;singleton:=true - Jetty OSGi Test WebApp - com.acme.osgi.Activator - J2SE-1.5 - - + + + + org.apache.maven.plugins + maven-deploy-plugin + + + true + + + + org.apache.felix + maven-bundle-plugin + true + + + org.eclipse.jetty.osgi.testapp;singleton:=true + Jetty OSGi Test WebApp + com.acme.osgi.Activator + J2SE-1.5 + + org.osgi.framework, org.osgi.service.cm;version="1.2.0", org.osgi.service.packageadmin, @@ -90,17 +60,17 @@ org.osgi.service.url;version="1.0.0", org.osgi.util.tracker;version="1.3.0", org.slf4j;resolution:=optional, - org.slf4j.spi;resolution:=optional, + org.slf4j.spi;resolution:=optional, org.slf4j.helpers;resolution:=optional, org.xml.sax, org.xml.sax.helpers, * - - org.eclipse.jetty.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))" - - - - - - + + org.eclipse.jetty.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))" + + + + + + diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 4b574b01a84..d79471ac4e6 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -3,7 +3,6 @@ org.eclipse.jetty.osgi jetty-osgi-project 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 test-jetty-osgi @@ -20,7 +19,6 @@ - org.ops4j.pax.exam pax-exam @@ -33,7 +31,6 @@ ${exam.version} test - @@ -42,7 +39,7 @@ ${exam.version} test - + org.ops4j.pax.exam pax-exam-junit4 @@ -95,7 +92,6 @@ test - org.eclipse.jetty.osgi @@ -255,7 +251,7 @@ org.eclipse.jetty jetty-util - ${project.version} + ${project.version} runtime @@ -334,7 +330,6 @@ runtime - org.eclipse.jetty jetty-plus @@ -366,7 +361,6 @@ test - org.eclipse.jetty.tests test-mock-resources @@ -390,7 +384,14 @@ jetty-test-helper test + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + test + + @@ -454,4 +455,5 @@ + diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java index ee9904c5e18..5777e3bfac7 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestJettyOSGiBootWebAppAsService.java @@ -22,6 +22,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javax.inject.Inject; import org.eclipse.jetty.client.HttpClient; @@ -49,11 +50,11 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty; /** * TestJettyOSGiBootWebAppAsService - * + * * Tests deployment of a WebAppContext as an osgi Service. - * + * * Tests the ServiceWebAppProvider. - * + * * Pax-Exam to make sure the jetty-osgi-boot can be started along with the * httpservice web-bundle. Then make sure we can deploy an OSGi service on the * top of this. @@ -76,7 +77,7 @@ public class TestJettyOSGiBootWebAppAsService options.add(CoreOptions.systemPackages("com.sun.org.apache.xalan.internal.res","com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xml.internal.utils", "com.sun.org.apache.xpath.internal", "com.sun.org.apache.xpath.internal.jaxp", "com.sun.org.apache.xpath.internal.objects")); - + options.addAll(TestJettyOSGiBootCore.coreJettyDependencies()); options.addAll(Arrays.asList(options(systemProperty("pax.exam.logging").value("none")))); options.addAll(Arrays.asList(options(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(LOG_LEVEL)))); @@ -85,14 +86,13 @@ public class TestJettyOSGiBootWebAppAsService options.addAll(jspDependencies()); return options.toArray(new Option[options.size()]); } - public static List

header-template.txt
true true true - ${project.inceptionYear}-2016 + ${project.inceptionYear}-2016 DOUBLESLASH_STYLE @@ -250,26 +273,65 @@ manifest - + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + set-osgi-version + validate + + parse-version + + - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - + org.eclipse.jetty.toolchain + jetty-version-maven-plugin + + + attach-version + process-resources + + attach-version-text + + + + + - org.eclipse.jetty.toolchain - jetty-version-maven-plugin - 2.0 + org.apache.maven.plugins + maven-assembly-plugin + 2.6 + + + org.eclipse.jetty.toolchain + jetty-assembly-descriptors + 1.0 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 org.apache.maven.plugins @@ -279,11 +341,18 @@ 10 + + org.apache.maven.plugins + maven-enforcer-plugin + 1.4.1 + org.apache.maven.plugins maven-jar-plugin + 3.0.0 + ${project.build.outputDirectory}/META-INF/MANIFEST.MF ${project.version} Eclipse.org - Jetty @@ -292,83 +361,10 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.19 - - -showversion -Xmx1g -Xms1g -XX:+PrintGCDetails - false - random - - - - java.io.tmpdir - ${project.build.directory} - - - - - - org.apache.felix - maven-bundle-plugin - true - - - jar - maven-plugin - - - ${bundle-symbolic-name} - Jetty module for ${project.name} - JavaSE-1.8 - ${jetty.url} - Eclipse Jetty Project - . - ${bundle-symbolic-name}.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" - Copyright (c) 2008-2016 Mort Bay Consulting Pty. Ltd. - javax.servlet*;version="[2.6.0,3.2)",javax.transaction*;version="[1.1,1.3)",org.eclipse.jetty*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",* - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - org.eclipse.jetty.toolchain - jetty-assembly-descriptors - 1.0 - - - - - org.codehaus.mojo - findbugs-maven-plugin - - true - true - Max - org.eclipse.jetty.* - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-jxr-plugin - org.apache.maven.plugins maven-javadoc-plugin - 2.8 + 2.10.3 true true @@ -455,118 +451,296 @@ org.apache.maven.plugins - maven-pmd-plugin - 3.4 + maven-jxr-plugin + 2.5 - org.neo4j.build.plugins - clirr-maven-plugin - 1.0.1 + org.apache.maven.plugins + maven-pmd-plugin + 3.6 + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + + org.apache.maven.plugins + maven-remote-resources-plugin + 1.5 + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.0 + + + org.apache.maven.plugins + maven-site-plugin + 3.5.1 + + + org.apache.maven.plugins + maven-source-plugin + 3.0.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 - clirr-report.html - ${project.build.directory}/clirr-report.xml - true - true - false - true - info - 9.3.8.v20160314 - false + -showversion -Xmx1g -Xms1g -XX:+PrintGCDetails + false + + + java.io.tmpdir + ${project.build.directory} + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + com.agilejava.docbkx + docbkx-maven-plugin + 2.0.14 + + + com.mycila + license-maven-plugin + 2.11 + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + jar + maven-plugin + + + ${bundle-symbolic-name} + Jetty module for ${project.name} + JavaSE-1.8 + ${jetty.url} + Eclipse Jetty Project + . + ${bundle-symbolic-name}.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" + Copyright (c) 2008-2016 Mort Bay Consulting Pty. Ltd. + javax.servlet*;version="[2.6.0,3.2)",javax.transaction*;version="[1.1,1.3)",org.eclipse.jetty*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))",* + + + + + org.asciidoctor + asciidoctor-maven-plugin + 1.5.3 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + org.codehaus.mojo + findbugs-maven-plugin + 3.0.3 + + true + true + Max + org.eclipse.jetty.* + + + + org.eclipse.jetty.toolchain + jetty-version-maven-plugin + 2.0 + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.eclipse.jetty.toolchain + jetty-version-maven-plugin + [1.0.3,) + + attach-version-text + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.1,) + + unpack + unpack-dependencies + copy-dependencies + copy + + + + + + + + + org.ops4j.pax.exam + maven-paxexam-plugin + + [1.2.0,) + + + + generate-depends-file + + generate-config + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + [1.4,) + + run + + + + + + + + + org.sonatype.maven.plugin + emma-maven-plugin + [1.1,) + + instrument + + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + [2.5,) + + default-descriptor + descriptor + xdoc + helpmojo + + + + + + + + + org.codehaus.mojo + native-maven-plugin + [1.0-alpha-7,) + + initialize + javah + compile + unzipinc + link + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + [2.8,) + + jar + + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + [2.5,) + + check + + + + + + + + + org.apache.maven.plugins + maven-remote-resources-plugin + [1.0,) + + process + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + [1.0,) + + enforce + + + + + + + + - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.1 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8 - - 512m - true - true - true - - - - org.apache.maven.plugins - maven-pmd-plugin - 2.7.1 - - 1.7 - - jetty/pmd_ruleset.xml - - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.5.2 - - - - - jetty-ant - jetty-util - jetty-jmx - jetty-io - jetty-http - jetty-http2 - jetty-continuation - jetty-server - jetty-xml - jetty-security - jetty-servlet - jetty-webapp - jetty-fcgi - jetty-websocket - jetty-servlets - jetty-util-ajax - apache-jsp - apache-jstl - jetty-maven-plugin - jetty-jspc-maven-plugin - jetty-deploy - jetty-start - jetty-plus - jetty-annotations - jetty-jndi - jetty-jaas - jetty-cdi - jetty-spring - jetty-client - jetty-proxy - jetty-jaspi - jetty-rewrite - jetty-nosql - jetty-infinispan - jetty-gcloud - jetty-memcached - jetty-unixsocket - tests - examples - jetty-quickstart - jetty-distribution - jetty-runner - jetty-monitor - jetty-http-spi - jetty-osgi - jetty-alpn - jetty-documentation - - - @@ -594,68 +768,56 @@ asm-commons 5.0.1 - org.eclipse.jetty.orbit javax.security.auth.message 1.0.0.v201108011116 - org.eclipse.jetty.toolchain jetty-schemas 3.1 - org.mortbay.jasper apache-jsp ${jsp.version} - org.eclipse.jdt.core.compiler ecj 4.4.2 - - - - org.apache.taglibs - taglibs-standard-impl - 1.2.5 - - - + + + org.apache.taglibs + taglibs-standard-impl + 1.2.5 + + org.apache.taglibs taglibs-standard-spec 1.2.5 - - org.eclipse.jetty.orbit javax.activation 1.1.0.v201105071233 provided - org.eclipse.jetty.orbit javax.mail.glassfish 1.4.1.v201005082020 - javax.transaction javax.transaction-api 1.2 provided - - org.apache.maven @@ -715,6 +877,7 @@ + + + jdk8 + + [1.8,1.9) + + + jetty-documentation + + + + + + org.neo4j.build.plugins + clirr-maven-plugin + 1.0.1 + + clirr-report.html + ${project.build.directory}/clirr-report.xml + true + true + false + true + info + 9.3.8.v20160314 + false + + + + + + + + jdk9 + + [1.9,) + + + + apache-plugins-snapshots + https://repository.apache.org/content/groups/snapshots + + true + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0-SNAPSHOT + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0-SNAPSHOT + + + + + config @@ -762,12 +987,50 @@ - maven-compiler-plugin + true + org.apache.maven.plugins + maven-deploy-plugin - 1.8 - 1.8 + true + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + @@ -803,30 +1066,6 @@ - - maven-3 - - - - ${basedir} - - - - - - maven-site-plugin - - - attach-descriptor - - attach-descriptor - - - - - - - aggregate-site @@ -1080,4 +1319,109 @@ + + + github + https://github.com/eclipse/jetty.project/issues + + + + + Jetty Developer Mailing List + https://dev.eclipse.org/mhonarc/lists/jetty-dev/maillist.html + https://dev.eclipse.org/mailman/listinfo/jetty-dev + https://dev.eclipse.org/mailman/listinfo/jetty-dev + + + Jetty Commit Mailing List + https://dev.eclipse.org/mhonarc/lists/jetty-commit/maillist.html + https://dev.eclipse.org/mailman/listinfo/jetty-commit + https://dev.eclipse.org/mailman/listinfo/jetty-commit + + + Jetty Users Mailing List + https://dev.eclipse.org/mhonarc/lists/jetty-users/maillist.html + https://dev.eclipse.org/mailman/listinfo/jetty-users + https://dev.eclipse.org/mailman/listinfo/jetty-users + + + Jetty Announce Mailing List + https://dev.eclipse.org/mhonarc/lists/jetty-announce/maillist.html + https://dev.eclipse.org/mailman/listinfo/jetty-announce + https://dev.eclipse.org/mailman/listinfo/jetty-announce + + + + + + gregw + Greg Wilkins + gregw@webtide.com + Webtide, LLC + https://webtide.com + 10 + + + janb + Jan Bartel + janb@webtide.com + Webtide, LLC + https://webtide.com + 10 + + + jesse + Jesse McConnell + jesse.mcconnell@gmail.com + Webtide, LLC + https://webtide.com + -6 + + + joakime + Joakim Erdfelt + joakim.erdfelt@gmail.com + Webtide, LLC + https://webtide.com + -7 + + + sbordet + Simone Bordet + simone.bordet@gmail.com + Webtide, LLC + https://webtide.com + 1 + + + djencks + David Jencks + david.a.jencks@gmail.com + IBM + -8 + + + + + Webtide + https://webtide.com + + + + + oss.sonatype.org + Jetty Staging Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + oss.sonatype.org + Jetty Snapshot Repository + https://oss.sonatype.org/content/repositories/jetty-snapshots/ + + + jetty.eclipse.website + scp://build.eclipse.org:/home/data/httpd/download.eclipse.org/jetty/${project.version}/ + + + diff --git a/tests/pom.xml b/tests/pom.xml index 4db9da434d8..c55d6e3c544 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -5,7 +5,6 @@ org.eclipse.jetty jetty-project 9.4.0-SNAPSHOT - ../pom.xml org.eclipse.jetty.tests tests-parent diff --git a/tests/test-continuation/pom.xml b/tests/test-continuation/pom.xml index 36a865ec97c..cdcf94ba6f2 100644 --- a/tests/test-continuation/pom.xml +++ b/tests/test-continuation/pom.xml @@ -4,7 +4,6 @@ org.eclipse.jetty.tests tests-parent 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 test-continuation @@ -28,11 +27,11 @@ - org.eclipse.jetty + org.eclipse.jetty jetty-servlet ${project.version} provided - + org.eclipse.jetty jetty-continuation @@ -43,6 +42,6 @@ jetty-test-helper compile - + diff --git a/tests/test-http-client-transport/pom.xml b/tests/test-http-client-transport/pom.xml index ec608ac8bc1..ca0ea2a2225 100644 --- a/tests/test-http-client-transport/pom.xml +++ b/tests/test-http-client-transport/pom.xml @@ -15,38 +15,52 @@ ${project.groupId}.client.http + + + jdk8 + + [1.8,1.9) + + + + + maven-dependency-plugin + + + copy + generate-resources + + copy + + + + + org.mortbay.jetty.alpn + alpn-boot + ${alpn.version} + jar + false + ${project.build.directory}/alpn + + + + + + + + maven-surefire-plugin + + -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar + + + + + + + + - - maven-dependency-plugin - - - copy - generate-resources - - copy - - - - - org.mortbay.jetty.alpn - alpn-boot - ${alpn.version} - jar - false - ${project.build.directory}/alpn - - - - - - - - maven-surefire-plugin - - -Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar - - org.apache.maven.plugins maven-deploy-plugin diff --git a/tests/test-jmx/jmx-webapp/pom.xml b/tests/test-jmx/jmx-webapp/pom.xml index 6e2babb5b5c..237924e08f9 100644 --- a/tests/test-jmx/jmx-webapp/pom.xml +++ b/tests/test-jmx/jmx-webapp/pom.xml @@ -37,12 +37,6 @@ true - - org.apache.maven.plugins - maven-war-plugin - - - diff --git a/tests/test-quickstart/pom.xml b/tests/test-quickstart/pom.xml index 6b051ee0eb4..e0c26b10f60 100644 --- a/tests/test-quickstart/pom.xml +++ b/tests/test-quickstart/pom.xml @@ -4,7 +4,6 @@ org.eclipse.jetty.tests tests-parent 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 org.eclipse.jetty @@ -103,7 +102,7 @@ org.eclipse.jetty.toolchain jetty-test-helper - + diff --git a/tests/test-webapps/pom.xml b/tests/test-webapps/pom.xml index 463a0119535..29deb7bb499 100644 --- a/tests/test-webapps/pom.xml +++ b/tests/test-webapps/pom.xml @@ -5,7 +5,6 @@ org.eclipse.jetty.tests tests-parent 9.4.0-SNAPSHOT - ../pom.xml test-webapps-parent Jetty Tests :: WebApps :: Parent diff --git a/tests/test-webapps/test-jetty-webapp/pom.xml b/tests/test-webapps/test-jetty-webapp/pom.xml index 8bd0b1cda44..bb64ac7f4bc 100644 --- a/tests/test-webapps/test-jetty-webapp/pom.xml +++ b/tests/test-webapps/test-jetty-webapp/pom.xml @@ -4,7 +4,6 @@ org.eclipse.jetty.tests test-webapps-parent 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 org.eclipse.jetty diff --git a/tests/test-webapps/test-jndi-webapp/pom.xml b/tests/test-webapps/test-jndi-webapp/pom.xml index 86a19a58ff3..644a4f93934 100644 --- a/tests/test-webapps/test-jndi-webapp/pom.xml +++ b/tests/test-webapps/test-jndi-webapp/pom.xml @@ -92,18 +92,11 @@ src/main/assembly/config.xml - + - - org.apache.maven.plugins - maven-war-plugin - - - org.eclipse.jetty jetty-maven-plugin diff --git a/tests/test-webapps/test-proxy-webapp/pom.xml b/tests/test-webapps/test-proxy-webapp/pom.xml index ec11b5b9c38..d41ab52e363 100644 --- a/tests/test-webapps/test-proxy-webapp/pom.xml +++ b/tests/test-webapps/test-proxy-webapp/pom.xml @@ -4,7 +4,6 @@ org.eclipse.jetty.tests test-webapps-parent 9.4.0-SNAPSHOT - ../pom.xml 4.0.0 org.eclipse.jetty diff --git a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml index b6ac53f631c..7e921553f6d 100644 --- a/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml +++ b/tests/test-webapps/test-servlet-spec/test-container-initializer/pom.xml @@ -13,29 +13,6 @@ - - maven-compiler-plugin - - false - - - - org.apache.maven.plugins - maven-jar-plugin - - - artifact-jar - - jar - - - - - - target/classes/META-INF/MANIFEST.MF - - - org.apache.felix maven-bundle-plugin From 40af755251f2ff9a473f49b7f209279cacdb7ce2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 7 Jun 2016 10:44:33 +1000 Subject: [PATCH 16/21] restructure failing test to better analyse failure --- .../jetty/server/LocalAsyncContextTest.java | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java index 8049c43fa08..d27c3353967 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import javax.servlet.AsyncContext; @@ -62,8 +63,8 @@ public class LocalAsyncContextTest _server.setHandler(session); _server.start(); - __completed.set(0); - __completed1.set(0); + __completed.set(null); + __completed1.set(null); } protected Connector initConnector() @@ -88,8 +89,8 @@ public class LocalAsyncContextTest _handler.setCompleteAfter(-1); response=process(null); check(response,"TIMEOUT"); - spinAssertEquals(1,__completed::get); - spinAssertEquals(1,__completed1::get); + spinAssertEquals(1,()->{return __completed.get()==null?0:1;}); + spinAssertEquals(1,()->{return __completed1.get()==null?0:1;}); } @Test @@ -210,9 +211,6 @@ public class LocalAsyncContextTest { String response; - __completed.set(0); - __completed1.set(0); - _handler.setRead(0); _handler.setSuspendFor(1000); _handler.setResumeAfter(100); @@ -222,8 +220,8 @@ public class LocalAsyncContextTest _handler.setCompleteAfter2(-1); response=process(null); check(response,"STARTASYNC","DISPATCHED","startasync","STARTASYNC","DISPATCHED"); - spinAssertEquals(1,__completed::get); - spinAssertEquals(0,__completed1::get); + spinAssertEquals(1,()->{return __completed.get()==null?0:1;}); + spinAssertEquals(0,()->{return __completed1.get()==null?0:1;}); } @@ -544,21 +542,35 @@ public class LocalAsyncContextTest } } - static AtomicInteger __completed = new AtomicInteger(); - static AtomicInteger __completed1 = new AtomicInteger(); + static AtomicReference __completed = new AtomicReference<>(); + static AtomicReference __completed1 = new AtomicReference<>(); private static AsyncListener __asyncListener = new AsyncListener() { @Override public void onComplete(AsyncEvent event) throws IOException { - __completed.incrementAndGet(); + Throwable complete = new Throwable(); + if (!__completed.compareAndSet(null,complete)) + { + __completed.get().printStackTrace(); + complete.printStackTrace(); + __completed.set(null); + throw new IllegalStateException(); + } } @Override public void onError(AsyncEvent event) throws IOException { - __completed.incrementAndGet(); + Throwable complete = new Throwable(); + if (!__completed.compareAndSet(null,complete)) + { + __completed.get().printStackTrace(); + complete.printStackTrace(); + __completed.set(null); + throw new IllegalStateException(); + } } @Override @@ -581,13 +593,29 @@ public class LocalAsyncContextTest @Override public void onComplete(AsyncEvent event) throws IOException { - __completed1.incrementAndGet(); + Throwable complete = new Throwable(); + if (!__completed1.compareAndSet(null,complete)) + { + __completed1.get().printStackTrace(); + complete.printStackTrace(); + __completed1.set(null); + throw new IllegalStateException(); + } } @Override public void onError(AsyncEvent event) throws IOException { + Throwable complete = new Throwable(); + if (!__completed1.compareAndSet(null,complete)) + { + __completed1.get().printStackTrace(); + complete.printStackTrace(); + __completed1.set(null); + throw new IllegalStateException(); + } } + @Override public void onStartAsync(AsyncEvent event) throws IOException { From 1d3816fdc5d65173f69a85d9f6fb865903ee8478 Mon Sep 17 00:00:00 2001 From: WalkerWatch Date: Mon, 6 Jun 2016 21:20:11 -0400 Subject: [PATCH 17/21] Chapter 10 clean up and link fixes. Signed-off-by: WalkerWatch --- .../session-clustering-gcloud-datastore.adoc | 159 +++++---------- .../session-clustering-infinispan.adoc | 142 +++++-------- .../sessions/session-clustering-jdbc.adoc | 147 +++++--------- .../sessions/session-clustering-mongodb.adoc | 188 ++++++------------ .../setting-session-characteristics.adoc | 58 ++---- .../sessions/using-persistent-sessions.adoc | 52 ++--- 6 files changed, 252 insertions(+), 494 deletions(-) diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-gcloud-datastore.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-gcloud-datastore.adoc index a6175fd5cdb..ab37fe2ed54 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-gcloud-datastore.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-gcloud-datastore.adoc @@ -17,144 +17,97 @@ [[session-clustering-gcloud-datastore]] === Session Clustering with Google Cloud Datastore -Jetty can support session clustering by persisting sessions to -https://cloud.google.com/datastore/docs/concepts/overview[Google Cloud -Datastore]. Each Jetty instance locally caches sessions for which it has -received requests, writing any changes to the session through to the -Datastore as the request exits the server. Sessions must obey the -Serialization contract, and servlets must call the -Session.setAttribute() method to ensure that changes are persisted. +Jetty can support session clustering by persisting sessions to https://cloud.google.com/datastore/docs/concepts/overview[Google Cloud Datastore]. +Each Jetty instance locally caches sessions for which it has received requests, writing any changes to the session through to the Datastore as the request exits the server. +Sessions must obey the Serialization contract, and servlets must call the `Session.setAttribute()` method to ensure that changes are persisted. -The persistent session mechanism works in conjunction with a load -balancer that supports stickiness. Stickiness can be based on various -data items, such as source IP address or characteristics of the session -ID or a load-balancer specific mechanism. For those load balancers that -examine the session ID, the Jetty persistent session mechanism appends a -node ID to the session ID, which can be used for routing. +The persistent session mechanism works in conjunction with a load balancer that supports stickiness. +Stickiness can be based on various data items, such as source IP address or characteristics of the session ID or a load-balancer specific mechanism. +For those load balancers that examine the session ID, the Jetty persistent session mechanism appends a node ID to the session ID, which can be used for routing. ==== Configuration -There are two components to session management in Jetty: a session ID -manager and a session manager. +There are two components to session management in Jetty: a session ID manager and a session manager. -* The session ID manager ensures that session IDs are unique across all -webapps hosted on a Jetty instance, and thus there can only be one -session ID manager per Jetty instance. -* The session manager handles the session lifecycle -(create/update/invalidate/expire) on behalf of a web application, so -there is one session manager per web application instance. +* The session ID manager ensures that session IDs are unique across all webapps hosted on a Jetty instance, and thus there can only be one session ID manager per Jetty instance. +* The session manager handles the session lifecycle (create/update/invalidate/expire) on behalf of a web application, so there is one session manager per web application instance. -These managers also cooperate and collaborate with the -`org.eclipse.jetty.server.session.SessionHandler` to enable -cross-context dispatch. +These managers also cooperate and collaborate with the `org.eclipse.jetty.server.session.SessionHandler` to enable cross-context dispatch. ==== The gcloud-sessions Module -When using the jetty distribution, to enable Cloud Datastore session -persistence, you will first need to enable the `gcloud-sessions` -link:#startup-modules[module] for your link:#creating-jetty-base[base] -using the --add-to-start or --add-to-startd argument to the -link:#startup-overview[start.jar]. +When using the jetty distribution, to enable Cloud Datastore session persistence, you will first need to enable the `gcloud-sessions` link:#startup-modules[module] for your link:#creating-jetty-base[base] using the `--add-to-start` or `--add-to-startd` argument to the link:#startup-overview[start.jar]. -As part of the module installation, the necessary jars will be -dynamically downloaded and installed to your `${jetty.base}/lib/gcloud` -directory. If you need to up or downgrade the version of the jars, then -you can delete the jars that were automatically installed and replace -them. Once you've done that, you will need to prevent jetty's startup -checks from detecting the missing jars. To do that, you can use -`--skip-file-validation=glcoud-sessions` argument to start.jar on the -command line, or place that line inside `${jetty.base}/start.ini` to -ensure it is used for every start. +As part of the module installation, the necessary jars will be dynamically downloaded and installed to your `${jetty.base}/lib/gcloud` directory. +If you need to up or downgrade the version of the jars, then you can delete the jars that were automatically installed and replace them. +Once you've done that, you will need to prevent jetty's startup checks from detecting the missing jars. +To do that, you can use `--skip-file-validation=glcoud-sessions` argument to start.jar on the command line, or place that line inside `${jetty.base}/start.ini` to ensure it is used for every start. ===== Configuring the GCloudSessionIdManager -The gcloud-sessions module will have installed file called -`${jetty.home}/etc/jetty-gcloud-sessions.xml`. This file configures an -instance of the GCloudSessionIdManager that will be shared across all -webapps deployed on that server. It looks like this: +The gcloud-sessions module will have installed file called `${jetty.home}/etc/jetty-gcloud-sessions.xml`. +This file configures an instance of the `GCloudSessionIdManager` that will be shared across all webapps deployed on that server. It looks like this: [source,xml] ---- -include::{SRCDIR}/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/jetty-gcloud-session-store.xml[] +include::{SRCDIR}/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/jetty-gcloud-sessions.xml[] ---- -You configure it by setting values for properties. The properties will -either be inserted as commented out in your `start.ini`, or your -`start.d/gcloud-sessions.ini` file, depending on how you enabled the -module. +You configure it by setting values for properties. +The properties will either be inserted as commented out in your `start.ini`, or your `start.d/gcloud-sessions.ini` file, depending on how you enabled the module. -The only property you always need to set is the name of the node in the -cluster: +The only property you always need to set is the name of the node in the cluster: jetty.gcloudSession.workerName:: - The name that uniquely identifies this node in the cluster. This value - will also be used by the sticky load balancer to identify the node. - Don't forget to change the value of this property on *each* node on - which you enable gcloud datastore session clustering. + The name that uniquely identifies this node in the cluster. + This value will also be used by the sticky load balancer to identify the node. + Don't forget to change the value of this property on *each* node on which you enable gcloud datastore session clustering. -Which other properties you need to set depends on the execution -environment: +Which other properties you need to set depends on the execution environment: ====== Running Within Google Infrastructure -When you upload your webapp to run in Compute Engine, you do not need to -set any other properties for jetty. If you follow the instructions in -the https://cloud.google.com/datastore/docs/activate[Cloud Datastore -documentation], all authorizations etc will be provided by the runtime -environment. +When you upload your webapp to run in Compute Engine, you do not need to set any other properties for Jetty. +If you follow the instructions in the https://cloud.google.com/datastore/docs/activate[Cloud Datastore documentation], all authorizations...etc. will be provided by the runtime environment. ====== Running Externally to Google Infrastructure -When your app is executing outside of Google, you can either contact a -remote Cloud Datastore instance, or a -https://cloud.google.com/datastore/docs/tools/devserver[local test dev -server] provided by the sdk. The choice determines which properties you -need to set: +When your app is executing outside of Google, you can either contact a remote Cloud Datastore instance, or a https://cloud.google.com/datastore/docs/tools/devserver[local test dev server] provided by the sdk. +The choice determines which properties you need to set: Contacting an sdk dev server for testing::: - In this case, you need to set up either some _System_ properties or - _environment variables_ - NOT jetty properties! - + + In this case, you need to set up either some _System_ properties or _environment variables_ - *NOT* Jetty properties! + DATASTORE_DATASET;; This must be the name of your (test) project. DATASTORE_HOST;; - This is the url of the dev server as described at - https://cloud.google.com/datastore/docs/tools/devserver#setting_environment_variables. - An example may be "http://localhost:9999" + This is the url of the dev server as described https://cloud.google.com/datastore/docs/tools/devserver#setting_environment_variables[in Google's documentation]. + An example may be "http://localhost:9999". + Contacting a remote Cloud Datastore::: - In this case, you need to provide all of the authentication and - authorization information explicitly via jetty properties in the ini - file: - + + In this case, you need to provide all of the authentication and authorization information explicitly via jetty properties in the ini file: + jetty.gcloudSession.projectId;; This is the name of your project. jetty.gcloudSession.p12File;; - This is the location of the p12 key file that is associated with - your project. + This is the location of the p12 key file that is associated with your project. jetty.gcloudSession.serviceAccount;; - This is the email address that defines your service account for the - Cloud Datastore. + This is the email address that defines your service account for the Cloud Datastore. jetty.gcloudSession.password;; This is the password associated with the p12 key file. ===== Configuring the GCloudSessionManager -As mentioned elsewhere, there should be one GCloudSessionManager per -context (ie webapp). It will need to reference the single -GCloudSessionIdManager from which it derives the Cloud Datastore -configuration information. +As mentioned elsewhere, there should be one `GCloudSessionManager` per context (e.g. webapp). +It will need to reference the single `GCloudSessionIdManager` from which it derives the Cloud Datastore configuration information. -The way you configure a GCloudSessionManager depends on whether you're -configuring from a context xml file or a `jetty-web.xml` file or code. -The basic difference is how you get a reference to the Jetty -`org.eclipse.jetty.server.Server` instance. +The way you configure a `GCloudSessionManager` depends on whether you're configuring from a context xml file, a `jetty-web.xml` file or code. +The basic difference is how you get a reference to the Jetty `org.eclipse.jetty.server.Server` instance. From a context xml file, you reference the Server instance as a Ref: [source,xml] ----- - - +---- @@ -175,12 +128,10 @@ From a context xml file, you reference the Server instance as a Ref: ---- -From a `WEB-INF/jetty-web.xml` file, you can reference the Server -instance directly: +From a `WEB-INF/jetty-web.xml` file, you can reference the Server instance directly: [source,xml] ---- - @@ -201,19 +152,17 @@ instance directly: ---- -The GCloudSessionManager supports the following configuration setters: +The `GCloudSessionManager` supports the following configuration setters: scavengeIntervalSec:: - Time in seconds between runs of a scavenger task that looks for - expired old sessions to delete. The default is 10 minutes. If set to - 0, no scavenging is done. + Time in seconds between runs of a scavenger task that looks for expired old sessions to delete. + The default is 10 minutes. + If set to 0, no scavenging is done. staleIntervalSec:: - The length of time a session can be in memory without being checked - against the cluster. A value of 0 indicates that the session is never - checked against the cluster - the current node is considered to be the - master for the session. + The length of time a session can be in memory without being checked against the cluster. + A value of 0 indicates that the session is never checked against the cluster - the current node is considered to be the master for the session. maxQueryResults:: - The maximum number of results to return for a query to find expired - sessions. For efficiency it is important to limit the size of the - result. The default is 100. If 0 or negative numbers are set, the - default is used instead. + The maximum number of results to return for a query to find expired sessions. + For efficiency it is important to limit the size of the result. + The default is 100. + If 0 or negative numbers are set, the default is used instead. diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-infinispan.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-infinispan.adoc index 1e7524e3b21..5ada3f1b7fb 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-infinispan.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-infinispan.adoc @@ -17,58 +17,33 @@ [[session-clustering-infinispan]] === Session Clustering with Infinispan -Jetty can support session clustering by persisting sessions to -http://www.infinispan.org[Infinispan]. Each Jetty instance locally -caches sessions for which it has received requests, writing any changes -to the session through to Infinispan as the request exits the server. -Sessions must obey the Serialization contract, and servlets must call -the Session.setAttribute() method to ensure that changes are persisted. +Jetty can support session clustering by persisting sessions to http://www.infinispan.org[Infinispan]. +Each Jetty instance locally caches sessions for which it has received requests, writing any changes to the session through to Infinispan as the request exits the server. +Sessions must obey the Serialization contract, and servlets must call the `Session.setAttribute()` method to ensure that changes are persisted. -The persistent session mechanism works in conjunction with a load -balancer that supports stickiness. Stickiness can be based on various -data items, such as source IP address or characteristics of the session -ID or a load-balancer specific mechanism. For those load balancers that -examine the session ID, the Jetty persistent session mechanism appends a -node ID to the session ID, which can be used for routing. +The persistent session mechanism works in conjunction with a load balancer that supports stickiness. +Stickiness can be based on various data items, such as source IP address or characteristics of the session ID or a load-balancer specific mechanism. +For those load balancers that examine the session ID, the Jetty persistent session mechanism appends a node ID to the session ID, which can be used for routing. ==== Configuration -There are two components to session management in Jetty: a session ID -manager and a session manager. +There are two components to session management in Jetty: a session ID manager and a session manager. -* The session ID manager ensures that session IDs are unique across all -webapps hosted on a Jetty instance, and thus there can only be one -session ID manager per Jetty instance. -* The session manager handles the session lifecycle -(create/update/invalidate/expire) on behalf of a web application, so -there is one session manager per web application instance. +* The session ID manager ensures that session IDs are unique across all webapps hosted on a Jetty instance, and thus there can only be one session ID manager per Jetty instance. +* The session manager handles the session lifecycle (create/update/invalidate/expire) on behalf of a web application, so there is one session manager per web application instance. -These managers also cooperate and collaborate with the -`org.eclipse.jetty.server.session.SessionHandler` to enable -cross-context dispatch. +These managers also cooperate and collaborate with the `org.eclipse.jetty.server.session.SessionHandler` to enable cross-context dispatch. -==== The infinispan Module +==== The Infinispan Module -When using the jetty distribution, to enable Infinispan session -persistence, you will first need to enable the `infinispan` -link:#startup-modules[module] for your link:#creating-jetty-base[base] -using the --add-to-start or --add-to-startd argument to the -link:#startup-overview[start.jar]. +When using the jetty distribution, to enable Infinispan session persistence, you will first need to enable the Infinispan link:#startup-modules[module] for your link:#creating-jetty-base[base] using the `--add-to-start` or `--add-to-startd` argument to the link:#startup-overview[start.jar]. -As part of the module installation, the necessary infinispan jars will -be dynamically downloaded and installed to your -`${jetty.base}/lib/infinispan` directory. If you need to up or downgrade -the version of the infinispan jars, then you can delete the jars that -were automatically installed and replace them. Once you've done that, -you will need to prevent jetty's startup checks from detecting the -missing jars. To do that, you can use -`--skip-file-validation=infinispan` argument to start.jar on the command -line, or place that line inside `${jetty.base}/start.ini` to ensure it -is used for every start. +As part of the module installation, the necessary Infinispan jars will be dynamically downloaded and installed to your `${jetty.base}/lib/infinispan` directory. +If you need to up or downgrade the version of the Infinispan jars, then you can delete the jars that were automatically installed and replace them. +Once you've done that, you will need to prevent Jetty's startup checks from detecting the missing jars. +To do that, you can use `--skip-file-validation=infinispan` argument to start.jar on the command line, or place that line inside `${jetty.base}/start.ini` to ensure it is used for every start. -You will also find the following properties, either in your base's -`start.d/infinispan.ini` file or appended to your `start.ini`, depending -on how you enabled the module: +You will also find the following properties, either in your base's `start.d/infinispan.ini` file or appended to your `start.ini`, depending on how you enabled the module: .... ## Unique identifier for this node in the cluster @@ -76,61 +51,41 @@ jetty.infinispanSession.workerName=node1 .... jetty.infinispanSession.workerName:: - The name that uniquely identifies this node in the cluster. This value - will also be used by the sticky load balancer to identify the node. - Don't forget to change the value of this property on *each* node on - which you enable infinispan session clustering. + The name that uniquely identifies this node in the cluster. + This value will also be used by the sticky load balancer to identify the node. + Don't forget to change the value of this property on *each* node on which you enable Infinispan session clustering. -These properties are applied to the InfinispanSessionIdManager described -below. +These properties are applied to the `InfinispanSessionIdManager` described below. ===== Configuring the InfinispanSessionIdManager -The infinispan module will have installed file called -$\{jetty.home}/etc/jetty-infinispan.xml. This file configures an -instance of the InfinispanSessionIdManager that will be shared across -all webapps deployed on that server. It looks like this: +The Infinispan module will have installed file called `$\{jetty.home}/etc/jetty-infinispan.xml`. +This file configures an instance of the `InfinispanSessionIdManager` that will be shared across all webapps deployed on that server. +It looks like this: [source,xml] ---- -include::{SRCDIR}/jetty-infinispan/src/main/config/etc/jetty-default-infinispan-store.xml[] +include::{SRCDIR}/jetty-infinispan/src/main/config/etc/jetty-infinispan.xml[] ---- -As you can see, you configure the Infinispan -http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_the_cache_apis[Cache] -instance that the InfinispanSessionIdManager should use in this file. By -default, the infinispan -http://infinispan.org/docs/7.1.x/getting_started/getting_started.html#_running_infinispan_on_a_single_node[Default -cache] instance is used (ie on the local node). You can instead use a -custom Cache setup - the jetty-infinispan.xml file shows you how to -configure a remote Cache (using the -http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_using_hot_rod_server[hotrod -java client]). +As you can see, you configure the Infinispan http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_the_cache_apis[Cache] instance that the `InfinispanSessionIdManager` should use in this file. +By default, the Infinispan http://infinispan.org/docs/7.1.x/getting_started/getting_started.html#_running_infinispan_on_a_single_node[Default cache] instance is used (e.g. on the local node). +You can instead use a custom Cache setup - the `jetty-infinispan.xml` file shows you how to configure a remote Cache (using the http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_using_hot_rod_server[hotrod java client]). -The InfinispanSessionIdManager can be configured by calling setters: +The `InfinispanSessionIdManager` can be configured by calling setters: idleExpiryMultiple:: - Sessions that are not immortal, ie they have an expiry time, have - their ids stored into Infinispan with an - http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_expiration[idle - expiry timeout] equivalent to double the session's timeout. This - should be sufficient to ensure that a session id that is in-use by a - session is never accidentally removed. However, should you wish to, - you can configure this to any integral value to effectively increase - the - http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_expiration[idle - expiry] timeout. + Sessions that are not immortal, e.g. they have an expiry time, have their ids stored into Infinispan with an http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_expiration[idle expiry timeout] equivalent to double the session's timeout. + This should be sufficient to ensure that a session id that is in-use by a session is never accidentally removed. + However, should you wish to, you can configure this to any integral value to effectively increase the http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_expiration[idle expiry] timeout. ===== Configuring the InfinispanSessionManager -As mentioned elsewhere, there should be one InfinispanSessionManager per -context (ie webapp). It will need to reference the single -InfinispanSessionIdManager configured previously for the Server. +As mentioned elsewhere, there should be one `InfinispanSessionManager` per context (e.g. webapp). +It will need to reference the single `InfinispanSessionIdManager` configured previously for the Server. -The way you configure a InfinispanSessionManager depends on whether -you're configuring from a context xml file or a `jetty-web.xml` file or -code. The basic difference is how you get a reference to the Jetty -`org.eclipse.jetty.server.Server` instance. +The way you configure a `InfinispanSessionManager` depends on whether you're configuring from a context xml file, a `jetty-web.xml` file or code. +The basic difference is how you get a reference to the Jetty `org.eclipse.jetty.server.Server` instance. From a context xml file, you reference the Server instance as a Ref: @@ -171,8 +126,7 @@ From a context xml file, you reference the Server instance as a Ref: ---- -From a `WEB-INF/jetty-web.xml` file, you can reference the Server -instance directly: +From a `WEB-INF/jetty-web.xml` file, you can reference the Server instance directly: [source,xml] ---- @@ -213,25 +167,19 @@ instance directly: The InfinispanSessionManager can be provided by calling setters: scavengeInterval:: - Time in seconds between runs of a scavenger task that looks for - expired old sessions to delete. The default is 10 minutes. + Time in seconds between runs of a scavenger task that looks for expired old sessions to delete. + The default is 10 minutes. staleIntervalSec:: - The length of time a session can be in memory without being checked - against the cluster. A value of 0 indicates that the session is never - checked against the cluster - the current node is considered to be the - master for the session. + The length of time a session can be in memory without being checked against the cluster. + A value of 0 indicates that the session is never checked against the cluster - the current node is considered to be the master for the session. ===== Using HotRod -If you're using the hotrod client - where serialization will be required -- you will need to ensure that the hotrod marshalling software works -with jetty classloading. To do this, firstly ensure that you have -included the lines containing the `prependServerClass` to your context -xml file as shown above. +If you're using the hotrod client - where serialization will be required - you will need to ensure that the hotrod marshalling software works with Jetty classloading. +To do this, firstly ensure that you have included the lines containing the `prependServerClass` to your context xml file as shown above. -Then, create the file -`${jetty.base}/resources/hotrod-client.properties`. Add the following -line to this file: +Then, create the file `${jetty.base}/resources/hotrod-client.properties`. +Add the following line to this file: .... infinispan.client.hotrod.marshaller=org.eclipse.jetty.session.infinispan.WebAppMarshaller diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-jdbc.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-jdbc.adoc index 6eb6ae7b96d..2280f980eb0 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-jdbc.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-jdbc.adoc @@ -17,57 +17,35 @@ [[session-clustering-jdbc]] === Session Clustering with a Database -Jetty can support session clustering by persisting sessions to a shared -database. Each Jetty instance locally caches sessions for which it has -received requests, writing any changes to the session through to the -database as the request exits the server. Sessions must obey the -Serialization contract, and servlets must call the -Session.setAttribute() method to ensure that changes are persisted. +Jetty can support session clustering by persisting sessions to a shared database. +Each Jetty instance locally caches sessions for which it has received requests, writing any changes to the session through to the database as the request exits the server. +Sessions must obey the Serialization contract, and servlets must call the `Session.setAttribute()` method to ensure that changes are persisted. -The persistent session mechanism works in conjunction with a load -balancer that supports stickiness. Stickiness can be based on various -data items, such as source IP address or characteristics of the session -ID or a load-balancer specific mechanism. For those load balancers that -examine the session ID, the Jetty persistent session mechanism appends a -node ID to the session ID, which can be used for routing. +The persistent session mechanism works in conjunction with a load balancer that supports stickiness. +Stickiness can be based on various data items, such as source IP address or characteristics of the session ID or a load-balancer specific mechanism. +For those load balancers that examine the session ID, the Jetty persistent session mechanism appends a node ID to the session ID, which can be used for routing. -In this type of solution, the database can become both a bottleneck and -a single point of failure. Jetty takes steps to reduce the load on the -database (discussed below), but in a heavily loaded environment you -might need to investigate other optimization strategies such as local -caching and database replication. You should also consult your database -vendor's documentation for information on how to ensure high -availability and failover of your database. +In this type of solution, the database can become both a bottleneck and a single point of failure. +Jetty takes steps to reduce the load on the database (discussed below), but in a heavily loaded environment you might need to investigate other optimization strategies such as local caching and database replication. +You should also consult your database vendor's documentation for information on how to ensure high availability and failover of your database. ==== Configuration -There are two components to session management in Jetty: a session ID -manager and a session manager. +There are two components to session management in Jetty: a session ID manager and a session manager. -* The session ID manager ensures that session IDs are unique across all -webapps hosted on a Jetty instance, and thus there can only be one -session ID manager per Jetty instance. -* The session manager handles the session lifecycle -(create/update/invalidate/expire) on behalf of a web application, so -there is one session manager per web application instance. +* The session ID manager ensures that session IDs are unique across all webapps hosted on a Jetty instance, and thus there can only be one session ID manager per Jetty instance. +* The session manager handles the session lifecycle (create/update/invalidate/expire) on behalf of a web application, so there is one session manager per web application instance. -These managers also cooperate and collaborate with the -`org.eclipse.jetty.server.session.SessionHandler` to enable -cross-context dispatch. +These managers also cooperate and collaborate with the `org.eclipse.jetty.server.session.SessionHandler` to enable cross-context dispatch. ==== The jdbc-session Module -When using the jetty distribution, to enable jdbc session persistence, -you will first need to enable the jdbc-session -link:#startup-modules[module] for your link:#creating-jetty-base[base] -using the --add-to-start or --add-to-startd argument to the -link:#startup-overview[start.jar]. +When using the jetty distribution, to enable jdbc session persistence, you will first need to enable the jdbc-session link:#startup-modules[module] for your link:#creating-jetty-base[base] using the `--add-to-start` or `--add-to-startd` argument to the link:#startup-overview[start.jar]. -You will also find the following properties, either in your base's -start.d/jdbc-session.ini file or appended to your start.ini, depending -on how you enabled the module: +You will also find the following properties, either in your base's start.d/jdbc-session.ini file or appended to your start.ini, depending on how you enabled the module: -.... +[source,java] +---- ## Unique identifier for this node in the cluster jetty.jdbcSession.workerName=node1 @@ -75,53 +53,42 @@ jetty.jdbcSession.workerName=node1 #jetty.jdbcSession.datasource=sessions jetty.jdbcSession.driverClass=org.apache.derby.jdbc.EmbeddedDriver jetty.jdbcSession.connectionURL=jdbc:derby:sessions;create=true -.... +---- jetty.jdbcSession.workerName:: - The name that uniquely identifies this node in the cluster. This value - will also be used by the sticky load balancer to identify the node. - Don't forget to change the value of this property on *each* node on - which you enable jdbc session clustering. + The name that uniquely identifies this node in the cluster. + This value will also be used by the sticky load balancer to identify the node. + Don't forget to change the value of this property on *each* node on which you enable jdbc session clustering. jetty.jdbcSession.scavenge:: - The time in seconds between sweeps of a task which scavenges old - expired sessions. The default is 10 mins. We don't recommend you - increase the frequency bcause doing so increases the load on the - database with very little gain. + The time in seconds between sweeps of a task which scavenges old expired sessions. + The default is 10 minutess. + Increasing the frequency is not recommended as doing so increases the load on the database with very little gain. jetty.jdbcSession.datasource:: - The name of a javax.sql.DataSource that gives access to the database - that holds the session information. You should configure *either* this - or the jdbc driver information described next. + The name of a `javax.sql.DataSource` that gives access to the database that holds the session information. + You should configure *either* this or the jdbc driver information described next. jetty.jdbcSession.datasource and jetty.jdbcSession.connectionURL:: - This is the name of the jdbc driver class, and a jdbc connection url - suitable for that driver. You should configure *either* this or the - jdbc datasource name described above. + This is the name of the jdbc driver class, and a jdbc connection url suitable for that driver. + You should configure *either* this or the jdbc datasource name described above. -These properties are applied to the JDBCSessionIdManager described -below. +These properties are applied to the `JDBCSessionIdManager` described below. ===== Configuring the JDBCSessionIdManager -The jdbc-session module will have installed file called -$\{jetty.home}/etc/jetty-jdbc-sessions.xml. This file configures an -instance of the JDBCSessionIdManager that will be shared across all -webapps deployed on that server. It looks like this: +The jdbc-session module will have installed file called `$\{jetty.home}/etc/jetty-jdbc-sessions.xml`. +This file configures an instance of the `JDBCSessionIdManager` that will be shared across all webapps deployed on that server. +It looks like this: [source,xml] ---- -include::{SRCDIR}/jetty-server/src/main/config/etc/jetty-jdbc-session-store.xml[] +include::{SRCDIR}/jetty-server/src/main/config/etc/jetty-jdbc-sessions.xml[] ---- -As well as uncommenting and setting up appropriate values for the -properties we discussed above, you will also need to edit this file and -uncomment *either* the datasource or the driver info elements. +As well as uncommenting and setting up appropriate values for the properties discussed above, you will also need to edit this file and uncomment *either* the data source or the driver info elements. -As Jetty configuration files are direct mappings of XML to Java, it is -straightforward to see how to do this in code, but here's an example -anyway: +As Jetty configuration files are direct mappings of XML to Java, it is straight forward to do this in code: [source,java] ----- - +---- Server server = new Server(); ... JDBCSessionIdManager idMgr = new JDBCSessionIdManager(server); @@ -134,19 +101,18 @@ server.setSessionIdManager(idMgr); ====== Configuring the Database Schema -You may find it necessary to change the names of the tables and columns -that the JDBC Session management uses to store the session information. +You may find it necessary to change the names of the tables and columns that the JDBC Session management uses to store the session information. The defaults used are: .Default Values for Session Id Table -[cols=",",] +[options="header"] |=========================== |table name |JettySessionIds -|columns |id +|columns |id |=========================== .Default Values for Session Table -[cols=",",] +[options="header"] |======================================================================= |table name |JettySessions @@ -155,16 +121,11 @@ accessTime, lastAccessTime, createTime, cookieTime, lastSavedTime, expiryTime, maxInterval, map |======================================================================= -To change these values, use the -link:{JDURL}/org/eclipse/jetty/server/session/SessionIdTableSchema.html[org.eclipse.jetty.server.session.SessionIdTableSchema] -and -link:{JDURL}/org/eclipse/jetty/server/session/SessionTableSchema.html[org.eclipse.jetty.server.session.SessionTableSchema] -classes. These classes have getter/setter methods for the table name and -all columns. +To change these values, use the link:{JDURL}/org/eclipse/jetty/server/session/SessionIdTableSchema.html[org.eclipse.jetty.server.session.SessionIdTableSchema] and link:{JDURL}/org/eclipse/jetty/server/session/SessionTableSchema.html[org.eclipse.jetty.server.session.SessionTableSchema] classes. +These classes have getter/setter methods for the table name and all columns. -Here's an example of changing the name of JettySessionsId table and its -single column. This example will use java code, but as explained above, -you may also do this via a jetty xml configuration file: +Here's an example of changing the name of `JettySessionsId` table and its single column. +This example will use java code, but as explained above, you may also do this via a Jetty xml configuration file: [source,java] ---- @@ -176,10 +137,8 @@ idTableSchema.setIdColumn("theid"); idManager.setSessionIdTableSchema(idTableSchema); ---- -In a similar fashion, you can change the names of the table and columns -for the JettySessions table. *Note* that both the SessionIdTableSchema -and the SessionTableSchema instances are set on the JDBCSessionIdManager -class. +In a similar fashion, you can change the names of the table and columns for the `JettySessions` table. +*Note* that both the `SessionIdTableSchema` and the `SessionTableSchema` instances are set on the `JDBCSessionIdManager` class. [source,java] ---- @@ -203,14 +162,11 @@ idManager.setSessionTableSchema(sessionTableSchema); ===== Configuring the JDBCSessionManager -As mentioned elsewhere, there should be one JDBCSessionManager per -context (ie webapp). It will need to reference the single -JDBCSessionIdManager configured previously for the Server. +As mentioned elsewhere, there should be one `JDBCSessionManager` per context (e.g. webapp). +It will need to reference the single `JDBCSessionIdManager` configured previously for the Server. -The way you configure a JDBCSessionManager depends on whether you're -configuring from a context xml file or a `jetty-web.xml` file or code. -The basic difference is how you get a reference to the Jetty -`org.eclipse.jetty.server.Server` instance. +The way you configure a `JDBCSessionManager` depends on whether you're configuring from a context xml file, a `jetty-web.xml` file or code. +The basic difference is how you get a reference to the Jetty `org.eclipse.jetty.server.Server` instance. From a context xml file, you reference the Server instance as a Ref: @@ -232,8 +188,7 @@ From a context xml file, you reference the Server instance as a Ref: ---- -From a `WEB-INF/jetty-web.xml` file, you can reference the Server -instance directly: +From a `WEB-INF/jetty-web.xml` file, you can reference the Server instance directly: [source,xml] ---- diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-mongodb.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-mongodb.adoc index 27b4355379b..47cc1659436 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-mongodb.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/session-clustering-mongodb.adoc @@ -17,108 +17,72 @@ [[session-clustering-mongodb]] === Session Clustering with MongoDB -Jetty can support session clustering by persisting sessions into -http://www.mogodb.org[MongoDB]. Each Jetty instance locally caches -sessions for which it has received requests, writing any changes to the -session through to the cluster as the request exits the server. Sessions -must obey the Serialization contract, and servlets must call the -Session.setAttribute() method to ensure that changes are persisted. +Jetty can support session clustering by persisting sessions into http://www.mogodb.org[MongoDB]. +Each Jetty instance locally caches sessions for which it has received requests, writing any changes to the session through to the cluster as the request exits the server. +Sessions must obey the Serialization contract, and servlets must call the `Session.setAttribute()` method to ensure that changes are persisted. -The session persistence mechanism works in conjunction with a load -balancer that supports stickiness. Stickiness can be based on various -data items, such as source IP address or characteristics of the session -ID or a load-balancer specific mechanism. For those load balancers that -examine the session ID, the Jetty persistent session mechanism appends a -node ID to the session ID, which can be used for routing. +The session persistence mechanism works in conjunction with a load balancer that supports stickiness. +Stickiness can be based on various data items, such as source IP address or characteristics of the session ID or a load-balancer specific mechanism. +For those load balancers that examine the session ID, the Jetty persistent session mechanism appends a node ID to the session ID, which can be used for routing. -In this type of solution, the traffic on the network needs to be -carefully watched and tends to be the bottleneck. You are probably -investigating this solution in order to scale to large amount of users -and sessions, so careful attention should be paid to your usage -scenario. Applications with a heavy write profile to their sessions will -consume more network bandwidth than profiles that are predominately read -oriented. We recommend using this session manager with largely read -based session scenarios. +In this type of solution, the traffic on the network needs to be carefully watched and tends to be the bottleneck. +You are probably investigating this solution in order to scale to large amount of users and sessions, so careful attention should be paid to your usage scenario. +Applications with a heavy write profile to their sessions will consume more network bandwidth than profiles that are predominately read oriented. +We recommend using this session manager with largely read based session scenarios. ==== Configuration -There are two components to session management in Jetty: a session ID -manager and a session manager. +There are two components to session management in Jetty: a session ID manager and a session manager. -* The session ID manager ensures that session IDs are unique across all -webapps hosted on a Jetty instance, and thus there should only be one -session ID manager per Jetty instance. -* The session manager handles the session lifecycle -(create/update/invalidate/expire) on behalf of a web application, so -there is one session manager per web application instance. +* The session ID manager ensures that session IDs are unique across all webapps hosted on a Jetty instance, and thus there can only be one session ID manager per Jetty instance. +* The session manager handles the session lifecycle (create/update/invalidate/expire) on behalf of a web application, so there is one session manager per web application instance. -These managers also cooperate and collaborate with the -`org.eclipse.jetty.server.session.SessionHandler` to enable -cross-context dispatch. +These managers also cooperate and collaborate with the `org.eclipse.jetty.server.session.SessionHandler` to enable cross-context dispatch. ==== The nosql Module -When using the jetty distribution, to enable the mongodb session -persistence mechanism, you will first need to enable the nosql -link:#startup-modules[module] for your link:#creating-jetty-base[base] -using the --add-to-start or --add-to-startd argument to the -link:#startup-overview[start.jar]. This module will automatically -download the mongodb-java-driver and install it to your base's lib/nosql -directory. +When using the jetty distribution, to enable the MongoDB session persistence mechanism, you will first need to enable the nosql link:#startup-modules[module] for your link:#creating-jetty-base[base] using the `--add-to-start` or `--add-to-startd` argument to the link:#startup-overview[start.jar]. +This module will automatically download the `mongodb-java-driver` and install it to your base's `lib/nosql` directory. -As part of the module installation, the necessary mongo java driver jars -will be dynamically downloaded and installed to your -`${jetty.base}/lib/nosql` directory. If you need to up or downgrade the -version of these jars, then you can delete the jars that were -automatically installed and replace them. Once you've done that, you -will need to prevent jetty's startup checks from detecting the missing -jars. To do that, you can use `--skip-file-validation=nosql` argument to -start.jar on the command line, or place that line inside -`${jetty.base}/start.ini` to ensure it is used for every start. +As part of the module installation, the necessary mongo java driver jars will be dynamically downloaded and installed to your `${jetty.base}/lib/nosql` directory. +If you need to up or downgrade the version of these jars, then you can delete the jars that were automatically installed and replace them. +Once you've done that, you will need to prevent Jetty's startup checks from detecting the missing jars. +To do that, you can use `--skip-file-validation=nosql` argument to start.jar on the command line, or place that line inside `${jetty.base}/start.ini` to ensure it is used for every start. -You will also find the following properties, either in your base's -start.d/nosql.ini file or appended to your start.ini, depending on how -you enabled the module: +You will also find the following properties, either in your base's `start.d/nosql.ini` file or appended to your `start.ini`, depending on how you enabled the module: -.... +[source,xml] +---- ## Unique identifier for this node in the cluster jetty.nosqlSession.workerName=node1 ## Interval in seconds between scavenging expired sessions jetty.nosqlSession.scavenge=1800 -.... +---- -The `jetty.nosqlSession.workerName` is the unique name for this jetty -Server instance. It will be used by the sticky load balancer to uniquely -identify the node. You should change this value on *each* node to which -you install mongodb session management. +The `jetty.nosqlSession.workerName` is the unique name for this Jetty Server instance. +It will be used by the sticky load balancer to uniquely identify the node. +You should change this value on *each* node to which you install MongoDB session management. -The `jetty.nosqlSession.scavenge` property defines the time in seconds -between runs of the scavengeer: the scavenger is a task which runs -periodically to clean out sessions that have expired but become stranded -in the database for whatever reason. +The `jetty.nosqlSession.scavenge` property defines the time in seconds between runs of the scavenger: the scavenger is a task which runs periodically to clean out sessions that have expired but become stranded in the database for whatever reason. -These properties are substituted into the configuration of the -MongoDBSessionIdManager and MongoSessionManager. +These properties are substituted into the configuration of the `MongoDBSessionIdManager` and `MongoSessionManager`. ===== Configuring the MongoSessionIdManager -The nosql module will have installed file called -$\{jetty.home}/etc/jetty-nosql.xml. This file configures an instance of -the MongoSessionIdManager that will be shared across all webapps -deployed on that server. It looks like this: +The nosql module will have installed file called `$\{jetty.home}/etc/jetty-nosql.xml`. +This file configures an instance of the `MongoSessionIdManager` that will be shared across all webapps deployed on that server. +It looks like this: [source,xml] ---- -include::{SRCDIR}/jetty-nosql/src/main/config/etc/jetty-mongo-session-store.xml[] +include::{SRCDIR}/jetty-nosql/src/main/config/etc/jetty-nosql.xml[] ---- -The MongoSessionIdManager needs access to a mongodb cluster, and the -jetty-nosql.xml file assumes the defaults of localhost and default -mongodb port. If you need to configure something else, you will need to -edit this file. Here's an example of a more complex setup to use a -remote mongodb instance: +The `MongoSessionIdManager` needs access to a MongoDB cluster, and the `jetty-nosql.xml` file assumes the defaults of localhost and default MongoDB port. +If you need to configure something else, you will need to edit this file. +Here's an example of a more complex setup to use a remote MongoDB instance: [source,xml] ---- @@ -162,9 +126,7 @@ remote mongodb instance: ---- -As Jetty configuration files are direct mappings of XML to Java, it is -straightforward to see how to do this in code, but here's an example -anyway: +As Jetty configuration files are direct mappings of XML to Java, it is straight forward to do this in code: [source,java] ---- @@ -178,71 +140,52 @@ anyway: ---- -The MongoSessionIdManager has slightly different options than some of -our more traditional session options. The MongoDBSessionIdManager has -the same scavenge timers which govern the setting of a valid session to -invalid after a certain period of inactivity. New to this session id -manager is the extra purge setting which governs removal from the -mongodb cluster. This can be configured through the 'purge' option. -Purge is by default set to true and by default runs daily for each node -on the cluster. Also able to be configured is the age in which an -invalid session will be retained which is set to 1 day by default. This -means that invalid sessions will be removed after lingering in the -mongodb instance for a day. There is also an option for purging valid -sessions that have not been used recently. The default time for this is -1 week. You can disable these behaviors by setting purge to false. +The MongoSessionIdManager has slightly different options than some of our more traditional session options. +The `MongoDBSessionIdManager` has the same scavenge timers which govern the setting of a valid session to invalid after a certain period of inactivity. +New to this session id manager is the extra purge setting which governs removal from the MongoDB cluster. +This can be configured through the 'purge' option. Purge is by default set to true and by default runs daily for each node on the cluster. +Also able to be configured is the age in which an invalid session will be retained which is set to 1 day by default. +This means that invalid sessions will be removed after lingering in the MongoDB instance for a day. +There is also an option for purging valid sessions that have not been used recently. +The default time for this is 1 week. You can disable these behaviors by setting purge to false. scavengeDelay:: - How long to delay before periodically looking for sessions to - scavenge? + How long to delay before periodically looking for sessions to scavenge? scavengePeriod:: - How much time after a scavenge has completed should you wait before - doing it again? + How much time after a scavenge has completed should you wait before doing it again? scavengeBlockSize:: - Number of session ids to which to limit each scavenge query. If you - have a very large number of sessions in memory then setting this to a - non 0 value may help speed up scavenging by breaking the scavenge into - multiple, queries. The default is 0, which means that all session ids - are considered in a single query. + Number of session ids to which to limit each scavenge query. + If you have a very large number of sessions in memory then setting this to a non 0 value may help speed up scavenging by breaking the scavenge into multiple, queries. + The default is 0, which means that all session ids are considered in a single query. purge (Boolean):: - Do you want to purge (delete) sessions that are invalid from the - session store completely? + Do you want to purge (delete) sessions that are invalid from the session store completely? purgeDelay:: How often do you want to perform this purge operation? purgeInvalidAge:: - How old should an invalid session be before it is eligible to be - purged? + How old should an invalid session be before it is eligible to be purged? purgeValidAge:: - How old should a valid session be before it is eligible to be marked - invalid and purged? Should this occur at all? + How old should a valid session be before it is eligible to be marked invalid and purged? + Should this occur at all? purgeLimit:: - Integer value that represents how many items to return from a purge - query. The default is 0, which is unlimited. If you have a lot of old - expired orphaned sessions then setting this value may speed up the - purge process. + Integer value that represents how many items to return from a purge query. + The default is 0, which is unlimited. + If you have a lot of old expired orphaned sessions then setting this value may speed up the purge process. preserveOnStop:: Whether or not to retain all sessions when the session manager stops. Default is `true`. ===== Configuring a MongoSessionManager -As mentioned elsewhere, there should be one MongoSessionManager per -context (ie webapp). It will need to reference the single -MongoSessionIdManager configured previously for the Server. +As mentioned elsewhere, there should be one `MongoSessionManager` per context (e.g. webapp). +It will need to reference the single `MongoSessionIdManager` configured previously for the Server. -The way you configure a -link:{JDURL}/org/eclipse/jetty/nosql/MongoSessionManager.html[org.eclipse.jetty.nosql.mongodb.MongoSessionManager] -depends on whether you're configuring from a -link:#deployable-descriptor-file[context xml] file or a -link:#jetty-web-xml-config[jetty-web.xml] file or code. The basic -difference is how you get a reference to the Jetty -`org.eclipse.jetty.server.Server` instance. +The way you configure a link:{JDURL}/org/eclipse/jetty/nosql/MongoSessionManager.html[org.eclipse.jetty.nosql.mongodb.MongoSessionManager] depends on whether you're configuring from a link:#deployable-descriptor-file[context xml] file or a link:#jetty-web-xml-config[jetty-web.xml] file or code. +The basic difference is how you get a reference to the Jetty `org.eclipse.jetty.server.Server` instance. From a context xml file, you reference the Server instance as a Ref: [source,xml] ----- - +---- @@ -258,15 +201,12 @@ From a context xml file, you reference the Server instance as a Ref: - ---- -From a `WEB-INF/jetty-web.xml` file, you can reference the Server -instance directly: +From a `WEB-INF/jetty-web.xml` file, you can reference the Server instance directly: [source,xml] ---- - @@ -287,7 +227,6 @@ If you're embedding this in code: [source,java] ---- - //assuming you have already set up the MongoSessionIdManager as shown earlier //and have a reference to the Server instance: @@ -296,5 +235,4 @@ If you're embedding this in code: MongoSessionManager mongoMgr = new MongoSessionManager(); mongoMgr.setSessionIdManager(server.getSessionIdManager()); wac.setSessionHandler(new SessionHandler(mongoMgr)); - ---- diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc index c8f57ef325d..9317a27a8fe 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc @@ -17,9 +17,7 @@ [[setting-session-characteristics]] === Setting Session Characteristics -To modify the session characteristics of a web application, you can use -the following parameters, applying them as in one of the example -configurations: +To modify the session characteristics of a web application, you can use the following parameters, applying them as in one of the example configurations: [[using-init-parameters]] ==== Using Init Parameters @@ -61,14 +59,12 @@ urls with calls to encodeURL(). False by default. [[applying-init-parameters]] ===== Applying Init Parameters -The following sections provide examples of how to apply the init -parameters. +The following sections provide examples of how to apply the init parameters. [[context-parameter-example]] ====== Context Parameter Example -You can set these parameters as context parameters in a web -application's ` WEB-INF/web.xml` file: +You can set these parameters as context parameters in a web application's `WEB-INF/web.xml` file: [source,xml] ---- @@ -97,8 +93,7 @@ application's ` WEB-INF/web.xml` file: [[web-application-examples]] ====== Web Application Examples -You can configure init parameters on a web application, either in code, -or in a Jetty context xml file equivalent: +You can configure init parameters on a web application, either in code, or in a Jetty context xml file equivalent: [source,xml] ---- @@ -125,8 +120,7 @@ or in a Jetty context xml file equivalent: [[init-parameter-examples]] ====== SessionManager Examples -You can configure init parameters directly on a `SessionManager` -instance, either in code or the equivalent in xml: +You can configure init parameters directly on a `SessionManager` instance, either in code or the equivalent in xml: [source,xml] ---- @@ -152,24 +146,16 @@ instance, either in code or the equivalent in xml: ==== Using Servlet 3.0 Session Configuration -With the advent of http://jcp.org/en/jsr/detail?id=315[Servlet -Specification 3.0] there are new APIs for configuring session handling -characteristics. What was achievable before only via jetty-specific -link:#session-init-params[init-parameters] can now be achieved in a -container-agostic manner either in code, or via web.xml. +With the advent of http://jcp.org/en/jsr/detail?id=315[Servlet Specification 3.0] there are new APIs for configuring session handling characteristics. +What was achievable before only via Jetty-specific link:#session-init-params[init-parameters] can now be achieved in a container-agnostic manner either in code, or via `web.xml`. [[session-cookie-configuration]] ===== SessionCookieConfiguration -The -http://docs.oracle.com/javaee/6/api/javax/servlet/SessionCookieConfig.html[javax.servlet.SessionCookieConfig] -class can be used to set up session handling characteristics. For full -details, consult the -http://docs.oracle.com/javaee/6/api/javax/servlet/SessionCookieConfig.html[javadoc]. +The http://docs.oracle.com/javaee/6/api/javax/servlet/SessionCookieConfig.html[javax.servlet.SessionCookieConfig] class can be used to set up session handling characteristics. +For full details, consult the http://docs.oracle.com/javaee/6/api/javax/servlet/SessionCookieConfig.html[javadoc]. -Here's an example of how you use it: this is a ServletContextListener -that retrieves the SessionCookieConfig and sets up some new values for -it when the context is being initialized: +Below is an example of this implementation: a `ServletContextListener` retrieves the `SessionCookieConfig` and sets up some new values when the context is being initialized: [source,java] ---- @@ -209,9 +195,7 @@ public class TestListener implements ServletContextListener } ---- -You can also use web.xml to configure the session handling -characteristics instead: here's an example, doing exactly the same as we -did above in code: +You can also use `web.xml` to configure the session handling characteristics instead: here's an example doing exactly the same as above instead of using code: [source,xml] ---- @@ -240,14 +224,9 @@ did above in code: [[session-tracking-modes]] ===== SessionTrackingModes -In addition to the configuration of -link:#session-cookie-configuration[session cookies], since Servlet 3.0 -you can also use the -http://docs.oracle.com/javaee/6/api/javax/servlet/SessionTrackingMode.html[javax.servlet.SessionTrackingMode] -to configure session tracking. +In addition to the configuration of link:#session-cookie-configuration[session cookies], since Servlet 3.0 you can also use the http://docs.oracle.com/javaee/6/api/javax/servlet/SessionTrackingMode.html[javax.servlet.SessionTrackingMode] to configure session tracking. -To determine what are the _default_ session tracking characteristics -used by the container, call: +To determine what are the _default_ session tracking characteristics used by the container, call: [source,java] ---- @@ -260,13 +239,12 @@ _default_ session tracking modes for Jetty are: * http://docs.oracle.com/javaee/6/api/javax/servlet/SessionTrackingMode.html#COOKIE[SessionTrackingMode.COOKIE] * http://docs.oracle.com/javaee/6/api/javax/servlet/SessionTrackingMode.html#URL[SessionTrackingMode.URL] -To see which session tracking modes are actually in effect for this -Context, the following call returns a java.util.Set of -javax.servlet.SessionTrackingMode: +To see which session tracking modes are actually in effect for this Context, the following call returns a `java.util.Set` of `javax.servlet.SessionTrackingMode`: -.... +[source,java] +---- javax.servlet.SessionContext.getEffectiveSessionTrackingModes(); -.... +---- To change the session tracking modes, call: @@ -275,7 +253,7 @@ To change the session tracking modes, call: javax.servlet.SessionContext.setSessionTrackingModes(Set); ---- -You may also set the tracking mode in web.xml, eg: +You may also set the tracking mode in `web.xml`, e.g.: [source,xml] ---- diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/using-persistent-sessions.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/using-persistent-sessions.adoc index 9b90d77bb8b..8ca2f8ca382 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/using-persistent-sessions.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/using-persistent-sessions.adoc @@ -17,21 +17,17 @@ [[using-persistent-sessions]] === Using Persistent Sessions -It is sometimes useful to preserve existing Sessions across restarts of -Jetty. The -link:{JDURL}/org/eclipse/jetty/server/session/HashSessionManager.html[`HashSessionManager`] -supports this feature. If you enable persistence, the -`HashSessionManager` saves all existing, valid Sessions to disk before -shutdown completes. On restart, Jetty restores the saved Sessions. +It is sometimes useful to preserve existing Sessions across restarts of Jetty. +The link:{JDURL}/org/eclipse/jetty/server/session/HashSessionManager.html[`HashSessionManager`] supports this feature. +If you enable persistence, the `HashSessionManager` saves all existing, valid Sessions to disk before shutdown completes. +On restart, Jetty restores the saved Sessions. [[enabling-persistence]] ==== Enabling Persistence -A SessionManager does just what its name suggests–it manages the -lifecycle and state of sessions on behalf of a webapp. Each webapp must -have its own unique SessionManager instance. Enabling persistence is as -simple as configuring the `HashSessionManager` as the SessionManager for -a webapp and telling it where on disk to store the sessions: +A `SessionManager` does just what its name suggests – it manages the lifecycle and state of sessions on behalf of a webapp. +Each webapp must have its own unique `SessionManager` instance. +Enabling persistence is as simple as configuring the `HashSessionManager` as the `SessionManager` for a webapp and telling it where on disk to store the sessions: [source,xml] ---- @@ -57,30 +53,25 @@ a webapp and telling it where on disk to store the sessions: ---- -____ -[TIP] -If you want to persist the sessions from multiple webapps: -1. Configure a separate HashSessionManager for each. -2. Assign to each a different value for 'storeDirectory'. -____ +The above uses an example of a xref:intro-jetty-configuration-contexts[context configuration file]. -The above example uses a configuration file suitable for the -link:{JDURL}/org/eclipse/jetty/deploy/providers/ContextProvider.html[ContextProvider], -thus you might want to check out xref:using-context-provider[]. +[TIP] +==== +If you want to persist the sessions from multiple webapps: + +1. Configure a separate `HashSessionManager` for each. + +2. Assign to each a different value for `storeDirectory`. +==== [[delaying-session-load]] ==== Delaying Session Load -You might need to ensure that the sessions are loaded AFTER the servlet -environment starts up (by default, Jetty eagerly loads sessions as part -of the container startup, but before it initializes the servlet -environment). For example, the Wicket web framework requires the servlet -environment to be available when sessions are activated. +You might need to ensure that the sessions are loaded AFTER the servlet environment starts up (by default, Jetty eagerly loads sessions as part of the container startup, but before it initializes the servlet environment). +For example, the Wicket web framework requires the servlet environment to be available when sessions are activated. -Using `SessionManager.setLazyLoad(true)`, Jetty loads sessions lazily -either when it receives the first request for a session, or the session -scavenger runs for the first time, whichever happens first. Here's how -the configuration looks in XML: +Using `SessionManager.setLazyLoad(true)`, Jetty loads sessions lazily either when it receives the first request for a session, or the session scavenger runs for the first time, whichever happens first. +Here's how the configuration looks in XML: [source,xml] ---- @@ -98,8 +89,7 @@ the configuration looks in XML: [[enabling-persistence-for-jetty-maven-plugin]] ==== Enabling Persistence for the Jetty Maven Plugin -To enable session persistence for the Jetty Maven plugin, set up the -HashSessionManager in the configuration section like so: +To enable session persistence for the Jetty Maven plugin, set up the `HashSessionManager` in the configuration section like so: [source,xml] ---- From 73fe6715dea99fbed7db976d045b9f1278fb65c8 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 7 Jun 2016 10:23:38 +0200 Subject: [PATCH 18/21] Issue #306 - Merge jetty-parent into jetty-project. Moved more plugin version declarations into jetty.project's pom. --- aggregates/jetty-all/pom.xml | 3 -- jetty-cdi/test-cdi-it/pom.xml | 2 - jetty-client/pom.xml | 1 - jetty-jspc-maven-plugin/pom.xml | 32 +++++++------ jetty-maven-plugin/pom.xml | 22 +++++---- jetty-osgi/jetty-osgi-alpn/pom.xml | 1 - jetty-osgi/pom.xml | 1 - jetty-osgi/test-jetty-osgi/pom.xml | 10 ----- jetty-start/pom.xml | 5 +-- jetty-websocket/pom.xml | 1 - jetty-websocket/websocket-client/pom.xml | 1 - pom.xml | 45 +++++++++++++++++++ tests/test-jmx/jmx-webapp-it/pom.xml | 2 - tests/test-quickstart/pom.xml | 1 - tests/test-webapps/test-jndi-webapp/pom.xml | 1 - .../test-spec-webapp/pom.xml | 23 +--------- 16 files changed, 74 insertions(+), 77 deletions(-) diff --git a/aggregates/jetty-all/pom.xml b/aggregates/jetty-all/pom.xml index 3e0e91ef960..88636ca2122 100644 --- a/aggregates/jetty-all/pom.xml +++ b/aggregates/jetty-all/pom.xml @@ -21,7 +21,6 @@ org.apache.maven.plugins maven-resources-plugin - 2.7 massage-manifest @@ -44,7 +43,6 @@ org.apache.maven.plugins maven-shade-plugin - 2.3 org.eclipse.jetty.toolchain @@ -99,7 +97,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.9.1 attach-artifacts diff --git a/jetty-cdi/test-cdi-it/pom.xml b/jetty-cdi/test-cdi-it/pom.xml index 5329541c38e..fb6b0ea619d 100644 --- a/jetty-cdi/test-cdi-it/pom.xml +++ b/jetty-cdi/test-cdi-it/pom.xml @@ -91,7 +91,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.17 @@ -104,7 +103,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 start-jetty diff --git a/jetty-client/pom.xml b/jetty-client/pom.xml index 9450cdcc994..b7e52465020 100644 --- a/jetty-client/pom.xml +++ b/jetty-client/pom.xml @@ -51,7 +51,6 @@ org.apache.maven.plugins maven-shade-plugin - 2.4.2 package diff --git a/jetty-jspc-maven-plugin/pom.xml b/jetty-jspc-maven-plugin/pom.xml index 9923d8def5b..2757507f02a 100644 --- a/jetty-jspc-maven-plugin/pom.xml +++ b/jetty-jspc-maven-plugin/pom.xml @@ -23,7 +23,6 @@ org.apache.maven.plugins maven-plugin-plugin - 3.4 exec-plugin-doc @@ -86,21 +85,20 @@ 1.8.4 - org.eclipse.jetty - apache-jstl - ${project.version} - - + org.eclipse.jetty + apache-jstl + ${project.version} + + - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.1 - - false - - + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + false + + project-team @@ -112,7 +110,7 @@ - - + + diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml index 9d6d2a3ba73..93041dd2f45 100644 --- a/jetty-maven-plugin/pom.xml +++ b/jetty-maven-plugin/pom.xml @@ -25,7 +25,6 @@ org.apache.maven.plugins maven-plugin-plugin - ${pluginToolsVersion} exec-plugin-doc @@ -143,15 +142,14 @@ - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.1 - - false - - + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + false + + project-team @@ -163,7 +161,7 @@ - - + + diff --git a/jetty-osgi/jetty-osgi-alpn/pom.xml b/jetty-osgi/jetty-osgi-alpn/pom.xml index d6307719dc5..e58873fefd4 100644 --- a/jetty-osgi/jetty-osgi-alpn/pom.xml +++ b/jetty-osgi/jetty-osgi-alpn/pom.xml @@ -16,7 +16,6 @@ org.codehaus.mojo build-helper-maven-plugin - 1.7 parse-version diff --git a/jetty-osgi/pom.xml b/jetty-osgi/pom.xml index e72e88d0b74..0e90d452392 100644 --- a/jetty-osgi/pom.xml +++ b/jetty-osgi/pom.xml @@ -59,7 +59,6 @@ org.apache.maven.plugins maven-eclipse-plugin - 2.8 prevent/overwriting/by/pointing/to/nonexisting/MANIFEST.MF true diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index d79471ac4e6..2007583b5f4 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -402,19 +402,9 @@ -Dmortbay-alpn-boot=${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.7 - 1.7 - - org.apache.servicemix.tooling depends-maven-plugin - 1.2 generate-depends-file diff --git a/jetty-start/pom.xml b/jetty-start/pom.xml index 2337af1f0e9..87b25aac1e5 100644 --- a/jetty-start/pom.xml +++ b/jetty-start/pom.xml @@ -35,15 +35,14 @@ org.apache.maven.plugins maven-shade-plugin - 2.4 - + true false org.eclipse.jetty:jetty-util - + org.eclipse.jetty.util diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index 3820ed9f0bd..90654949d37 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -37,7 +37,6 @@ org.codehaus.mojo clirr-maven-plugin - 2.5 info 9.1.0.v20131115 diff --git a/jetty-websocket/websocket-client/pom.xml b/jetty-websocket/websocket-client/pom.xml index 7b48388dde7..c076cce1f6f 100644 --- a/jetty-websocket/websocket-client/pom.xml +++ b/jetty-websocket/websocket-client/pom.xml @@ -88,7 +88,6 @@ org.apache.maven.plugins maven-shade-plugin - 2.0 package diff --git a/pom.xml b/pom.xml index cc2f58e639b..1177d525174 100644 --- a/pom.xml +++ b/pom.xml @@ -307,6 +307,11 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + org.apache.maven.plugins maven-assembly-plugin @@ -341,11 +346,21 @@ 10 + + org.apache.maven.plugins + maven-eclipse-plugin + 2.10 + org.apache.maven.plugins maven-enforcer-plugin 1.4.1 + + org.apache.maven.plugins + maven-failsafe-plugin + 2.19.1 + org.apache.maven.plugins maven-jar-plugin @@ -454,11 +469,21 @@ maven-jxr-plugin 2.5 + + org.apache.maven.plugins + maven-plugin-plugin + 3.4 + org.apache.maven.plugins maven-pmd-plugin 3.6 + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.9 + org.apache.maven.plugins maven-release-plugin @@ -474,6 +499,11 @@ maven-resources-plugin 3.0.0 + + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + org.apache.maven.plugins maven-site-plugin @@ -537,16 +567,31 @@ + + org.apache.servicemix.tooling + depends-maven-plugin + 1.3.1 + org.asciidoctor asciidoctor-maven-plugin 1.5.3 + + org.codehaus.mojo + appassembler-maven-plugin + 1.10 + org.codehaus.mojo build-helper-maven-plugin 1.9.1 + + org.codehaus.mojo + clirr-maven-plugin + 2.7 + org.codehaus.mojo exec-maven-plugin diff --git a/tests/test-jmx/jmx-webapp-it/pom.xml b/tests/test-jmx/jmx-webapp-it/pom.xml index dba7237812c..e5185756c12 100644 --- a/tests/test-jmx/jmx-webapp-it/pom.xml +++ b/tests/test-jmx/jmx-webapp-it/pom.xml @@ -82,7 +82,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.17 @@ -95,7 +94,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 start-jetty diff --git a/tests/test-quickstart/pom.xml b/tests/test-quickstart/pom.xml index e0c26b10f60..11a3998e760 100644 --- a/tests/test-quickstart/pom.xml +++ b/tests/test-quickstart/pom.xml @@ -109,7 +109,6 @@ org.codehaus.mojo appassembler-maven-plugin - 1.7 unix diff --git a/tests/test-webapps/test-jndi-webapp/pom.xml b/tests/test-webapps/test-jndi-webapp/pom.xml index 644a4f93934..67cf9201001 100644 --- a/tests/test-webapps/test-jndi-webapp/pom.xml +++ b/tests/test-webapps/test-jndi-webapp/pom.xml @@ -81,7 +81,6 @@ org.apache.maven.plugins maven-assembly-plugin - 2.2-beta-3 package 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 2726e9eeef1..baf5064ea8e 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 @@ -21,7 +21,7 @@ true - + org.apache.maven.plugins maven-assembly-plugin @@ -62,7 +62,6 @@ - org.apache.felix maven-bundle-plugin @@ -93,7 +92,6 @@ - maven-antrun-plugin @@ -141,24 +139,6 @@ - org.eclipse.jetty jetty-maven-plugin @@ -192,6 +172,7 @@ + javax.transaction From 39ef0ec7d6048537098dd943dd2543c7a4ebc999 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 7 Jun 2016 11:55:48 -0500 Subject: [PATCH 19/21] fix bad test target dir usage --- .../eclipse/jetty/annotations/TestAnnotationConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationConfiguration.java b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationConfiguration.java index 713f2a4a7a9..f6392771418 100644 --- a/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationConfiguration.java +++ b/jetty-annotations/src/test/java/org/eclipse/jetty/annotations/TestAnnotationConfiguration.java @@ -25,6 +25,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.FragmentDescriptor; import org.eclipse.jetty.webapp.WebAppContext; @@ -40,7 +41,7 @@ public class TestAnnotationConfiguration @Test public void testGetFragmentFromJar() throws Exception { - String dir = System.getProperty("basedir", "."); + String dir = MavenTestingUtils.getTargetTestingDir("getFragmentFromJar").getAbsolutePath(); File file = new File(dir); file=new File(file.getCanonicalPath()); URL url=file.toURL(); From ef63395b077570e8d86e4c45cdc1c60a218dc723 Mon Sep 17 00:00:00 2001 From: WalkerWatch Date: Tue, 7 Jun 2016 16:40:24 -0400 Subject: [PATCH 20/21] Removed references to SPDY in Chapter 3, updated Chapter 10 with general info on Sessions Signed-off-by: WalkerWatch --- .../sessions/setting-session-characteristics.adoc | 6 ++++++ .../quick-start/configuring/what-to-configure.adoc | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc b/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc index 9317a27a8fe..eaaf3c7bd2a 100644 --- a/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc +++ b/jetty-documentation/src/main/asciidoc/administration/sessions/setting-session-characteristics.adoc @@ -17,6 +17,12 @@ [[setting-session-characteristics]] === Setting Session Characteristics +Sessions are a concept within the Servlet api which allow requests to store and retrieve information across the time a user spends in an application. +Choosing the correct session manager implementation is an important consideration for every application as each can fit and perform optimally in different situations. +If you need a simple in-memory session manager that can persist to disk then the `HashSessionManager` can be a good place to start. +If you need a session manager that can work in a clustered scenario with multiple instances of Jetty, then the JDBC session manager can be an excellent option. +Jetty also offers more niche session managers that leverage backends such as MongoDB, Inifinispan, or even Google's Cloud Data Store. + To modify the session characteristics of a web application, you can use the following parameters, applying them as in one of the example configurations: [[using-init-parameters]] diff --git a/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc b/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc index 87e430bcfcb..2c12a63c57d 100644 --- a/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc +++ b/jetty-documentation/src/main/asciidoc/quick-start/configuring/what-to-configure.adoc @@ -55,7 +55,7 @@ Services:: ==== Configuring Connectors A Jetty Server Connector is a network end point that accepts connections for one or more protocols which produce requests and/or messages for the Jetty server. -In the standard Jetty server distribution, several provided configuration files add connectors to the server for various protocols and combinations of protocols: `http.ini`, `https.ini` and `jetty-spdy.xml`. +In the standard Jetty server distribution, several provided configuration files add connectors to the server for various protocols and combinations of protocols: `http.ini`, `https.ini` and `jetty-http2.xml`. The configuration needed for connectors is typically: Port:: @@ -67,10 +67,10 @@ Host:: Idle Timeout:: The time in milliseconds that a connection can be idle before the connector takes action to close the connection. HTTP Configuration:: - Connector types that accept HTTP semantics (including HTTP, HTTPS and SPDY) are configured with a HttpConfiguration instance that contains common HTTP configuration that is independent of the specific wire protocol used. - Because these values are often common to multiple connector types, the standard Jetty Server distribution creates a single HttpConfiguration in the `jetty.xml` file which is used via the XML Ref element in the specific connector files. + Connector types that accept HTTP semantics (including HTTP, HTTPS and HTTP2) are configured with a `HttpConfiguration` instance that contains common HTTP configuration that is independent of the specific wire protocol used. + Because these values are often common to multiple connector types, the standard Jetty Server distribution creates a single `HttpConfiguration` in the `jetty.xml` file which is used via the XML Ref element in the specific connector files. SSL Context Factory:: - The TLS connector types (HTTPS and SPDY) configure an SSL Context Factory with the location of the server keystore and truststore for obtaining server certificates. + The TLS connector types (HTTPS and HTTP2) configure an SSL Context Factory with the location of the server keystore and truststore for obtaining server certificates. ____ From 1e239e53a83203fed96629d32422ee103f88bab4 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 7 Jun 2016 15:07:51 -0700 Subject: [PATCH 21/21] Fixing compact3 build --- aggregates/jetty-all-compact3/pom.xml | 58 +++++++++++---------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/aggregates/jetty-all-compact3/pom.xml b/aggregates/jetty-all-compact3/pom.xml index 78d4d9fff0e..89daa3e1091 100644 --- a/aggregates/jetty-all-compact3/pom.xml +++ b/aggregates/jetty-all-compact3/pom.xml @@ -56,15 +56,15 @@ sources **/* - META-INF/** - **/Servlet3Continuation* - **/Jetty6Continuation* - **/AppContextLeakPreventer*.java - **/AWTLeakPreventer*.java - **/IntrospectorCleaner*.java - **/PostConstructAnnotationHandler*.java - **/PreDestroyAnnotationHandler*.java - **/ResourceAnnotationHandler*.java + META-INF/**, + **/Servlet3Continuation*, + **/Jetty6Continuation*, + **/AppContextLeakPreventer*.java, + **/AWTLeakPreventer*.java, + **/IntrospectorCleaner*.java, + **/PostConstructAnnotationHandler*.java, + **/PreDestroyAnnotationHandler*.java, + **/ResourceAnnotationHandler*.java, **/ResourcesAnnotationHandler*.java org.eclipse.jetty,org.eclipse.jetty.websocket @@ -78,32 +78,22 @@ - org.apache.maven.plugins - + org.apache.maven.plugins maven-jar-plugin - - - package - package - - jar - - - - - - - development - http://eclipse.org/jetty - ${user.name} - org.eclipse.jetty - https://raw.githubusercontent.com/eclipse/jetty.project/master/NOTICE.txt - Jetty - - - - - + + + + + + development + https://eclipse.org/jetty + ${user.name} + org.eclipse.jetty + https://raw.githubusercontent.com/eclipse/jetty.project/master/NOTICE.txt + Jetty + + + org.apache.maven.plugins