Merge remote-tracking branch 'origin/jetty-9.3.x'
This commit is contained in:
commit
3e8187dcd5
|
@ -178,7 +178,8 @@ public class ServletContextHandler extends ContextHandler
|
||||||
@Override
|
@Override
|
||||||
public void setHandler(Handler handler)
|
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);
|
super.setHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,17 @@ package org.eclipse.jetty.start;
|
||||||
*/
|
*/
|
||||||
public class Version implements Comparable<Version>
|
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
|
* 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>)
|
* <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)
|
* The update (where bug fixes are placed)
|
||||||
*/
|
*/
|
||||||
private int update = -1;
|
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.
|
* 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")
|
* (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)
|
private void parse(String versionStr)
|
||||||
{
|
{
|
||||||
|
string = versionStr;
|
||||||
legacyMajor = 0;
|
legacyMajor = 0;
|
||||||
major = -1;
|
major = -1;
|
||||||
revision = -1;
|
revision = -1;
|
||||||
|
@ -194,6 +212,8 @@ public class Version implements Comparable<Version>
|
||||||
while (offset < len)
|
while (offset < len)
|
||||||
{
|
{
|
||||||
char c = versionStr.charAt(offset);
|
char c = versionStr.charAt(offset);
|
||||||
|
if (c=='-')
|
||||||
|
shortString=versionStr.substring(0,offset);
|
||||||
boolean isSeparator = !Character.isLetterOrDigit(c);
|
boolean isSeparator = !Character.isLetterOrDigit(c);
|
||||||
if (isSeparator)
|
if (isSeparator)
|
||||||
{
|
{
|
||||||
|
@ -206,7 +226,7 @@ public class Version implements Comparable<Version>
|
||||||
else if (Character.isLetter(c))
|
else if (Character.isLetter(c))
|
||||||
{
|
{
|
||||||
suffix = versionStr.substring(offset);
|
suffix = versionStr.substring(offset);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
|
@ -231,12 +251,16 @@ public class Version implements Comparable<Version>
|
||||||
break;
|
break;
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
if (!isSeparator)
|
if (!isSeparator)
|
||||||
|
{
|
||||||
update = val;
|
update = val;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
if (shortString==null)
|
||||||
|
shortString=versionStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,25 +269,7 @@ public class Version implements Comparable<Version>
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer(10);
|
return string;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,24 +278,6 @@ public class Version implements Comparable<Version>
|
||||||
*/
|
*/
|
||||||
public String toShortString()
|
public String toShortString()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer(10);
|
return shortString;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class VersionTest
|
||||||
{
|
{
|
||||||
assertToShortString("1.8","1.8");
|
assertToShortString("1.8","1.8");
|
||||||
assertToShortString("1.8.0","1.8.0");
|
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","1.8.0_45");
|
||||||
assertToShortString("1.8.0_45-internal","1.8.0_45");
|
assertToShortString("1.8.0_45-internal","1.8.0_45");
|
||||||
assertToShortString("1.8.0-debug","1.8.0");
|
assertToShortString("1.8.0-debug","1.8.0");
|
||||||
|
@ -61,6 +63,22 @@ public class VersionTest
|
||||||
assertThat("Version [" + verStr + "].toShortString", ver.toShortString(), is(expectedShortString));
|
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
|
@Test
|
||||||
public void testNewerVersion() {
|
public void testNewerVersion() {
|
||||||
assertIsNewer("0.0.0", "0.0.1");
|
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.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));
|
assertThat("9.3 >= 9.2",new Version("9.3").isNewerThanOrEqualTo(new Version("9.2")),is(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertIsOlder(String basever, String testver)
|
private void assertIsOlder(String basever, String testver)
|
||||||
{
|
{
|
||||||
Version vbase = new Version(basever);
|
Version vbase = new Version(basever);
|
||||||
|
@ -105,4 +123,6 @@ public class VersionTest
|
||||||
Version vtest = new Version(testver);
|
Version vtest = new Version(testver);
|
||||||
assertTrue("Version [" + testver + "] should be newer than [" + basever + "]", vtest.isNewerThan(vbase));
|
assertTrue("Version [" + testver + "] should be newer than [" + basever + "]", vtest.isNewerThan(vbase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,9 +209,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
/** Set to true to enable SSL Session caching */
|
/** Set to true to enable SSL Session caching */
|
||||||
private boolean _sessionCachingEnabled = true;
|
private boolean _sessionCachingEnabled = true;
|
||||||
/** SSL session cache size */
|
/** SSL session cache size */
|
||||||
private int _sslSessionCacheSize=0;
|
private int _sslSessionCacheSize=-1;
|
||||||
/** SSL session timeout */
|
/** SSL session timeout */
|
||||||
private int _sslSessionTimeout;
|
private int _sslSessionTimeout=-1;
|
||||||
|
|
||||||
/** SSL context */
|
/** SSL context */
|
||||||
private SSLContext _setContext;
|
private SSLContext _setContext;
|
||||||
|
@ -384,14 +384,18 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
||||||
context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider);
|
context = _sslProvider == null ? SSLContext.getInstance(_sslProtocol) : SSLContext.getInstance(_sslProtocol, _sslProvider);
|
||||||
context.init(keyManagers,trustManagers,secureRandom);
|
context.init(keyManagers,trustManagers,secureRandom);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize cache
|
// Initialize cache
|
||||||
SSLSessionContext serverContext=context.getServerSessionContext();
|
SSLSessionContext serverContext=context.getServerSessionContext();
|
||||||
if (serverContext!=null)
|
if (serverContext!=null)
|
||||||
serverContext.setSessionCacheSize(getSslSessionCacheSize());
|
{
|
||||||
|
if (getSslSessionCacheSize()>-1)
|
||||||
|
serverContext.setSessionCacheSize(getSslSessionCacheSize());
|
||||||
|
if (getSslSessionTimeout()>-1)
|
||||||
|
serverContext.setSessionTimeout(getSslSessionTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
// select the protocols and ciphers
|
// select the protocols and ciphers
|
||||||
SSLEngine sslEngine=context.createSSLEngine();
|
SSLEngine sslEngine=context.createSSLEngine();
|
||||||
|
@ -1438,8 +1442,11 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
return _sslSessionCacheSize;
|
return _sslSessionCacheSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** SEt SSL session cache size.
|
/** Set SSL session cache size.
|
||||||
* @param sslSessionCacheSize SSL session cache size to set
|
* <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)
|
public void setSslSessionCacheSize(int sslSessionCacheSize)
|
||||||
{
|
{
|
||||||
|
@ -1455,7 +1462,10 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set SSL session timeout.
|
/** 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)
|
public void setSslSessionTimeout(int sslSessionTimeout)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue