From a377b3a8f3298ccc2ae20b499059320a8f366699 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 28 Apr 2016 14:30:20 +1000 Subject: [PATCH 1/5] Issue #529 Support zero padded version updates --- .../java/org/eclipse/jetty/start/Version.java | 62 ++++++++----------- .../org/eclipse/jetty/start/VersionTest.java | 22 ++++++- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java index c9fceee34a1..fa808587d22 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Version.java @@ -25,6 +25,17 @@ package org.eclipse.jetty.start; */ public class Version implements Comparable { + + /** + * Original String version + */ + private String string = null; + + /** + * Short String version + */ + private String shortString = null; + /** * The major version for java is always "1" (per * legacy versioning history) @@ -45,6 +56,12 @@ public class Version implements Comparable * The update (where bug fixes are placed) */ private int update = -1; + + /** + * Update strings may be zero padded! + */ + private String updateString = null; + /** * Extra versioning information present on the version string, but not relevant for version comparison reason. * (eg: with "1.8.0_45-internal", the suffix would be "-internal") @@ -181,6 +198,7 @@ public class Version implements Comparable */ private void parse(String versionStr) { + string = versionStr; legacyMajor = 0; major = -1; revision = -1; @@ -194,6 +212,8 @@ public class Version implements Comparable while (offset < len) { char c = versionStr.charAt(offset); + if (c=='-') + shortString=versionStr.substring(0,offset); boolean isSeparator = !Character.isLetterOrDigit(c); if (isSeparator) { @@ -206,7 +226,7 @@ public class Version implements Comparable else if (Character.isLetter(c)) { suffix = versionStr.substring(offset); - return; + break; } switch (state) @@ -231,12 +251,16 @@ public class Version implements Comparable break; case UPDATE: if (!isSeparator) + { update = val; + } break; } offset++; } + if (shortString==null) + shortString=versionStr; } /** @@ -245,25 +269,7 @@ public class Version implements Comparable @Override public String toString() { - StringBuffer sb = new StringBuffer(10); - sb.append(legacyMajor); - if (major >= 0) - { - sb.append('.').append(major); - if (revision >= 0) - { - sb.append('.').append(revision); - if (update >= 0) - { - sb.append('_').append(update); - } - } - } - if (Utils.isNotBlank(suffix)) - { - sb.append('-').append(suffix); - } - return sb.toString(); + return string; } /** @@ -272,20 +278,6 @@ public class Version implements Comparable */ public String toShortString() { - StringBuffer sb = new StringBuffer(10); - sb.append(legacyMajor); - if (major >= 0) - { - sb.append('.').append(major); - if (revision >= 0) - { - sb.append('.').append(revision); - if (update >= 0) - { - sb.append('_').append(update); - } - } - } - return sb.toString(); + return shortString; } } diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java index 4fa8065d748..63ebe0a774e 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java @@ -49,6 +49,8 @@ public class VersionTest { assertToShortString("1.8","1.8"); assertToShortString("1.8.0","1.8.0"); + assertToShortString("1.8.0_3","1.8.0_3"); + assertToShortString("1.8.0_03","1.8.0_03"); assertToShortString("1.8.0_45","1.8.0_45"); assertToShortString("1.8.0_45-internal","1.8.0_45"); assertToShortString("1.8.0-debug","1.8.0"); @@ -60,6 +62,22 @@ public class VersionTest assertThat("Version [" + verStr + "].toShortString", ver.toShortString(), is(expectedShortString)); } + @Test + public void testToString() + { + assertToString("1.8"); + assertToString("1.8.0"); + assertToString("1.8.0_0"); + assertToString("1.8.0_3"); + assertToString("1.8.0_03"); + } + + private void assertToString(String verStr) + { + Version ver = new Version(verStr); + assertThat("Version [" + verStr + "].toString", ver.toString(), is(verStr)); + } + @Test public void testNewerVersion() { assertIsNewer("0.0.0", "0.0.1"); @@ -90,7 +108,7 @@ public class VersionTest assertThat("9.2 >= 9.3",new Version("9.2").isNewerThanOrEqualTo(new Version("9.3")),is(false)); assertThat("9.3 >= 9.2",new Version("9.3").isNewerThanOrEqualTo(new Version("9.2")),is(true)); } - + private void assertIsOlder(String basever, String testver) { Version vbase = new Version(basever); @@ -104,4 +122,6 @@ public class VersionTest Version vtest = new Version(testver); assertTrue("Version [" + testver + "] should be newer than [" + basever + "]", vtest.isNewerThan(vbase)); } + + } From d38bdb6e7c3154c16c7d31bdb1d8786483a778c2 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 28 Apr 2016 15:17:28 +1000 Subject: [PATCH 2/5] 486530 - Handler added to WebAppContext prevents ServletContext initialization Fixed needless warnings during destroy --- .../java/org/eclipse/jetty/servlet/ServletContextHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index 3b23ec4f3d2..3d8f498fc1f 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -178,7 +178,8 @@ public class ServletContextHandler extends ContextHandler @Override public void setHandler(Handler handler) { - LOG.warn("ServletContextHandler.setHandler should not be called directly. Use insertHandler or setSessionHandler etc."); + if (handler!=null) + LOG.warn("ServletContextHandler.setHandler should not be called directly. Use insertHandler or setSessionHandler etc."); super.setHandler(handler); } From 88c133978434530451a2c1c5cdd17f5e08e33694 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 29 Apr 2016 08:02:41 +1000 Subject: [PATCH 3/5] Issue #519 Disable SSL session caching Improve the configuration of the SSL session cache --- .../jetty/util/ssl/SslContextFactory.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index e0a87a77ed4..d8b926d8ab8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -385,14 +385,18 @@ public class SslContextFactory extends AbstractLifeCycle SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm); context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider); context.init(keyManagers,trustManagers,secureRandom); - } } // Initialize cache SSLSessionContext serverContext=context.getServerSessionContext(); if (serverContext!=null) - serverContext.setSessionCacheSize(getSslSessionCacheSize()); + { + if (getSslSessionCacheSize()>-1) + serverContext.setSessionCacheSize(getSslSessionCacheSize()); + if (getSslSessionTimeout()>-1) + serverContext.setSessionTimeout(getSslSessionTimeout()); + } // select the protocols and ciphers SSLEngine sslEngine=context.createSSLEngine(); @@ -1429,8 +1433,11 @@ public class SslContextFactory extends AbstractLifeCycle return _sslSessionCacheSize; } - /** SEt SSL session cache size. - * @param sslSessionCacheSize SSL session cache size to set + /** Set SSL session cache size. + *

Set the max cache size to be set on {@link SSLSessionContext#setSessionCacheSize(int)} + * when this factory is started.

+ * @param sslSessionCacheSize SSL session cache size to set. A value of -1 (default) uses + * the JVM default, 0 means unlimited and positive number is a max size. */ public void setSslSessionCacheSize(int sslSessionCacheSize) { @@ -1446,7 +1453,10 @@ public class SslContextFactory extends AbstractLifeCycle } /** Set SSL session timeout. - * @param sslSessionTimeout SSL session timeout to set + *

Set the timeout in seconds to be set on {@link SSLSessionContext#setSessionTimeout(int)} + * when this factory is started.

+ * @param sslSessionTimeout SSL session timeout to set in seconds. A value of -1 (default) uses + * the JVM default, 0 means unlimited and positive number is a timeout in seconds. */ public void setSslSessionTimeout(int sslSessionTimeout) { From c74dd571fac8977bf0a81489df5fa2f9abd613d1 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 29 Apr 2016 08:10:18 +1000 Subject: [PATCH 4/5] Issue #519 Disable SSL session caching Set -1 defaults for session caching --- .../java/org/eclipse/jetty/util/ssl/SslContextFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index d8b926d8ab8..ff7387521e8 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -210,9 +210,9 @@ public class SslContextFactory extends AbstractLifeCycle /** Set to true to enable SSL Session caching */ private boolean _sessionCachingEnabled = true; /** SSL session cache size */ - private int _sslSessionCacheSize=0; + private int _sslSessionCacheSize=-1; /** SSL session timeout */ - private int _sslSessionTimeout; + private int _sslSessionTimeout=-1; /** SSL context */ private SSLContext _setContext; From 480aa4d8747ab6032c004e0a75c0090a42ca4c13 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 29 Apr 2016 10:22:09 +1000 Subject: [PATCH 5/5] Issue #534 Remove synchronization around session iteration when checking for idle sessions. --- .../jetty/nosql/mongodb/MongoSessionManager.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java index 2f773705e95..5e12ab81e3d 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionManager.java @@ -602,16 +602,14 @@ public class MongoSessionManager extends NoSqlSessionManager long idleMs = getIdlePeriod()*1000L; long now = System.currentTimeMillis(); - - synchronized (this) //necessary? + + + for (NoSqlSession session:_sessions.values()) { - for (NoSqlSession session:_sessions.values()) + if (session.getAccessed()+ idleMs < now) { - if (session.getAccessed()+ idleMs < now) - { - //idle the session by passivating the session to mongo, then clearing the session's attribute map in memory - session.idle(); - } + //idle the session by passivating the session to mongo, then clearing the session's attribute map in memory + session.idle(); } } }