Merge remote-tracking branch 'origin/jetty-9.3.x'

This commit is contained in:
Greg Wilkins 2016-04-29 16:58:00 +10:00
commit 3e8187dcd5
4 changed files with 67 additions and 48 deletions

View File

@ -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);
}

View File

@ -25,6 +25,17 @@ package org.eclipse.jetty.start;
*/
public class Version implements Comparable<Version>
{
/**
* Original String version
*/
private String string = null;
/**
* Short String version
*/
private String shortString = null;
/**
* The major version for java is always "1" (per
* <a href="http://www.oracle.com/technetwork/java/javase/namechange-140185.html">legacy versioning history</a>)
@ -45,6 +56,12 @@ public class Version implements Comparable<Version>
* 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<Version>
*/
private void parse(String versionStr)
{
string = versionStr;
legacyMajor = 0;
major = -1;
revision = -1;
@ -194,6 +212,8 @@ public class Version implements Comparable<Version>
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<Version>
else if (Character.isLetter(c))
{
suffix = versionStr.substring(offset);
return;
break;
}
switch (state)
@ -231,12 +251,16 @@ public class Version implements Comparable<Version>
break;
case UPDATE:
if (!isSeparator)
{
update = val;
}
break;
}
offset++;
}
if (shortString==null)
shortString=versionStr;
}
/**
@ -245,25 +269,7 @@ public class Version implements Comparable<Version>
@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,24 +278,6 @@ public class Version implements Comparable<Version>
*/
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 && update <10)
{
sb.append("_0").append(update);
}
else if (update >= 0)
{
sb.append('_').append(update);
}
}
}
return sb.toString();
return shortString;
}
}

View File

@ -50,6 +50,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");
@ -61,6 +63,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");
@ -91,7 +109,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);
@ -105,4 +123,6 @@ public class VersionTest
Version vtest = new Version(testver);
assertTrue("Version [" + testver + "] should be newer than [" + basever + "]", vtest.isNewerThan(vbase));
}
}

View File

@ -209,9 +209,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;
@ -384,14 +384,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();
@ -1438,8 +1442,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.
* <p>Set the max cache size to be set on {@link SSLSessionContext#setSessionCacheSize(int)}
* when this factory is started.</p>
* @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)
{
@ -1455,7 +1462,10 @@ public class SslContextFactory extends AbstractLifeCycle
}
/** Set SSL session timeout.
* @param sslSessionTimeout SSL session timeout to set
* <p>Set the timeout in seconds to be set on {@link SSLSessionContext#setSessionTimeout(int)}
* when this factory is started.</p>
* @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)
{