Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-9.4.x-ewyk

This commit is contained in:
Greg Wilkins 2017-03-23 10:27:14 +11:00
commit 7a87c8ec9d
166 changed files with 1904 additions and 224 deletions

View File

@ -1,10 +1,72 @@
jetty-9.4.3-SNAPSHOT
jetty-9.4.4-SNAPSHOT
jetty-9.4.3.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
+ 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ 856 Add server/port and auth configuration for mongo sessions
+ 1015 Ensure jetty-distribution excludes git / temp files
+ 1049 test-jetty-osgi test exits/crashes the surefire forked JVM
+ 1184 IllegalStateException for HEAD requests responded with 404
+ 1340 PushCacheFilter question
+ 1351 StringIndexOutOfBoundsException thrown on incomplete Accept-Language
header
+ 1353 A Large ClasspathPattern results in infinite loop
+ 1357 RolloverFileOutputStream: No rollout performed at midnight
+ 1363 HttpInput.read deadlock (async mode)
+ 1374 When `Server.start` fails, beans ought to be stopped
+ 1375 Support pushed resources in HTTP client
+ 1378 Slow TLS clients may hang the server
+ 1379 Misleading javadoc for initialization of SessionIdPathParameterName
+ 1383 javadoc build on JDK 8u121 fails due to scripts
+ 1384 Expose StatisticsServlet to webapp
+ 1387 Windows and paxexam failure due to "renaming bundle"
+ 1389 Update to gcloud datastore-0.9.4-beta
+ 1390 HashLoginService and "this.web-inf.url" property are incompatible
+ 1394 Default OS Locale/Encoding/Charset can cause test failures
+ 1396 Set-Cookie produced by Jetty is invalid for RFC6265 and Chrome
+ 1398 Ensure all SessionDataStores store lastsaved time
+ 1399 SlowClientTest is failing on CI
+ 1401 HttpOutput.recycle() does not clear the write listener
+ 1402 Move RFC syntax validation to jetty-http Syntax class
+ 1403 Move new CookieCompliance class to jetty-http
+ 1405 Cookie name cannot be blank or null
jetty-9.3.17.v20170317 - 17 March 2017
+ 329 Javadoc for HttpTester and ServletTester needs to reference limited HTTP
version scope
+ 609 websocket ClientCloseTest testServerNoCloseHandshake is failing
+ 1015 Ensure jetty-distribution excludes git / temp files
+ 1047 ReadPendingException and then thread death
+ 1049 test-jetty-osgi test exits/crashes the surefire forked JVM
+ 1282 ByteArrayEndPointTest.testIdle() failure
+ 1296 Introduce HTTP parser "content complete" event
+ 1326 Jetty shutdown command got NullPointerException (http2 module added to
start)
+ 1328 Response.setBufferSize(int) ISE should be more clear on reason
+ 1340 PushCacheFilter question
+ 1342 Improve ByteBufferPool scalability
+ 1351 StringIndexOutOfBoundsException thrown on incomplete Accept-Language
header
+ 1357 RolloverFileOutputStream: No rollout performed at midnight
+ 1374 When `Server.start` fails, beans ought to be stopped
+ 1375 Support pushed resources in HTTP client
+ 1378 Slow TLS clients may hang the server
+ 1383 javadoc build on JDK 8u121 fails due to scripts
+ 1384 Expose StatisticsServlet to webapp
+ 1387 Windows and paxexam failure due to "renaming bundle"
+ 1389 Update to gcloud datastore-0.9.4-beta
+ 1390 HashLoginService and "this.web-inf.url" property are incompatible
+ 1394 Default OS Locale/Encoding/Charset can cause test failures
+ 1396 Set-Cookie produced by Jetty is invalid for RFC6265 and Chrome
+ 1399 SlowClientTest is failing on CI
+ 1401 HttpOutput.recycle() does not clear the write listener
jetty-9.4.2.v20170220 - 20 February 2017
+ 612 Support HTTP Trailer
+ 1047 ReadPendingException and then thread death
+ 1150 Rationalize the session tests
+ 1226 Undefined JETTY_LOGS breaks jetty.sh
+ 1226 Undefined JETTY_LOGS breaks jetty.sh
+ 1282 ByteArrayEndPointTest.testIdle() failure
+ 1284 IllegalStateException updating session inactive interval
+ 1290 http2-hpack not visible in OSGi
@ -80,19 +142,19 @@ jetty-9.4.1.v20170120 - 20 January 2017
with WEB-INF/lib/jetty-http.jar present
+ 1234 onBadMessage called from with handled message
+ 1239 Charset=unknown produces Exception during testing
+ 1242
+ 1242
org.eclipse.jetty.client.HttpRequestAbortTest.testAbortOnCommitWithContent[1]()
results in EofException
+ 1243
+ 1243
org.eclipse.jetty.proxy.ProxyServletFailureTest.testServerException[0]()
results in ServletException
+ 1244
+ 1244
ProxyServletFailureTest.testProxyRequestStallsContentServerIdlesTimeout()
has TimeoutException visible
+ 1248
+ 1248
org.eclipse.jetty.http2.client.StreamResetTest.testServerExceptionConsumesQueuedData
results in visible Stacktrace
+ 1252
+ 1252
HttpClientStreamTest.testInputStreamContentProviderThrowingWhileReading[transport:
HTTPS]() results in Early EOF
+ 1254 9.4.x Server resource handler welcome files forwarding not working
@ -206,6 +268,13 @@ jetty-9.3.15.v20161220 - 20 December 2016
+ 1186 Where can i find SocketConnector .java and
BlockingChannelConnector.java etc?
jetty-9.2.21.v20170120 - 20 January 2017
+ 592 Support no-value Host header in HttpParser
+ 1229 ClassLoader constraint issue when using NativeWebSocketConfiguration
with WEB-INF/lib/jetty-http.jar present
+ 1267 Request.getRemoteUser can throw undeclared IllegalStateException via
DeferredAuthentication & FormAuthenticator
jetty-9.4.0.RC3 - 05 December 2016
+ 1051 NCSARequestLog/RolloverFileOutputStream does not roll day after DST
ends

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-jsp</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apache-jstl</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>example-async-rest</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.example-async-rest</groupId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>example-async-rest</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.example-async-rest</groupId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.examples</groupId>
<artifactId>examples-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.examples</groupId>
<artifactId>examples-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -58,6 +58,7 @@ public class ManyServletContexts
other.addServlet(new ServletHolder(new HelloServlet("YO!")), "*.yo");
server.start();
server.dumpStdErr();
server.join();
}
}

View File

@ -22,7 +22,6 @@ import java.io.File;
import java.lang.management.ManagementFactory;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker;
import org.eclipse.jetty.webapp.WebAppContext;
@ -62,6 +61,8 @@ public class OneWebApp
// Start things up!
server.start();
server.dumpStdErr();
// The use of server.join() the will make the current thread join and
// wait until the server is done executing.
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.eclipse.jetty.examples</groupId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-client</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-server</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-alpn-parent</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-annotations</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-ant</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-core</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-full-servlet</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-servlet</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-websocket</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.cdi</groupId>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-cdi-webapp</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-continuation</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-deploy</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-distribution</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<artifactId>jetty-documentation</artifactId>
<name>Jetty :: Documentation</name>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.fcgi</groupId>
<artifactId>fcgi-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.gcloud</groupId>
<artifactId>gcloud-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -11,6 +11,7 @@
<Arg>
<New id="sessionDataStoreFactory" class="org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory">
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
<Set name="maxRetries"><Property name="jetty.session.gcloud.maxRetries" default="5"/></Set>
<Set name="backoffMs"><Property name="jetty.session.gcloud.backoffMs" default="1000"/></Set>
<Set name="namespace"><Property name="jetty.session.gcloud.namespace" default=""/></Set>

View File

@ -26,6 +26,8 @@ etc/sessions/gcloud/session-store.xml
[ini-template]
## GCloudDatastore Session config
#jetty.session.gracePeriod.seconds=3600
#jetty.session.savePeriod.seconds=0
#jetty.session.gcloud.maxRetries=5
#jetty.session.gcloud.backoffMs=1000
#jetty.session.gcloud.namespace=

View File

@ -548,11 +548,15 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
for (ExpiryInfo item:info)
{
if (StringUtil.isBlank(item.getLastNode()))
{
expired.add(item.getId()); //nobody managing it
}
else
{
if (_context.getWorkerName().equals(item.getLastNode()))
{
expired.add(item.getId()); //we're managing it, we can expire it
}
else
{
if (_lastExpiryCheckTime <= 0)
@ -560,8 +564,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
//our first check, just look for sessions that we managed by another node that
//expired at least 3 graceperiods ago
if (item.getExpiry() < (now - (1000L * (3 * _gracePeriodSec))))
expired.add(item.getId());
}
expired.add(item.getId()); }
else
{
//another node was last managing it, only expire it if it expired a graceperiod ago
@ -655,11 +658,12 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
*/
protected Set<ExpiryInfo> queryExpiryByIndex () throws Exception
{
long now = System.currentTimeMillis();
Set<ExpiryInfo> info = new HashSet<>();
Query<ProjectionEntity> query = Query.newProjectionEntityQueryBuilder()
.setKind(_model.getKind())
.setProjection(_model.getId(), _model.getLastNode(), _model.getExpiry())
.setFilter(CompositeFilter.and(PropertyFilter.gt(_model.getExpiry(), 0), PropertyFilter.le(_model.getExpiry(), System.currentTimeMillis())))
.setFilter(CompositeFilter.and(PropertyFilter.gt(_model.getExpiry(), 0), PropertyFilter.le(_model.getExpiry(), now)))
.setLimit(_maxResults)
.build();
@ -765,7 +769,6 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
{
if (LOG.isDebugEnabled()) LOG.debug("Writing session {} to DataStore", data.getId());
Entity entity = entityFromSession(data, makeKey(id, _context));
//attempt the update with exponential back-off

View File

@ -94,6 +94,7 @@ public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFacto
ds.setMaxRetries(getMaxRetries());
ds.setGracePeriodSec(getGracePeriodSec());
ds.setNamespace(_namespace);
ds.setSavePeriodSec(getSavePeriodSec());
return ds;
}

View File

@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-home</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-http-spi</artifactId>

View File

@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-http</artifactId>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-infinispan</artifactId>

View File

@ -22,6 +22,7 @@
<Set name="cache"><Ref id="cache"/></Set>
<Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispan.idleTimeout.seconds" default="0" /></Set>
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
</New>
</Arg>
</Call>

View File

@ -24,6 +24,7 @@
<Set name="cache"><Ref id="remoteCache"/></Set>
<Set name="infinispanIdleTimeoutSec"><Property name="jetty.session.infinispan.idleTimeout.seconds" default="0" /></Set>
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
</New>
</Arg>
</Call>

View File

@ -25,3 +25,6 @@ Infinispan is an open source project hosted on Github and released under the Apa
http://infinispan.org/
http://www.apache.org/licenses/LICENSE-2.0.html
[ini-template]
#jetty.session.gracePeriod.seconds=3600
#jetty.session.savePeriod.seconds=0

View File

@ -31,8 +31,4 @@ http://www.apache.org/licenses/LICENSE-2.0.html
#jetty.session.infinispan.remoteCacheName=sessions
#jetty.session.infinispan.idleTimeout.seconds=0
#jetty.session.gracePeriod.seconds=3600
#jetty.session.savePeriod.seconds=0

View File

@ -61,6 +61,7 @@ public class InfinispanSessionDataStoreFactory extends AbstractSessionDataStoreF
store.setGracePeriodSec(getGracePeriodSec());
store.setInfinispanIdleTimeoutSec(getInfinispanIdleTimeoutSec());
store.setCache(getCache());
store.setSavePeriodSec(getSavePeriodSec());
return store;
}

View File

@ -2,7 +2,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-io</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jaas</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jaspi</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jmx</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jndi</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jspc-maven-plugin</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-maven-plugin</artifactId>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.memcached</groupId>
<artifactId>memcached-parent</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-nosql</artifactId>

View File

@ -13,6 +13,7 @@
<Set name="dbName"><Property name="jetty.session.mongo.dbName" default="HttpSessions" /></Set>
<Set name="collectionName"><Property name="jetty.session.mongo.collectionName" default="jettySessions" /></Set>
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
<Set name="host"><Property name="jetty.session.mongo.host" default="localhost"/></Set>
<Set name="port"><Property name="jetty.session.mongo.port" default="27017"/></Set>
</New>

View File

@ -13,6 +13,7 @@
<Set name="dbName"><Property name="jetty.session.mongo.dbName" default="HttpSessions" /></Set>
<Set name="collectionName"><Property name="jetty.session.mongo.collectionName" default="jettySessions" /></Set>
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
<Set name="connectionString"><Property name="jetty.session.mongo.connectionString" default="mongodb://localhost"/></Set>
</New>
</Arg>

View File

@ -31,6 +31,7 @@ connection-type?=address
#jetty.session.mongo.dbName=HttpSessions
#jetty.session.mongo.collectionName=jettySessions
#jetty.session.gracePeriod.seconds=3600
#jetty.session.savePeriod.seconds=0
connection-type=address
#jetty.session.mongo.host=localhost

View File

@ -135,6 +135,7 @@ public class MongoSessionDataStoreFactory extends AbstractSessionDataStoreFactor
{
MongoSessionDataStore store = new MongoSessionDataStore();
store.setGracePeriodSec(getGracePeriodSec());
store.setSavePeriodSec(getSavePeriodSec());
Mongo mongo;
if (!StringUtil.isBlank(getConnectionString()))

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-alpn</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-boot-jsp</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-boot</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-httpservice</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-jetty-osgi-context</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-jetty-osgi-server</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-plus</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-proxy</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty</groupId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-rewrite</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-runner</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-security</artifactId>

View File

@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.4.3-SNAPSHOT</version>
<version>9.4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-server</artifactId>

View File

@ -12,6 +12,7 @@
<New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.FileSessionDataStoreFactory">
<Set name="deleteUnrestorableFiles"><Property name="jetty.session.file.deleteUnrestorableFiles" default="false" /></Set>
<Set name="storeDir"><Property name="jetty.session.file.storeDir"/></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
</New>
</Arg>
</Call>

View File

@ -11,6 +11,7 @@
<Arg>
<New id="sessionDataStoreFactory" class="org.eclipse.jetty.server.session.JDBCSessionDataStoreFactory">
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
<Set name="databaseAdaptor">
<Ref id="databaseAdaptor"/>
</Set>

View File

@ -19,4 +19,4 @@ sessions/
[ini-template]
jetty.session.file.storeDir=${jetty.base}/sessions
#jetty.session.file.deleteUnrestorableFiles=false
#jetty.session.savePeriod.seconds=0

View File

@ -23,6 +23,7 @@ db-connection-type?=datasource
##
#jetty.session.gracePeriod.seconds=3600
#jetty.session.savePeriod.seconds=0
## Connection type:Datasource
db-connection-type=datasource

View File

@ -46,18 +46,33 @@ public class ClassLoaderDump implements Dumpable
{
if (_loader==null)
out.append("No ClassLoader\n");
else if (_loader instanceof Dumpable)
{
ContainerLifeCycle.dump(out,indent,Collections.singleton(_loader));
}
else if (_loader instanceof URLClassLoader)
{
out.append(String.valueOf(_loader)).append("\n");
ClassLoader parent = _loader.getParent();
if (parent==null)
ContainerLifeCycle.dump(out,indent,TypeUtil.asList(((URLClassLoader)_loader).getURLs()));
else if (parent == Server.class.getClassLoader())
ContainerLifeCycle.dump(out,indent,TypeUtil.asList(((URLClassLoader)_loader).getURLs()),Collections.singleton(parent.toString()));
else if (parent instanceof Dumpable)
ContainerLifeCycle.dump(out,indent,TypeUtil.asList(((URLClassLoader)_loader).getURLs()),Collections.singleton(parent));
else
ContainerLifeCycle.dump(out,indent,TypeUtil.asList(((URLClassLoader)_loader).getURLs()),Collections.singleton(new ClassLoaderDump(parent)));
}
else
{
out.append(String.valueOf(_loader)).append("\n");
Object parent = _loader.getParent();
if (parent != null)
{
if (_loader instanceof URLClassLoader)
ContainerLifeCycle.dump(out,indent,TypeUtil.asList(((URLClassLoader)_loader).getURLs()),Collections.singleton(parent.toString()));
else
ContainerLifeCycle.dump(out,indent,Collections.singleton(parent.toString()));
}
ClassLoader parent = _loader.getParent();
if (parent==Server.class.getClassLoader())
ContainerLifeCycle.dump(out,indent,Collections.singleton(parent.toString()));
else if (parent instanceof Dumpable)
ContainerLifeCycle.dump(out,indent,Collections.singleton(parent));
else if (parent!=null)
ContainerLifeCycle.dump(out,indent,Collections.singleton(new ClassLoaderDump(parent)));
}
}
}

View File

@ -21,9 +21,12 @@ package org.eclipse.jetty.server.session;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
* AbstractSessionDataStore
@ -32,10 +35,12 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
*/
public abstract class AbstractSessionDataStore extends ContainerLifeCycle implements SessionDataStore
{
final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
protected SessionContext _context; //context associated with this session data store
protected int _gracePeriodSec = 60 * 60; //default of 1hr
protected long _lastExpiryCheckTime = 0; //last time in ms that getExpired was called
protected int _savePeriodSec = 0; //time in sec between saves
/**
* Store the session data persistently.
@ -74,21 +79,33 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem
@Override
public void store(String id, SessionData data) throws Exception
{
if (data == null)
return;
long lastSave = data.getLastSaved();
long savePeriodMs = (_savePeriodSec <=0? 0: TimeUnit.SECONDS.toMillis(_savePeriodSec));
//set the last saved time to now
data.setLastSaved(System.currentTimeMillis());
try
if (LOG.isDebugEnabled())
LOG.debug("Store: id={}, dirty={}, lsave={}, period={}, elapsed={}", id,data.isDirty(), data.getLastSaved(), savePeriodMs, (System.currentTimeMillis()-lastSave));
//save session if attribute changed or never been saved or time between saves exceeds threshold
if (data.isDirty() || (lastSave <= 0) || ((System.currentTimeMillis()-lastSave) > savePeriodMs))
{
//call the specific store method, passing in previous save time
doStore(id, data, lastSave);
data.setDirty(false); //only undo the dirty setting if we saved it
}
catch (Exception e)
{
//reset last save time if save failed
data.setLastSaved(lastSave);
throw e;
//set the last saved time to now
data.setLastSaved(System.currentTimeMillis());
try
{
//call the specific store method, passing in previous save time
doStore(id, data, lastSave);
data.setDirty(false); //only undo the dirty setting if we saved it
}
catch (Exception e)
{
//reset last save time if save failed
data.setLastSaved(lastSave);
throw e;
}
}
}
@ -148,6 +165,37 @@ public abstract class AbstractSessionDataStore extends ContainerLifeCycle implem
}
/**
* @return the savePeriodSec
*/
public int getSavePeriodSec()
{
return _savePeriodSec;
}
/**
* The minimum time in seconds between save operations.
* Saves normally occur every time the last request
* exits as session. If nothing changes on the session
* except for the access time and the persistence technology
* is slow, this can cause delays.
* <p>
* By default the value is 0, which means we save
* after the last request exists. A non zero value
* means that we will skip doing the save if the
* session isn't dirty if the elapsed time since
* the session was last saved does not exceed this
* value.
*
* @param savePeriodSec the savePeriodSec to set
*/
public void setSavePeriodSec(int savePeriodSec)
{
_savePeriodSec = savePeriodSec;
}
/**
* @see java.lang.Object#toString()
*/

View File

@ -28,6 +28,7 @@ public abstract class AbstractSessionDataStoreFactory implements SessionDataStor
{
int _gracePeriodSec;
int _savePeriodSec;
@ -47,6 +48,24 @@ public abstract class AbstractSessionDataStoreFactory implements SessionDataStor
{
_gracePeriodSec = gracePeriodSec;
}
/**
* @return the savePeriodSec
*/
public int getSavePeriodSec()
{
return _savePeriodSec;
}
/**
* @param savePeriodSec the savePeriodSec to set
*/
public void setSavePeriodSec(int savePeriodSec)
{
_savePeriodSec = savePeriodSec;
}
}

View File

@ -153,10 +153,14 @@ public class CachingSessionDataStore extends ContainerLifeCycle implements Sessi
@Override
public void store(String id, SessionData data) throws Exception
{
long lastSaved = data.getLastSaved();
//write to the SessionDataStore first
_store.store(id, data);
//then update the cache with written data
_cache.store(id,data);
//if the store saved it, then update the cache too
if (data.getLastSaved() != lastSaved)
_cache.store(id,data);
}

View File

@ -145,20 +145,17 @@ public class DefaultSessionCache extends AbstractSessionCache
{
for (Session session: _sessions.values())
{
//if we have a backing store and the session is dirty make sure it is written out
//if we have a backing store so give the session to it to write out if necessary
if (_sessionDataStore != null)
{
if (session.getSessionData().isDirty())
session.willPassivate();
try
{
session.willPassivate();
try
{
_sessionDataStore.store(session.getId(), session.getSessionData());
}
catch (Exception e)
{
LOG.warn(e);
}
_sessionDataStore.store(session.getId(), session.getSessionData());
}
catch (Exception e)
{
LOG.warn(e);
}
doDelete (session.getId()); //remove from memory
}

View File

@ -35,9 +35,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.ClassLoadingObjectInputStream;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -120,9 +122,42 @@ public class FileSessionDataStore extends AbstractSessionDataStore
final long now = System.currentTimeMillis();
HashSet<String> expired = new HashSet<String>();
File[] files = _storeDir.listFiles(new FilenameFilter()
{
HashSet<String> idsWithContext = new HashSet<>();
//one pass to get all idWithContext
File [] files = _storeDir.listFiles(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
if (dir != _storeDir)
return false;
//dir may contain files that don't match our naming pattern
if (!match(name))
{
return false;
}
String idWithContext = getIdWithContextFromString(name);
if (!StringUtil.isBlank(idWithContext))
idsWithContext.add(idWithContext);
return true;
}
});
//got the list of all sessionids with their contexts, remove all old files for each one
for (String idWithContext:idsWithContext)
{
deleteOldFiles(_storeDir, idWithContext);
}
//now find sessions that have expired in any context
files = _storeDir.listFiles(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
@ -130,16 +165,15 @@ public class FileSessionDataStore extends AbstractSessionDataStore
return false;
//dir may contain files that don't match our naming pattern
int index = name.indexOf('_');
if (index < 0)
if (!match(name))
return false;
try
{
long expiry = Long.parseLong(name.substring(0, index));
long expiry = getExpiryFromString(name);
return expiry > 0 && expiry < now;
}
catch (NumberFormatException e)
catch (Exception e)
{
return false;
}
@ -184,8 +218,9 @@ public class FileSessionDataStore extends AbstractSessionDataStore
{
public void run ()
{
File file = getFile(_storeDir,id);
//get rid of all but the newest file for a session
File file = deleteOldFiles(_storeDir, getIdWithContext(id));
if (file == null || !file.exists())
{
if (LOG.isDebugEnabled())
@ -197,17 +232,16 @@ public class FileSessionDataStore extends AbstractSessionDataStore
{
SessionData data = load(in);
data.setLastSaved(file.lastModified());
//delete restored file
file.delete();
reference.set(data);
}
catch (UnreadableSessionDataException e)
{
if (isDeleteUnrestorableFiles() && file.exists() && file.getParentFile().equals(_storeDir));
if (isDeleteUnrestorableFiles() && file.exists() && file.getParentFile().equals(_storeDir))
{
file.delete();
LOG.warn("Deleted unrestorable file for session {}", id);
}
exception.set(e);
}
catch (Exception e)
@ -236,13 +270,11 @@ public class FileSessionDataStore extends AbstractSessionDataStore
File file = null;
if (_storeDir != null)
{
//remove any existing file for the session
file = getFile(_storeDir, id);
if (file != null && file.exists())
file.delete();
//remove any existing files for the session
deleteAllFiles(_storeDir, getIdWithContext(id));
//make a fresh file using the latest session expiry
file = new File(_storeDir, getFileNameWithExpiry(data));
file = new File(_storeDir, getIdWithContextAndExpiry(data));
try(FileOutputStream fos = new FileOutputStream(file,false))
{
@ -288,7 +320,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore
@Override
public boolean exists(String id) throws Exception
{
File sessionFile = getFile(_storeDir, id);
File sessionFile = deleteOldFiles(_storeDir, getIdWithContext(id));
if (sessionFile == null || !sessionFile.exists())
return false;
@ -332,19 +364,32 @@ public class FileSessionDataStore extends AbstractSessionDataStore
}
/**
* Get the session id with its context.
*
* @param id identity of session
* @return the filename of the session data store
* @return the session id plus context
*/
private String getFileName (String id)
private String getIdWithContext (String id)
{
return _context.getCanonicalContextPath()+"_"+_context.getVhost()+"_"+id;
}
private String getFileNameWithExpiry (SessionData data)
/**
* Get the session id with its context and its expiry time
* @param data
* @return the session id plus context and expiry
*/
private String getIdWithContextAndExpiry (SessionData data)
{
return ""+data.getExpiry()+"_"+getFileName(data.getId());
return ""+data.getExpiry()+"_"+getIdWithContext(data.getId());
}
/**
* Work out which session id the file relates to.
* @param file the file to check
* @return the session id the file relates to.
*/
private String getIdFromFile (File file)
{
if (file == null)
@ -354,15 +399,73 @@ public class FileSessionDataStore extends AbstractSessionDataStore
return name.substring(name.lastIndexOf('_')+1);
}
/**
* Get the expiry time of the session stored in the file.
* @param file the file from which to extract the expiry time
* @return the expiry time
*/
private long getExpiryFromFile (File file)
{
if (file == null)
return 0;
String name = file.getName();
String s = name.substring(0, name.indexOf('_'));
return getExpiryFromString(file.getName());
}
private long getExpiryFromString (String filename)
{
if (StringUtil.isBlank(filename) || filename.indexOf("_") < 0)
throw new IllegalStateException ("Invalid or missing filename");
String s = filename.substring(0, filename.indexOf('_'));
return (s==null?0:Long.parseLong(s));
}
/**
* Extract the session id and context from the filename.
* @param file the file whose name to use
* @return the session id plus context
*/
private String getIdWithContextFromFile (File file)
{
if (file == null)
return null;
String s = getIdWithContextFromString(file.getName());
return s;
}
/**
* Extract the session id and context from the filename
* @param filename the name of the file to use
* @return the session id plus context
*/
private String getIdWithContextFromString (String filename)
{
if (StringUtil.isBlank(filename) || filename.indexOf('_') < 0)
return null;
return filename.substring(filename.indexOf('_')+1);
}
/**
* Check if the filename matches our session pattern
* @param filename
* @return
*/
private boolean match (String filename)
{
if (StringUtil.isBlank(filename))
return false;
String[] parts = filename.split("_");
//Need at least 4 parts for a valid filename
if (parts.length < 4)
return false;
return true;
}
/**
@ -384,7 +487,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore
{
if (dir != storeDir)
return false;
return (name.contains(getFileName(id)));
return (name.contains(getIdWithContext(id)));
}
});
@ -393,6 +496,97 @@ public class FileSessionDataStore extends AbstractSessionDataStore
return null;
return files[0];
}
private void deleteAllFiles(final File storeDir, final String idInContext)
{
File[] files = storeDir.listFiles (new FilenameFilter() {
/**
* @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
*/
@Override
public boolean accept(File dir, String name)
{
if (dir != storeDir)
return false;
return (name.contains(idInContext));
}
});
//no files for that id
if (files == null || files.length < 1)
return;
//delete all files
for (File f:files)
{
f.delete();
}
}
/**
* Delete all but the most recent file for a given session id in a context.
*
* @param storeDir the directory in which sessions are stored
* @param idWithContext the id of the session
* @return the most recent remaining file for the session, can be null
*/
private File deleteOldFiles (final File storeDir, final String idWithContext)
{
File[] files = storeDir.listFiles (new FilenameFilter() {
/**
* @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
*/
@Override
public boolean accept(File dir, String name)
{
if (dir != storeDir)
return false;
if (!match(name))
return false;
return (name.contains(idWithContext));
}
});
//no file for that session
if (files == null || files.length == 0)
return null;
//delete all but the most recent file
File file = null;
for (File f:files)
{
if (file == null)
file = f;
else
{
//accept the newest file
if (f.lastModified() > file.lastModified())
{
file.delete();
file = f;
}
else
{
f.delete();
}
}
}
return file;
}
/**
* @param is inputstream containing session data

View File

@ -78,6 +78,7 @@ public class FileSessionDataStoreFactory extends AbstractSessionDataStoreFactory
fsds.setDeleteUnrestorableFiles(isDeleteUnrestorableFiles());
fsds.setStoreDir(getStoreDir());
fsds.setGracePeriodSec(getGracePeriodSec());
fsds.setSavePeriodSec(getSavePeriodSec());
return fsds;
}

View File

@ -48,6 +48,7 @@ public class JDBCSessionDataStoreFactory extends AbstractSessionDataStoreFactory
ds.setDatabaseAdaptor(_adaptor);
ds.setSessionTableSchema(_schema);
ds.setGracePeriodSec(getGracePeriodSec());
ds.setSavePeriodSec(getSavePeriodSec());
return ds;
}

View File

@ -0,0 +1,200 @@
//
// ========================================================================
// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import org.eclipse.jetty.util.component.Dumpable;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
public class ClassLoaderDumptTest
{
@Test
public void testSimple() throws Exception
{
Server server = new Server();
ClassLoader loader = new ClassLoader()
{
public String toString()
{
return "SimpleLoader";
}
};
server.addBean(new ClassLoaderDump(loader));
StringBuilder out = new StringBuilder();
server.dump(out);
String dump = out.toString();
assertThat(dump,containsString("+- SimpleLoader"));
assertThat(dump,containsString("+> "+Server.class.getClassLoader()));
}
@Test
public void testParent() throws Exception
{
Server server = new Server();
ClassLoader loader = new ClassLoader(Server.class.getClassLoader())
{
public String toString()
{
return "ParentedLoader";
}
};
server.addBean(new ClassLoaderDump(loader));
StringBuilder out = new StringBuilder();
server.dump(out);
String dump = out.toString();
assertThat(dump,containsString("+- ParentedLoader"));
assertThat(dump,containsString("| +- "+Server.class.getClassLoader()));
assertThat(dump,containsString("+> "+Server.class.getClassLoader()));
}
@Test
public void testNested() throws Exception
{
Server server = new Server();
ClassLoader middleLoader = new ClassLoader(Server.class.getClassLoader())
{
public String toString()
{
return "MiddleLoader";
}
};
ClassLoader loader = new ClassLoader(middleLoader)
{
public String toString()
{
return "TopLoader";
}
};
server.addBean(new ClassLoaderDump(loader));
StringBuilder out = new StringBuilder();
server.dump(out);
String dump = out.toString();
assertThat(dump,containsString("+- TopLoader"));
assertThat(dump,containsString("| +- MiddleLoader"));
assertThat(dump,containsString("| +- "+Server.class.getClassLoader()));
assertThat(dump,containsString("+> "+Server.class.getClassLoader()));
}
@Test
public void testDumpable() throws Exception
{
Server server = new Server();
ClassLoader middleLoader = new DumpableClassLoader(Server.class.getClassLoader());
ClassLoader loader = new ClassLoader(middleLoader)
{
public String toString()
{
return "TopLoader";
}
};
server.addBean(new ClassLoaderDump(loader));
StringBuilder out = new StringBuilder();
server.dump(out);
String dump = out.toString();
assertThat(dump,containsString("+- TopLoader"));
assertThat(dump,containsString("| +- DumpableClassLoader"));
assertThat(dump,not(containsString("| +- "+Server.class.getClassLoader())));
assertThat(dump,containsString("+> "+Server.class.getClassLoader()));
}
public static class DumpableClassLoader extends ClassLoader implements Dumpable
{
public DumpableClassLoader(ClassLoader parent)
{
super(parent);
}
@Override
public String dump()
{
return "DumpableClassLoader";
}
@Override
public void dump(Appendable out, String indent) throws IOException
{
out.append(dump()).append('\n');
}
public String toString()
{
return "DumpableClassLoader";
}
}
@Test
public void testUrlClassLoaders() throws Exception
{
Server server = new Server();
ClassLoader middleLoader = new URLClassLoader(new URL[]
{new URL("file:/one"),new URL("file:/two"),new URL("file:/three"),},
Server.class.getClassLoader())
{
public String toString()
{
return "MiddleLoader";
}
};
ClassLoader loader = new URLClassLoader(new URL[]
{new URL("file:/ONE"),new URL("file:/TWO"),new URL("file:/THREE"),},
middleLoader)
{
public String toString()
{
return "TopLoader";
}
};
server.addBean(new ClassLoaderDump(loader));
StringBuilder out = new StringBuilder();
server.dump(out);
String dump = out.toString();
System.err.println(dump);
assertThat(dump,containsString("+- TopLoader"));
assertThat(dump,containsString("| +- file:/ONE"));
assertThat(dump,containsString("| +- file:/TWO"));
assertThat(dump,containsString("| +- file:/THREE"));
assertThat(dump,containsString("| +- MiddleLoader"));
assertThat(dump,containsString("| +- file:/one"));
assertThat(dump,containsString("| +- file:/two"));
assertThat(dump,containsString("| +- file:/three"));
assertThat(dump,containsString("| +- "+Server.class.getClassLoader()));
assertThat(dump,containsString("+> "+Server.class.getClassLoader()));
}
}

Some files were not shown because too many files have changed in this diff Show More