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

This commit is contained in:
Joakim Erdfelt 2017-08-09 16:21:08 -07:00
commit 3ec5f8fa3d
39 changed files with 1188 additions and 85 deletions

View File

@ -1,7 +1,7 @@
Eclipse Jetty Canonical Repository
==================================
This is the canonical repository for the Jetty project, feel free to fork and contribute now!
This is the canonical repository for the Jetty project, feel free to fork and contribute now!
Submitting a patch or pull request?
@ -13,7 +13,7 @@ Project description
-------------------
Jetty is a lightweight highly scalable java based web server and servlet engine.
Our goal is to support web protocols like HTTP, HTTP/2 and WebSocket in a high volume low latency way that provides maximum performance while retaining the ease of use and compatibility with years of servlet development.
Our goal is to support web protocols like HTTP, HTTP/2 and WebSocket in a high volume low latency way that provides maximum performance while retaining the ease of use and compatibility with years of servlet development.
Jetty is a modern fully async web server that has a long history as a component oriented technology easily embedded into applications while still offering a solid traditional distribution for webapp deployment.
- [https://projects.eclipse.org/projects/rt.jetty](https://projects.eclipse.org/projects/rt.jetty)

View File

@ -0,0 +1,8 @@
[name]
protonego-boot
[files]
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar

View File

@ -4,7 +4,7 @@
<parent>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>jetty-cdi-parent</artifactId>
<version>9.3.0-SNAPSHOT</version>
<version>9.4.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cdi-webapp-it</artifactId>

View File

@ -602,23 +602,6 @@ public class DeploymentManager extends ContainerLifeCycle
public void scope(XmlConfiguration xmlc, Resource webapp)
throws IOException
{
xmlc.getIdMap().put("Server", getServer());
Resource home = Resource.newResource(System.getProperty("jetty.home","."));
xmlc.getProperties().put("jetty.home",home.toString());
xmlc.getProperties().put("jetty.home.uri",normalizeURI(home.getURI().toString()));
Resource base = Resource.newResource(System.getProperty("jetty.base",home.toString()));
xmlc.getProperties().put("jetty.base",base.toString());
xmlc.getProperties().put("jetty.base.uri",normalizeURI(base.getURI().toString()));
xmlc.getProperties().put("jetty.webapp",webapp.toString());
xmlc.getProperties().put("jetty.webapps",webapp.getFile().toPath().getParent().toString());
}
private String normalizeURI(String uri)
{
if (uri.endsWith("/"))
return uri.substring(0,uri.length()-1);
return uri;
xmlc.setJettyStandardIdsAndProperties(getServer(),webapp);
}
}

View File

@ -5,12 +5,12 @@ applications to deploy using the following conventions:
+ A directory called example/ will be deployed as a standard web
application if it contains a WEB-INF/ subdirectory, otherwise it will be
deployed as context of static content. The context path will be /example
(eg http://localhost:8080/example/) unless the base name is root, in
which case the context path is /. If the directory name ends with ".d"
it is ignored (by may be used by explicit configuration).
(eg http://localhost:8080/example/) unless the base name is "root" (not
case sensitive), in which case the context path is /. If the directory name
ends with ".d" it is ignored (but may still be used by explicit configuration).
+ A file called example.war will be deployed as a standard web application
with the context path /example (eg http://localhost:8080/example/). If the
with the context path /example (eg http://localhost:8080/example/). If the
base name is root, then the context path is /. If example.war and example/
exist, then only the WAR is deployed (which may use the directory as an
unpack location).

View File

@ -22,6 +22,6 @@ Conscrypt is distributed under the Apache Licence 2.0
https://github.com/google/conscrypt/blob/master/LICENSE
[ini]
conscrypt.version?=1.0.0.RC8
conscrypt.version?=1.0.0.RC9
jetty.sslContext.provider?=AndroidOpenSSL

View File

@ -185,7 +185,7 @@ public class ResourceHttpContent implements HttpContent
public HttpField getContentLength()
{
long l=_resource.length();
return l==-1?null:new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,_resource.length());
return l==-1?null:new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,l);
}
/* ------------------------------------------------------------ */

View File

@ -37,6 +37,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.ReservedThreadExecutor;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.eclipse.jetty.util.thread.strategy.EatWhatYouKill;
/**
@ -57,17 +58,35 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
private final ManagedSelector[] _selectors;
private long _connectTimeout = DEFAULT_CONNECT_TIMEOUT;
private long _selectorIndex;
private int _reservedThreads = -2;
private int _reservedThreads = -1;
public static int defaultSchedulers(Executor executor)
{
if (executor instanceof ThreadPool)
{
int threads = ((ThreadPool)executor).getThreads();
int cpus = Runtime.getRuntime().availableProcessors();
return Math.max(1,Math.min(cpus/2,threads/16));
}
return Math.max(1,Runtime.getRuntime().availableProcessors()/2);
}
protected SelectorManager(Executor executor, Scheduler scheduler)
{
this(executor, scheduler, (Runtime.getRuntime().availableProcessors() + 1) / 2);
this(executor, scheduler, -1);
}
/**
* @param executor The executor to use for handling selected {@link EndPoint}s
* @param scheduler The scheduler to use for timing events
* @param selectors The number of selectors to use, or -1 for a default derived
* from a heuristic over available CPUs and thread pool size.
*/
protected SelectorManager(Executor executor, Scheduler scheduler, int selectors)
{
if (selectors <= 0)
throw new IllegalArgumentException("No selectors");
selectors = defaultSchedulers(executor);
this.executor = executor;
this.scheduler = scheduler;
_selectors = new ManagedSelector[selectors];
@ -110,26 +129,33 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
* Get the number of preallocated producing threads
* @see EatWhatYouKill
* @see ReservedThreadExecutor
* @return The number of threads preallocated to producing (default 1).
* @return The number of threads preallocated to producing (default -1).
*/
@ManagedAttribute("The number of preallocated producer threads")
@ManagedAttribute("The number of reserved producer threads")
public int getReservedThreads()
{
return _reservedThreads;
}
/**
* Set the number of preallocated threads for high priority tasks
* Set the number of reserved threads for high priority tasks.
* <p>Reserved threads are used to take over producing duties, so that a
* producer thread may immediately consume a task it has produced (EatWhatYouKill
* scheduling). If a reserved thread is not available, then produced tasks must
* be submitted to an executor to be executed by a different thread.
* @see EatWhatYouKill
* @see ReservedThreadExecutor
* @param threads The number of producing threads to preallocate (default 1).
* The EatWhatYouKill scheduler will be disabled with a value of 0.
* @param threads The number of producing threads to preallocate. If
* less that 0 (the default), then a heuristic based on the number of CPUs and
* the thread pool size is used to select the number of threads. If 0, no
* threads are preallocated and the EatWhatYouKill scheduler will be
* disabled and all produced tasks will be executed in a separate thread.
*/
public void setReservedThreads(int threads)
{
_reservedThreads = threads;
}
/**
* Executes the given task in a different thread.
*
@ -265,7 +291,7 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
@Override
protected void doStart() throws Exception
{
addBean(new ReservedThreadExecutor(getExecutor(),_reservedThreads==-2?_selectors.length:_reservedThreads),true);
addBean(new ReservedThreadExecutor(getExecutor(),_reservedThreads),true);
for (int i = 0; i < _selectors.length; i++)
{
ManagedSelector selector = newSelector(i);

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>config</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<scope>provided</scope>
<outputDirectory>lib/mail</outputDirectory>
<includes>
<include>org.eclipse.jetty.orbit:javax.mail.glassfish</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/jndi-config</directory>
<outputDirectory></outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@ -3,6 +3,7 @@ Adds the Jetty JNDI implementation to the classpath.
[depend]
server
mail
[lib]
lib/jetty-jndi-${jetty.version}.jar

View File

@ -0,0 +1,8 @@
[description]
Adds the javax.mail implementation to the classpath.
[provides]
mail
[lib]
lib/mail/*.jar

104
jetty-jsp/pom.xml Normal file
View File

@ -0,0 +1,104 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-jsp</artifactId>
<name>Jetty :: Glassfish JSP Implementation</name>
<url>http://www.eclipse.org/jetty</url>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>config</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<!-- Schemas -->
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-schemas</artifactId>
</dependency>
<!-- servlet api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<!-- JSP Api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
</dependency>
<!-- JSP Impl -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp</artifactId>
</dependency>
<!-- JSTL Api -->
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
</dependency>
<!-- JSTL Impl -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
</dependency>
<!-- EL Api -->
<!-- Not needed as glassfish impl jars contain also the api classes
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</dependency>
-->
<!-- EL Impl -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
</dependency>
<!-- Eclipse Java Compiler (for JSP Compilation) -->
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -18,6 +18,17 @@
package org.eclipse.jetty.maven.plugin;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.jetty.util.PathWatcher;
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
import java.io.File;
import java.io.IOException;
import java.net.URL;
@ -30,17 +41,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.jetty.util.PathWatcher;
import org.eclipse.jetty.util.PathWatcher.PathWatchEvent;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.WebAppContext;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/**
* This goal is used in-situ on a Maven project without first requiring that the project
@ -624,7 +626,7 @@ public class JettyRunMojo extends AbstractJettyMojo
}

View File

@ -76,6 +76,10 @@ public class JettyWebAppContext extends WebAppContext
private String _jettyEnvXml;
private List<Overlay> _overlays;
/**
* Set the "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" with a pattern for matching jars on
* container classpath to scan. This is analogous to the WebAppContext.setAttribute() call.
@ -319,6 +323,9 @@ public class JettyWebAppContext extends WebAppContext
{
return _isGenerateQuickStart;
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>config</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<scope>provided</scope>
<outputDirectory>lib/transactions</outputDirectory>
<includes>
<include>javax.transaction:javax.transaction-api</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/plus-config</directory>
<outputDirectory></outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@ -7,6 +7,7 @@ server
security
jndi
webapp
transactions
[lib]
lib/jetty-plus-${jetty.version}.jar

View File

@ -0,0 +1,8 @@
[description]
Puts javax.transaction api on the classpath
[provides]
transactions
[lib]
lib/transactions/*.jar

View File

@ -66,6 +66,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
HttpServletResponse res = (HttpServletResponse)response;
String header = req.getHeader(HttpHeader.AUTHORIZATION.asString());
String authScheme = getAuthSchemeFromHeader(header);
if (!mandatory)
{
@ -73,7 +74,7 @@ public class SpnegoAuthenticator extends LoginAuthenticator
}
// The client has responded to the challenge we sent previously
if (header != null && header.startsWith(HttpHeader.NEGOTIATE.asString().toLowerCase()))
if (header != null && isAuthSchemeNegotiate(authScheme))
{
String spnegoToken = header.substring(10);
@ -106,6 +107,47 @@ public class SpnegoAuthenticator extends LoginAuthenticator
}
}
/**
* Extracts the auth_scheme from the HTTP Authorization header, {@code Authorization: <auth_scheme> <token>}.
*
* @param header The HTTP Authorization header or null.
* @return The parsed auth scheme from the header, or the empty string.
*/
String getAuthSchemeFromHeader(String header)
{
// No header provided, return the empty string
if (header == null || header.isEmpty())
{
return "";
}
// Trim any leading whitespace
String trimmed_header = header.trim();
// Find the first space, all characters prior should be the auth_scheme
int index = trimmed_header.indexOf(' ');
if (index > 0) {
return trimmed_header.substring(0, index);
}
// If we don't find a space, this is likely malformed, just return the entire value
return trimmed_header;
}
/**
* Determines if provided auth scheme text from the Authorization header is case-insensitively
* equal to {@code negotiate}.
*
* @param authScheme The auth scheme component of the Authorization header
* @return True if the auth scheme component is case-insensitively equal to {@code negotiate}, False otherwise.
*/
boolean isAuthSchemeNegotiate(String authScheme)
{
if (authScheme == null || authScheme.length() != HttpHeader.NEGOTIATE.asString().length())
{
return false;
}
// Headers should be treated case-insensitively, so we have to jump through some extra hoops.
return authScheme.equalsIgnoreCase(HttpHeader.NEGOTIATE.asString());
}
@Override
public boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, User validatedUser) throws ServerAuthException
{

View File

@ -19,6 +19,8 @@
package org.eclipse.jetty.security.authentication;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import javax.servlet.http.HttpServletResponse;
@ -110,4 +112,37 @@ public class SpnegoAuthenticatorTest {
assertEquals(HttpHeader.NEGOTIATE.asString(), res.getHeader(HttpHeader.WWW_AUTHENTICATE.asString()));
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, res.getStatus());
}
@Test
public void testCaseInsensitiveHeaderParsing()
{
assertFalse(_authenticator.isAuthSchemeNegotiate(null));
assertFalse(_authenticator.isAuthSchemeNegotiate(""));
assertFalse(_authenticator.isAuthSchemeNegotiate("Basic"));
assertFalse(_authenticator.isAuthSchemeNegotiate("basic"));
assertFalse(_authenticator.isAuthSchemeNegotiate("Digest"));
assertFalse(_authenticator.isAuthSchemeNegotiate("LotsandLotsandLots of nonsense"));
assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiat asdfasdf"));
assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiated"));
assertFalse(_authenticator.isAuthSchemeNegotiate("Negotiate-and-more"));
assertTrue(_authenticator.isAuthSchemeNegotiate("Negotiate"));
assertTrue(_authenticator.isAuthSchemeNegotiate("negotiate"));
assertTrue(_authenticator.isAuthSchemeNegotiate("negOtiAte"));
}
@Test
public void testExtractAuthScheme()
{
assertEquals("", _authenticator.getAuthSchemeFromHeader(null));
assertEquals("", _authenticator.getAuthSchemeFromHeader(""));
assertEquals("", _authenticator.getAuthSchemeFromHeader(" "));
assertEquals("Basic", _authenticator.getAuthSchemeFromHeader(" Basic asdfasdf"));
assertEquals("Basicasdf", _authenticator.getAuthSchemeFromHeader("Basicasdf asdfasdf"));
assertEquals("basic", _authenticator.getAuthSchemeFromHeader(" basic asdfasdf "));
assertEquals("Negotiate", _authenticator.getAuthSchemeFromHeader("Negotiate asdfasdf"));
assertEquals("negotiate", _authenticator.getAuthSchemeFromHeader("negotiate asdfasdf"));
assertEquals("negotiate", _authenticator.getAuthSchemeFromHeader(" negotiate asdfasdf"));
assertEquals("negotiated", _authenticator.getAuthSchemeFromHeader(" negotiated asdfasdf"));
}
}

View File

@ -29,7 +29,7 @@
<Set name="sslSessionTimeout"><Property name="jetty.sslContext.sslSessionTimeout" default="-1"/></Set>
<Set name="RenegotiationAllowed"><Property name="jetty.sslContext.renegotiationAllowed" default="true"/></Set>
<Set name="RenegotiationLimit"><Property name="jetty.sslContext.renegotiationLimit" default="5"/></Set>
<!-- Example of how to configure a PKIX Certificate Path revocation Checker
<Call id="pkixPreferCrls" class="java.security.cert.PKIXRevocationChecker$Option" name="valueOf"><Arg>PREFER_CRLS</Arg></Call>
<Call id="pkixSoftFail" class="java.security.cert.PKIXRevocationChecker$Option" name="valueOf"><Arg>SOFT_FAIL</Arg></Call>
@ -50,5 +50,5 @@
</Call>
<Set name="PkixCertPathChecker"><Ref refid="pkixRevocationChecker"/></Set>
-->
</Configure>

View File

@ -57,6 +57,7 @@ import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestWrapper;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@ -64,7 +65,6 @@ import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.MappingMatch;
import javax.servlet.http.Part;
import javax.servlet.http.PushBuilder;
import javax.servlet.http.HttpServletMapping;
import org.eclipse.jetty.http.BadMessageException;
import org.eclipse.jetty.http.HostPortHttpField;
@ -1369,7 +1369,7 @@ public class Request implements HttpServletRequest
{
MetaData.Request metadata = _metaData;
String name = metadata==null?null:metadata.getURI().getHost();
// Return already determined host
if (name != null)
return name;
@ -1566,7 +1566,7 @@ public class Request implements HttpServletRequest
{
return _originalUri;
}
/* ------------------------------------------------------------ */
/**
* @param uri the URI to set
@ -1734,10 +1734,10 @@ public class Request implements HttpServletRequest
_originalUri = uri.isAbsolute() && request.getHttpVersion()!=HttpVersion.HTTP_2
? uri.toString()
: uri.getPathQuery();
if (uri.getScheme()==null)
uri.setScheme("http");
if (!uri.hasAuthority())
{
HttpField field = getHttpFields().getField(HttpHeader.HOST);
@ -1747,7 +1747,7 @@ public class Request implements HttpServletRequest
uri.setAuthority(authority.getHost(),authority.getPort());
}
}
String encoded = uri.getPath();
String path;
if (encoded==null)
@ -2242,14 +2242,14 @@ public class Request implements HttpServletRequest
_async=new AsyncContextState(state);
AsyncContextEvent event = new AsyncContextEvent(_context,_async,state,this,servletRequest,servletResponse);
event.setDispatchContext(getServletContext());
String uri = ((HttpServletRequest)servletRequest).getRequestURI();
if (uri.startsWith(_contextPath))
uri = uri.substring(_contextPath.length());
else
// TODO probably need to strip encoded context from requestURI, but will do this for now:
uri = URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo()));
uri = URIUtil.encodePath(URIUtil.addPaths(getServletPath(),getPathInfo()));
event.setDispatchPath(uri);
state.startAsync(event);
return _async;
@ -2499,12 +2499,12 @@ public class Request implements HttpServletRequest
match = null;
mapping = _servletPath;
}
return new HttpServletMapping()
{
@Override
public String getMatchValue()
{
{
return mapping;
}

View File

@ -219,8 +219,7 @@ public class ServerConnector extends AbstractNetworkConnector
@Name("factories") ConnectionFactory... factories)
{
super(server,executor,scheduler,bufferPool,acceptors,factories);
_manager = newSelectorManager(getExecutor(), getScheduler(),
selectors>0?selectors:Math.max(1,Math.min(4,Runtime.getRuntime().availableProcessors()/2)));
_manager = newSelectorManager(getExecutor(), getScheduler(),selectors);
addBean(_manager, true);
setAcceptorPriorityDelta(-2);
}

88
jetty-spdy/pom.xml Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-project</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<packaging>pom</packaging>
<name>Jetty :: SPDY :: Parent</name>
<url>http://www.eclipse.org/jetty</url>
<modules>
<module>spdy-core</module>
<module>spdy-client</module>
<module>spdy-server</module>
<module>spdy-http-common</module>
<module>spdy-http-server</module>
<module>spdy-http-client-transport</module>
<module>spdy-example-webapp</module>
<module>spdy-alpn-tests</module>
</modules>
<profiles>
<profile>
<id>npn</id>
<activation>
<jdk>1.7</jdk>
</activation>
<modules>
<!--
<module>spdy-npn-tests</module>
-->
</modules>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.*;version="9.1"</Export-Package>
<Import-Package>org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
<_nouses>true</_nouses>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-alpn-tests</artifactId>
<name>Jetty :: SPDY :: ALPN Tests</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn.version}</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/alpn</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xbootclasspath/p:${project.build.directory}/alpn/alpn-boot-${alpn.version}.jar</argLine>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.alpn</groupId>
<artifactId>alpn-api</artifactId>
<version>${alpn.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-client</artifactId>
<name>Jetty :: SPDY :: Client Binding</name>
<properties>
<bundle-symbolic-name>${project.groupId}.client</bundle-symbolic-name>
</properties>
<url>http://www.eclipse.org/jetty</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.client;version="9.1"</Export-Package>
<Import-Package>!org.eclipse.jetty.npn,!org.eclipse.jetty.alpn,org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.alpn</groupId>
<artifactId>alpn-api</artifactId>
<version>${alpn.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.npn</groupId>
<artifactId>npn-api</artifactId>
<version>${npn.api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-core</artifactId>
<name>Jetty :: SPDY :: Core</name>
<properties>
<bundle-symbolic-name>${project.groupId}.core</bundle-symbolic-name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-example-webapp</artifactId>
<packaging>war</packaging>
<name>Jetty :: SPDY :: HTTP Web Application</name>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<stopPort>8888</stopPort>
<stopKey>quit</stopKey>
<jvmArgs>
-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${npn.version}/npn-boot-${npn.version}.jar
</jvmArgs>
<jettyXml>${basedir}/src/main/config/example-jetty-spdy.xml</jettyXml>
<contextPath>/</contextPath>
<excludedGoals>
<excludedGoal>run</excludedGoal>
<excludedGoal>run-war</excludedGoal>
<excludedGoal>deploy</excludedGoal>
<excludedGoal>start</excludedGoal>
<excludedGoal>stop</excludedGoal>
</excludedGoals>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>proxy</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<stopPort>8888</stopPort>
<stopKey>quit</stopKey>
<jvmArgs>
-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${npn.version}/npn-boot-${npn.version}.jar
</jvmArgs>
<jettyXml>${basedir}/src/main/config/example-jetty-spdy-proxy.xml</jettyXml>
<contextPath>/</contextPath>
<excludedGoals>
<excludedGoal>run</excludedGoal>
<excludedGoal>run-war</excludedGoal>
<excludedGoal>deploy</excludedGoal>
<excludedGoal>start</excludedGoal>
<excludedGoal>stop</excludedGoal>
</excludedGoals>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-http-client-transport</artifactId>
<name>Jetty :: SPDY :: HTTP Client Transport</name>
<properties>
<bundle-symbolic-name>${project.groupId}.client.http</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.client.http;version="9.1"</Export-Package>
<Import-Package>!org.eclipse.jetty.npn,org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-server</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-http-common</artifactId>
<name>Jetty :: SPDY :: HTTP Common</name>
<properties>
<bundle-symbolic-name>${project.groupId}.http.common</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.http;version="9.1"</Export-Package>
<Import-Package>!org.eclipse.jetty.npn,org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-http-server</artifactId>
<name>Jetty :: SPDY :: HTTP Server</name>
<properties>
<bundle-symbolic-name>${project.groupId}.http.server</bundle-symbolic-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>config</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>artifact-jars</id>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.server.http;version="9.1",
org.eclipse.jetty.spdy.server.proxy;version="9.1"
</Export-Package>
<Import-Package>!org.eclipse.jetty.npn,org.eclipse.jetty.*;version="[9.0,10.0)",*
</Import-Package>
<_nouses>true</_nouses>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-http-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.npn</groupId>
<artifactId>npn-api</artifactId>
<version>${npn.api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-parent</artifactId>
<version>9.2.23-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-server</artifactId>
<name>Jetty :: SPDY :: Server Binding</name>
<properties>
<bundle-symbolic-name>${project.groupId}.server</bundle-symbolic-name>
</properties>
<url>http://www.eclipse.org/jetty</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Export-Package>org.eclipse.jetty.spdy.server;version="9.1"</Export-Package>
<Import-Package>org.eclipse.jetty.alpn;resolution:=optional,org.eclipse.jetty.alpn.server;resolution:=optional, org.eclipse.jetty.npn;resolution:=optional,org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
<_nouses>true</_nouses>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.spdy</groupId>
<artifactId>spdy-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.npn</groupId>
<artifactId>npn-api</artifactId>
<version>${npn.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.alpn</groupId>
<artifactId>alpn-api</artifactId>
<version>${alpn.api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,8 @@
[name]
protonego-boot
[files]
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar|lib/alpn/alpn-boot-8.1.11.v20170118.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.11.v20170118.jar

View File

@ -22,13 +22,13 @@ package org.eclipse.jetty.util;
* Parse an authority string into Host and Port
* <p>Parse a string in the form "host:port", handling IPv4 an IPv6 hosts</p>
*
* <p>The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean
* <p>The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean
* value to control of the square brackets are stripped off IPv6 addresses (default true).</p>
*/
public class HostPort
{
private final static boolean STRIP_IPV6 = Boolean.parseBoolean(System.getProperty("org.eclipse.jetty.util.HostPort.STRIP_IPV6","true"));
private final String _host;
private final int _port;

View File

@ -50,12 +50,29 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
/**
* @param executor The executor to use to obtain threads
* @param capacity The number of threads to preallocate. If less than 0 then the number of available processors is used.
* @param capacity The number of threads to preallocate. If less than 0 then capacity
* is calculated based on a heuristic from the number of available processors and
* thread pool size.
*/
public ReservedThreadExecutor(Executor executor,int capacity)
{
_executor = executor;
_queue = new ReservedThread[capacity>=0?capacity:Runtime.getRuntime().availableProcessors()];
if (capacity < 0)
{
if (executor instanceof ThreadPool)
{
int threads = ((ThreadPool)executor).getThreads();
int cpus = Runtime.getRuntime().availableProcessors();
capacity = Math.max(1,Math.min(cpus,threads/8));
}
else
{
capacity = Runtime.getRuntime().availableProcessors();
}
}
_queue = new ReservedThread[capacity];
}
public Executor getExecutor()

View File

@ -83,11 +83,10 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
Object xml_attr=context.getAttribute(XML_CONFIGURATION);
context.removeAttribute(XML_CONFIGURATION);
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration
?(XmlConfiguration)xml_attr
:new XmlConfiguration(jetty.getURI().toURL());
setupXmlConfiguration(jetty_config, web_inf);
final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration?(XmlConfiguration)xml_attr:new XmlConfiguration(jetty.getURI().toURL());
setupXmlConfiguration(context, jetty_config, web_inf);
try
{
WebAppClassLoader.runWithServerClassAccess(()->{jetty_config.configure(context);return null;});
@ -107,11 +106,12 @@ public class JettyWebXmlConfiguration extends AbstractConfiguration
* @param jetty_config The configuration object.
* @param web_inf the WEB-INF location
*/
private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_inf) throws IOException
private void setupXmlConfiguration(WebAppContext context, XmlConfiguration jetty_config, Resource web_inf) throws IOException
{
jetty_config.setJettyStandardIdsAndProperties(context.getServer(),null);
Map<String,String> props = jetty_config.getProperties();
props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURI().toString());
props.put(PROPERTY_WEB_INF_URI, web_inf.getURI().toString());
props.put(PROPERTY_WEB_INF_URI, XmlConfiguration.normalizeURI(web_inf.getURI().toString()));
props.put(PROPERTY_WEB_INF, web_inf.toString());
}
}

View File

@ -0,0 +1,77 @@
//
// ========================================================================
// 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.websocket.server;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
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;
import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.junit.Test;
public class WebSocketServerFactoryTest
{
private int setLogLevel(Class<?> clazz, int newLevel)
{
int oldLevel = StdErrLog.LEVEL_DEFAULT;
Logger logger = Log.getLogger(clazz);
if (logger instanceof StdErrLog)
{
StdErrLog stdErrLog = (StdErrLog) logger;
oldLevel = stdErrLog.getLevel();
stdErrLog.setLevel(newLevel);
}
return oldLevel;
}
@Test
public void testInit()
{
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
Executor executor = new QueuedThreadPool();
ByteBufferPool bufferPool = new MappedByteBufferPool();
int wsFactoryLevel = setLogLevel(WebSocketServerFactory.class, StdErrLog.LEVEL_DEBUG);
int abstractLifecycleLevel = setLogLevel(AbstractLifeCycle.class, StdErrLog.LEVEL_DEBUG);
int containerLifecycleLevel = setLogLevel(ContainerLifeCycle.class, StdErrLog.LEVEL_DEBUG);
try
{
WebSocketServerFactory wsFactory = new WebSocketServerFactory(policy, executor, bufferPool);
// The above init caused NPE due to bad constructor initialization order with debug active
assertThat("wsFactory.toString()", wsFactory.toString(), notNullValue());
}
finally
{
setLogLevel(WebSocketServerFactory.class, wsFactoryLevel);
setLogLevel(AbstractLifeCycle.class, abstractLifecycleLevel);
setLogLevel(ContainerLifeCycle.class, containerLifecycleLevel);
}
}
}

View File

@ -115,6 +115,55 @@ public class XmlConfiguration
return parser;
}
/**
* Set the standard IDs and properties expected in a jetty XML file:
* <ul>
* <li>RefId Server</li>
* <li>Property jetty.home</li>
* <li>Property jetty.home.uri</li>
* <li>Property jetty.base</li>
* <li>Property jetty.base.uri</li>
* <li>Property jetty.webapps</li>
* <li>Property jetty.webapps.uri</li>
* </ul>
* @param server The Server object to set
* @param webapp The webapps Resource
*/
public void setJettyStandardIdsAndProperties(Object server, Resource webapp)
{
try
{
if (server!=null)
getIdMap().put("Server", server);
Resource home = Resource.newResource(System.getProperty("jetty.home","."));
getProperties().put("jetty.home",home.toString());
getProperties().put("jetty.home.uri",normalizeURI(home.getURI().toString()));
Resource base = Resource.newResource(System.getProperty("jetty.base",home.toString()));
getProperties().put("jetty.base",base.toString());
getProperties().put("jetty.base.uri",normalizeURI(base.getURI().toString()));
if (webapp!=null)
{
getProperties().put("jetty.webapp",webapp.toString());
getProperties().put("jetty.webapps",webapp.getFile().toPath().getParent().toString());
getProperties().put("jetty.webapps.uri",normalizeURI(webapp.getURI().toString()));
}
}
catch(Exception e)
{
LOG.warn(e);
}
}
public static String normalizeURI(String uri)
{
if (uri.endsWith("/"))
return uri.substring(0,uri.length()-1);
return uri;
}
private final Map<String, Object> _idMap = new HashMap<>();
private final Map<String, String> _propertyMap = new HashMap<>();
private final URL _url;

View File

@ -23,14 +23,13 @@ package org.eclipse.jetty.server.session;
import java.io.IOException;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -215,7 +214,8 @@ public class SessionEvictionFailureTest
TestServer server = new TestServer (0, inactivePeriod, scavengePeriod, cacheFactory, storeFactory);
ServletContextHandler context = server.addContext(contextPath);
context.getSessionHandler().getSessionCache().setSaveOnInactiveEviction(true);
MockSessionDataStore ds = new MockSessionDataStore(new boolean[] {true, false, true, false, true});
//test values: allow first save, fail evict save, allow save, fail evict save, allow save, allow save on shutdown
MockSessionDataStore ds = new MockSessionDataStore(new boolean[] {true, false, true, false, true, true});
context.getSessionHandler().getSessionCache().setSessionDataStore(ds);
TestServlet servlet = new TestServlet();
@ -242,7 +242,6 @@ public class SessionEvictionFailureTest
//should remain in the cache
pause(evictionPeriod+(int)(evictionPeriod*0.5));
// Make another request to see if the session is still in the cache and can be used,
//allow it to be saved this time
Request request = client.newRequest(url + "?action=test");
@ -250,11 +249,9 @@ public class SessionEvictionFailureTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertNull(response.getHeaders().get("Set-Cookie")); //check that the cookie wasn't reset
//Wait for the eviction period to expire again
pause(evictionPeriod+(int)(evictionPeriod*0.5));
request = client.newRequest(url + "?action=test");
response = request.send();
assertEquals(HttpServletResponse.SC_OK,response.getStatus());