You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2018/02/26 14:27:48 UTC
svn commit: r1825378 - in /felix/trunk/osgi-r7/http:
itest/src/test/java/org/apache/felix/http/itest/ jetty/
jetty/src/main/java/org/apache/felix/http/jetty/internal/
Author: cziegeler
Date: Mon Feb 26 14:27:48 2018
New Revision: 1825378
URL: http://svn.apache.org/viewvc?rev=1825378&view=rev
Log:
FELIX-5793 : Update to Jetty 9.4.x
Modified:
felix/trunk/osgi-r7/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
felix/trunk/osgi-r7/http/jetty/pom.xml
felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
Modified: felix/trunk/osgi-r7/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java?rev=1825378&r1=1825377&r2=1825378&view=diff
==============================================================================
--- felix/trunk/osgi-r7/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java (original)
+++ felix/trunk/osgi-r7/http/itest/src/test/java/org/apache/felix/http/itest/BaseIntegrationTest.java Mon Feb 26 14:27:48 2018
@@ -314,6 +314,8 @@ public abstract class BaseIntegrationTes
),
// CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787"),
+ // scavenge sessions every 10 seconds (10 minutes is default in 9.4.x)
+ systemProperty("org.eclipse.jetty.servlet.SessionScavengingInterval").value("10"),
mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.5"),
mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.5"),
Modified: felix/trunk/osgi-r7/http/jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/http/jetty/pom.xml?rev=1825378&r1=1825377&r2=1825378&view=diff
==============================================================================
--- felix/trunk/osgi-r7/http/jetty/pom.xml (original)
+++ felix/trunk/osgi-r7/http/jetty/pom.xml Mon Feb 26 14:27:48 2018
@@ -41,7 +41,7 @@
<!-- Skip because of problems with Java 8 -->
<animal.sniffer.skip>true</animal.sniffer.skip>
<felix.java.version>8</felix.java.version>
- <jetty.version>9.3.22.v20171030</jetty.version>
+ <jetty.version>9.4.8.v20171121</jetty.version>
</properties>
<build>
Modified: felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java?rev=1825378&r1=1825377&r2=1825378&view=diff
==============================================================================
--- felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java (original)
+++ felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java Mon Feb 26 14:27:48 2018
@@ -21,6 +21,7 @@ package org.apache.felix.http.jetty.inte
import java.io.InputStream;
import java.util.ArrayList;
+import org.eclipse.jetty.server.session.HouseKeeper;
import org.osgi.framework.Bundle;
import org.osgi.service.metatype.AttributeDefinition;
import org.osgi.service.metatype.MetaTypeProvider;
@@ -315,6 +316,12 @@ class ConfigMetaTypeProvider implements
-1,
bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_MAX_AGE)));
+ adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_SERVLET_SESSION_MAX_AGE,
+ "Session Scavenging Interval",
+ "Interval of session scavenging in seconds. Default is " + String.valueOf(HouseKeeper.DEFAULT_PERIOD_MS / 1000),
+ HouseKeeper.DEFAULT_PERIOD_MS / 1000,
+ bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_SESSION_SCAVENGING_INTERVAL)));
+
adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_HTTP_SERVICE_NAME,
"HTTP Service Name",
"HTTP Service Name used in service filter to target specific HTTP instance. Default is null.",
@@ -386,6 +393,12 @@ class ConfigMetaTypeProvider implements
this( id, name, description, STRING, defaultValue == null ? null : new String[] { defaultValue }, 0, null, null, overrideValue == null ? null : new String[] { overrideValue } );
}
+ AttributeDefinitionImpl( final String id, final String name, final String description, final long defaultValue, final String overrideValue )
+ {
+ this( id, name, description, LONG, new String[]
+ { String.valueOf(defaultValue) }, 0, null, null, overrideValue == null ? null : new String[] { overrideValue } );
+ }
+
AttributeDefinitionImpl( final String id, final String name, final String description, final int defaultValue, final String overrideValue )
{
this( id, name, description, INTEGER, new String[]
Modified: felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1825378&r1=1825377&r2=1825378&view=diff
==============================================================================
--- felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java (original)
+++ felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java Mon Feb 26 14:27:48 2018
@@ -162,6 +162,9 @@ public final class JettyConfig
/** Felix specific property to configure session max age */
public static final String FELIX_JETTY_SERVLET_SESSION_MAX_AGE = "org.eclipse.jetty.servlet.MaxAge";
+ /** Felix specific property to configure session scavenging interval in Seconds */
+ public static final String FELIX_JETTY_SESSION_SCAVENGING_INTERVAL = "org.eclipse.jetty.servlet.SessionScavengingInterval";
+
/** Felix specific property to set HTTP instance name. */
public static final String FELIX_HTTP_SERVICE_NAME = "org.apache.felix.http.name";
@@ -333,6 +336,16 @@ public final class JettyConfig
return parseInt(getProperty(name, null), defValue);
}
+ /**
+ * Returns the named generic configuration property from the
+ * configuration or the bundle context. If neither property is defined
+ * return the defValue.
+ */
+ public long getLongProperty(String name, long defValue)
+ {
+ return parseLong(getProperty(name, null), defValue);
+ }
+
public String getKeyPassword()
{
return getProperty(FELIX_KEYSTORE_KEY_PASSWORD, this.context.getProperty(OSCAR_KEYSTORE_KEY_PASSWORD));
@@ -471,7 +484,7 @@ public final class JettyConfig
}
public String getRequestLogFilter() {
- return (String) getProperty(FELIX_HTTP_REQUEST_LOG_FILTER, null);
+ return getProperty(FELIX_HTTP_REQUEST_LOG_FILTER, null);
}
public boolean isRequestLogOSGiEnabled() {
@@ -487,11 +500,11 @@ public final class JettyConfig
}
public String getRequestLogFilePath() {
- return (String) getProperty(FELIX_HTTP_REQUEST_LOG_FILE_PATH, null);
+ return getProperty(FELIX_HTTP_REQUEST_LOG_FILE_PATH, null);
}
public String getRequestLogFileServiceName() {
- return (String) getProperty(FELIX_HTTP_REQUEST_LOG_FILE_SERVICE_NAME, "file");
+ return getProperty(FELIX_HTTP_REQUEST_LOG_FILE_SERVICE_NAME, "file");
}
public boolean isRequestLogFileAsync() {
@@ -507,7 +520,7 @@ public final class JettyConfig
}
public String getRequestLogFilenameDateFormat() {
- return (String) getProperty(FELIX_HTTP_REQUEST_LOG_FILE_FILENAME_DATE_FORMAT, null);
+ return getProperty(FELIX_HTTP_REQUEST_LOG_FILE_FILENAME_DATE_FORMAT, null);
}
public boolean isRequestLogFileExtended() {
@@ -774,4 +787,15 @@ public final class JettyConfig
}
}
+ private long parseLong(String value, long dflt)
+ {
+ try
+ {
+ return Long.parseLong(value);
+ }
+ catch (NumberFormatException e)
+ {
+ return dflt;
+ }
+ }
}
Modified: felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1825378&r1=1825377&r2=1825378&view=diff
==============================================================================
--- felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/osgi-r7/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Mon Feb 26 14:27:48 2018
@@ -50,10 +50,10 @@ import org.eclipse.jetty.server.HttpConn
import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.StatisticsHandler;
+import org.eclipse.jetty.server.session.HouseKeeper;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
@@ -385,6 +385,7 @@ public final class JettyService extends
this.controller.getEventDispatcher().setActive(true);
context.addEventListener(controller.getEventDispatcher());
context.getSessionHandler().addEventListener(controller.getEventDispatcher());
+
final ServletHolder holder = new ServletHolder(this.controller.createDispatcherServlet());
holder.setAsyncSupported(true);
context.addServlet(holder, "/*");
@@ -400,6 +401,11 @@ public final class JettyService extends
this.server.setHandler(this.parent);
this.server.start();
+ // session id manager is only available after server is started
+ context.getSessionHandler().getSessionIdManager().getSessionHouseKeeper().setIntervalSec(
+ this.config.getLongProperty(JettyConfig.FELIX_JETTY_SESSION_SCAVENGING_INTERVAL,
+ HouseKeeper.DEFAULT_PERIOD_MS / 1000L));
+
if (this.config.isProxyLoadBalancerConnection())
{
customizerWrapper = new CustomizerWrapper();
@@ -635,24 +641,19 @@ public final class JettyService extends
config.setSendXPoweredBy(this.config.isSendServerHeader());
connFactory.setInputBufferSize(this.config.getRequestBufferSize());
-
- //Changed from 8.x to 9.x
- //maxIdleTime -> ServerConnector.setIdleTimeout
- //requestBufferSize -> HttpConnectionFactory.setInputBufferSize
- //statsOn -> ServerConnector.addBean(new ConnectionStatistics());
}
- private void configureSessionManager(final ServletContextHandler context)
+ private void configureSessionManager(final ServletContextHandler context) throws Exception
{
final SessionHandler sessionHandler = context.getSessionHandler();
- sessionHandler.getSessionManager().setMaxInactiveInterval(this.config.getSessionTimeout() * 60);
- sessionHandler.getSessionManager().setSessionIdPathParameterName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_ID_PATH_PARAMETER_NAME, SessionManager.__DefaultSessionIdPathParameterName));
- sessionHandler.getSessionManager().setCheckingRemoteSessionIdEncoding(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SERVLET_CHECK_REMOTE_SESSION_ENCODING, true));
- sessionHandler.getSessionManager().setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
-
- final SessionCookieConfig cookieConfig = sessionHandler.getSessionManager().getSessionCookieConfig();
- cookieConfig.setName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_COOKIE_NAME, SessionManager.__DefaultSessionCookie));
- cookieConfig.setDomain(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_DOMAIN, SessionManager.__DefaultSessionDomain));
+ sessionHandler.setMaxInactiveInterval(this.config.getSessionTimeout() * 60);
+ sessionHandler.setSessionIdPathParameterName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_ID_PATH_PARAMETER_NAME, SessionHandler.__DefaultSessionIdPathParameterName));
+ sessionHandler.setCheckingRemoteSessionIdEncoding(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SERVLET_CHECK_REMOTE_SESSION_ENCODING, true));
+ sessionHandler.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
+
+ final SessionCookieConfig cookieConfig = sessionHandler.getSessionCookieConfig();
+ cookieConfig.setName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_COOKIE_NAME, SessionHandler.__DefaultSessionCookie));
+ cookieConfig.setDomain(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_DOMAIN, SessionHandler.__DefaultSessionDomain));
cookieConfig.setPath(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_PATH, context.getContextPath()));
cookieConfig.setMaxAge(this.config.getIntProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_MAX_AGE, -1));
cookieConfig.setHttpOnly(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SESSION_COOKIE_HTTP_ONLY, true));