Merged branch 'jetty-9.4.x' into 'jetty-9.4.x-2796-http2_max_concurrent_streams',

This commit is contained in:
Simone Bordet 2018-10-18 16:56:13 +02:00
commit 276fa7e86b
44 changed files with 689 additions and 297 deletions

54
Jenkinsfile vendored
View File

@ -22,58 +22,11 @@ def getFullBuild(jdk, os) {
def settingsName = 'oss-settings.xml'
def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true'
try {
stage("Checkout - ${jdk}") {
checkout scm
}
} catch (Exception e) {
notifyBuild("Checkout Failure", jdk)
throw e
}
try {
stage("Compile - ${jdk}") {
timeout(time: 15, unit: 'MINUTES') {
withMaven(
maven: mvnName,
jdk: "$jdk",
publisherStrategy: 'EXPLICIT',
globalMavenSettingsConfig: settingsName,
mavenOpts: mavenOpts,
mavenLocalRepo: localRepo) {
sh "mvn -V -B clean install -DskipTests -T6 -e"
}
}
}
} catch(Exception e) {
notifyBuild("Compile Failure", jdk)
throw e
}
try {
stage("Javadoc - ${jdk}") {
timeout(time: 20, unit: 'MINUTES') {
withMaven(
maven: mvnName,
jdk: "$jdk",
publisherStrategy: 'EXPLICIT',
globalMavenSettingsConfig: settingsName,
mavenOpts: mavenOpts,
mavenLocalRepo: localRepo) {
sh "mvn -V -B javadoc:javadoc -T6 -e"
}
}
}
} catch(Exception e) {
notifyBuild("Javadoc Failure", jdk)
throw e
}
try {
stage("Test - ${jdk}") {
stage("Build ${jdk}/${os}") {
timeout(time: 90, unit: 'MINUTES') {
// Run test phase / ignore test failures
checkout scm
withMaven(
maven: mvnName,
jdk: "$jdk",
@ -83,6 +36,7 @@ def getFullBuild(jdk, os) {
mavenOpts: mavenOpts,
mavenLocalRepo: localRepo) {
sh "mvn -V -B install -Dmaven.test.failure.ignore=true -e -Pmongodb -T3 -Djetty.testtracker.log=true -Dunix.socket.tmp="+env.JENKINS_HOME
sh "mvn -V -B javadoc:javadoc -T6 -e"
}
// withMaven doesn't label..
// Report failures in the jenkins UI
@ -112,6 +66,8 @@ def getFullBuild(jdk, os) {
consoleParsers = [[parserName: 'Maven'],
[parserName: 'JavaDoc'],
[parserName: 'JavaC']];
step([$class: 'MavenInvokerRecorder', reportsFilenamePattern: "**/target/invoker-reports/BUILD*.xml",
invokerBuildDir: "**/target/its"])
}
// Report on Maven and Javadoc warnings

View File

@ -99,6 +99,17 @@ jetty-9.3.25.v20180904 - 04 September 2018
+ 2860 Leakage of HttpDestinations in HttpClient
+ 2871 Server reads -1 after client resets HTTP/2 stream
jetty-9.2.26.v20180806 - 06 August 2018
+ 2777 Workaround for Conscrypt's ssl == null
jetty-9.2.25.v20180606 - 06 June 2018
+ 2114 Fix NPE in JettyHttpServerProvider
+ 2135 Android 8.1 needs direct buffers for SSL/TLS to work
+ 2529 HttpParser cleanup
+ 2603 WebSocket ByteAccumulator initialized with wrong maximum
+ 2604 WebSocket ByteAccumulator should report sizes in
MessageTooLargeException
jetty-9.4.11.v20180605 - 05 June 2018
+ 1785 Support for vhost@connectorname syntax of virtual hosts
+ 2346 Revert stack trace logging for HTTPChannel.onException

View File

@ -10,7 +10,8 @@
<url>http://www.eclipse.org/jetty</url>
<packaging>jar</packaging>
<properties>
<bundle-symbolic-name>${project.groupId}.${project.artifactId}</bundle-symbolic-name>
<bundle-symbolic-name>${project.groupId}.apache-jsp</bundle-symbolic-name>
<jpms-module-name>${project.groupId}.apache.jsp</jpms-module-name>
</properties>
<build>
<plugins>

View File

@ -0,0 +1,7 @@
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
[files]
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.13.v20181017|lib/alpn/alpn-boot-8.1.13.v20181017.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.13.v20181017.jar

View File

@ -0,0 +1,7 @@
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
[files]
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.13.v20181017|lib/alpn/alpn-boot-8.1.13.v20181017.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.13.v20181017.jar

View File

@ -13,3 +13,6 @@ lib/annotations/*.jar
[xml]
# Enable annotation scanning webapp configurations
etc/jetty-annotations.xml
[jpms]
add-modules:org.objectweb.asm

View File

@ -24,7 +24,6 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -36,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jetty.util.JavaVersion;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.ManifestUtils;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.MultiReleaseJarFile;
import org.eclipse.jetty.util.log.Log;
@ -69,9 +69,9 @@ import org.objectweb.asm.Opcodes;
public class AnnotationParser
{
private static final Logger LOG = Log.getLogger(AnnotationParser.class);
protected static int ASM_OPCODE_VERSION = Opcodes.ASM6; //compatibility of api
protected static String ASM_OPCODE_VERSION_STR = "ASM6";
private static final int ASM_OPCODE_VERSION = Opcodes.ASM6; //compatibility of api
private static final String ASM_OPCODE_VERSION_STR = "ASM6";
/**
* Map of classnames scanned and the first location from which scan occurred
*/
@ -86,48 +86,44 @@ public class AnnotationParser
public static int asmVersion ()
{
int asmVersion = ASM_OPCODE_VERSION;
Package asm = Opcodes.class.getPackage();
if (asm == null)
LOG.warn("Unknown asm runtime version, assuming version {}", ASM_OPCODE_VERSION_STR);
String version = ManifestUtils.getVersion(Opcodes.class).orElse(null);
if (version == null)
{
LOG.warn("Unknown ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
}
else
{
String s = asm.getImplementationVersion();
if (s==null)
LOG.info("Unknown asm implementation version, assuming version {}", ASM_OPCODE_VERSION_STR);
else
int dot = version.indexOf('.');
version = version.substring(0, (dot < 0 ? version.length() : dot)).trim();
try
{
int dot = s.indexOf('.');
s = s.substring(0, (dot < 0 ? s.length() : dot)).trim();
try
int v = Integer.parseInt(version);
switch (v)
{
int v = Integer.parseInt(s);
switch (v)
case 4:
{
case 4:
{
asmVersion = Opcodes.ASM4;
break;
}
case 5:
{
asmVersion = Opcodes.ASM5;
break;
}
case 6:
{
asmVersion = Opcodes.ASM6;
break;
}
default:
{
LOG.warn("Unrecognized runtime asm version, assuming {}", ASM_OPCODE_VERSION_STR);
}
asmVersion = Opcodes.ASM4;
break;
}
case 5:
{
asmVersion = Opcodes.ASM5;
break;
}
case 6:
{
asmVersion = Opcodes.ASM6;
break;
}
default:
{
LOG.warn("Unrecognized ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
}
}
catch (NumberFormatException e)
{
LOG.warn("Unable to parse runtime asm version, assuming version {}", ASM_OPCODE_VERSION_STR);
}
}
catch (NumberFormatException e)
{
LOG.warn("Unable to parse ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
}
}
return asmVersion;

View File

@ -10,7 +10,7 @@
<name>Jetty :: Ant Plugin</name>
<properties>
<bundle-symbolic-name>org.eclipse.jetty.ant</bundle-symbolic-name>
<bundle-symbolic-name>${project.groupId}.ant</bundle-symbolic-name>
</properties>
<build>
<plugins>

View File

@ -26,7 +26,12 @@ public class HttpResponseException extends RuntimeException
public HttpResponseException(String message, Response response)
{
super(message);
this(message, response, null);
}
public HttpResponseException(String message, Response response, Throwable cause)
{
super(message, cause);
this.response = response;
}

View File

@ -346,7 +346,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
{
HttpResponse response = exchange.getResponse();
response.status(failure.getCode()).reason(failure.getReason());
failAndClose(new HttpResponseException("HTTP protocol violation: bad response on " + getHttpConnection(), response));
failAndClose(new HttpResponseException("HTTP protocol violation: bad response on " + getHttpConnection(), response, failure));
}
}

View File

@ -43,6 +43,7 @@ import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http.BadMessageException;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpVersion;
@ -209,6 +210,8 @@ public class HttpReceiverOverHTTPTest
ExecutionException e = assertThrows(ExecutionException.class, ()->listener.get(5, TimeUnit.SECONDS));
assertThat(e.getCause(), instanceOf(HttpResponseException.class));
assertThat(e.getCause().getCause(),instanceOf(BadMessageException.class));
assertThat(e.getCause().getCause().getCause(),instanceOf(NumberFormatException.class));
}
@ParameterizedTest

View File

@ -347,6 +347,8 @@ The ALPN implementation, relying on modifications of OpenJDK classes, updates ev
|1.8.0u171 |8.1.12.v20180117
|1.8.0u172 |8.1.12.v20180117
|1.8.0u181 |8.1.12.v20180117
|1.8.0u191 |8.1.13.v20181017
|1.8.0u192 |8.1.13.v20181017
|=============================
[[alpn-build]]

View File

@ -28,3 +28,4 @@ include::custom-modules.adoc[]
include::startup-xml-config.adoc[]
include::startup-unix-service.adoc[]
include::startup-windows-service.adoc[]
include::startup-jpms.adoc[]

View File

@ -79,6 +79,8 @@ If a user does not accept the license agreement, the module will not be activate
Additional Startup Commands - `[exec]`::
The `[exec]` section is used to define additional parameters specific to the module.
These commands are added to the server startup.
JPMS Module-Path Definitions - `[jpms]`::
The `[jpms]` section is used to add link:#startup-jpms[JPMS modules] to the module-path for startup when using the `--jpms` command.
[[custom-module-properties]]
==== Module Properties

View File

@ -170,7 +170,7 @@ Note: order presented here is how they would appear on the classpath.
13: {VERSION} | ${jetty.home}/lib/jetty-jndi-{VERSION}.jar
14: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
15: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
16: 1.2 | ${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
16: 1.3 | ${jetty.home}/lib/jndi/javax.transaction-api-1.3.jar
17: {VERSION} | ${jetty.home}/lib/jetty-rewrite-{VERSION}.jar
18: {VERSION} | ${jetty.home}/lib/jetty-security-{VERSION}.jar
19: {VERSION} | ${jetty.home}/lib/jetty-servlet-{VERSION}.jar

View File

@ -80,7 +80,7 @@ Note: order presented here is how they would appear on the classpath.
13: {VERSION} | ${jetty.home}/lib/jetty-jndi-{VERSION}.jar
14: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
15: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
16: 1.2 | ${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
16: 1.3 | ${jetty.home}/lib/jndi/javax.transaction-api-1.3.jar
17: {VERSION} | ${jetty.home}/lib/jetty-rewrite-{VERSION}.jar
18: {VERSION} | ${jetty.home}/lib/jetty-security-{VERSION}.jar
19: {VERSION} | ${jetty.home}/lib/jetty-servlet-{VERSION}.jar

View File

@ -0,0 +1,158 @@
//
// ========================================================================
// Copyright (c) 1995-2018 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.
// ========================================================================
//
[[startup-jpms]]
=== Startup using the Java Platform Module System (JPMS)
Jetty modules also act ass automatic https://en.wikipedia.org/wiki/Java_Platform_Module_System[JPMS] modules via the `Automatic-Module-Name` attribute in the jar's `MANIFEST.MF` file.
This makes possible to run Jetty from the module-path, rather than the class-path.
We recommend using JDK 11 or greater due to the fact that JDK 11 removed all the "enterprise" modules from the JDK.
The classes in these "enterprise" modules were bundled with JDK 8, and present in "enterprise" modules in JDK 9 and JDK 10.
With JDK 11, these "enterprise" classes are either not available in the JDK (because their corresponding module was removed), or they are present in a different module.
Because some of these "enterprise" classes are required by Jetty or by applications running in Jetty, it is better to use a stable source for those classes - in this case by using JDK 11
or greater.
[[jpms-module-path]]
==== Starting Jetty on the module-path
To start Jetty on the module-path rather than the class-path, it is enough to add the `--jpms` option to the command line, for example:
[source, screen, subs="{sub-order}"]
....
$ mkdir my-jetty-base
$ cd my-jetty-base
$ java -jar $JETTY_HOME/start.jar --add-to-start=http
INFO : server transitively enabled, ini template available with --add-to-start=server
INFO : http initialized in ${jetty.base}/start.ini
INFO : threadpool transitively enabled, ini template available with --add-to-start=threadpool
INFO : Base directory was modified
$ java -jar $JETTY_HOME/start.jar --jpms
....
The example above creates a link:#startup-base-and-home[Jetty base directory] and enables the `http` module using the `--add-to-start` command.
The server then starts Jetty on the module-path using the `--jpms` option.
----
[NOTE]
When running on the module-path using the `--jpms` option, the Jetty start mechanism will fork a second JVM passing it the right JVM options to run on the module-path.
You will have two JVMs running: one that runs `start.jar` and one that runs Jetty on the module-path.
----
If you are interested in the details of how the command line to run Jetty on the module-path looks like, you can add the `--dry-run` option:
[source, screen, subs="{sub-order}"]
....
$ java -jar $JETTY_HOME/start.jar --jpms --dry-run
....
This will give an out put looking something like this (broken in sections for clarity):
[source, screen, subs="{sub-order}"]
....
/opt/openjdk-11+28/bin/java
--module-path /opt/jetty/lib/servlet-api-3.1.jar:/opt/jetty/lib/jetty-schemas-3.1.jar:/opt/jetty/lib/jetty-http-9.4.13-SNAPSHOT.jar:...
--patch-module servlet.api=/opt/jetty/lib/jetty-schemas-3.1.jar
--module org.eclipse.jetty.xml/org.eclipse.jetty.xml.XmlConfiguration /opt/jetty/etc/jetty-threadpool.xml /opt/jetty/etc/jetty.xml ...
....
The `--module-path` option specifies the list of Jetty jars.
This list depends on the Jetty modules that have been enabled via the link:#startup-modules[`--add-to-start`] command.
The `--patch-module` option is necessary for Servlet and JSP Containers to find XML DTDs and XML Schemas required to validate the various XML files present in web applications (such as `web.xml` and others).
The `--module` option tells the JVM to run main class `XmlConfiguration` from the `org.eclipse.jetty.xml` module, with the given XML files as program arguments.
When the JVM starts, module `org.eclipse.jetty.xml` is added to the set of JPMS _root modules_; all other Jetty modules, being automatic, will be resolved and added to the module graph.
JAR files that are not modules, such as `servlet-api-3.1.jar`, are on the module-path and therefore will be made automatic modules by the JVM (hence the derived module name `servlet.api` for this jar, referenced by the `--patch-module` command line option above).
[[jpms-advanced-config]]
==== Advanced JPMS Configuration
Web applications may need additional services from the Servlet Container, such as JDBC `DataSource` references or JTA `UserTransaction` references.
For example, for JDBC it is typical to store, in JNDI, a reference to the connection pool's `DataSource` (such as `com.zaxxer.hikari.HikariDataSource`) or a reference directly to the JDBC driver's `DataSource` (`com.mysql.jdbc.jdbc2.optional.MysqlDataSource`).
Jetty needs to be able to instantiate those classes and therefore needs to be able to load those classes and all their super-classes, among which includes `javax.sql.DataSource`.
When Jetty runs on the class-path, this is easily achieved by using a link:#custom-modules[custom module]:
[source, screen, subs="{sub-order}"]
.mysql.mod
....
[description]
MySQL module
[lib]
lib/mysql/mysql-connector-java-*.jar
....
However, when running on the module-path, things are quite different.
Class `javax.sql.DataSource` is in a JDK bundled module named `java.sql`, which is not automatic (it's a proper JPMS module) and it is not in the _root modules_ set.
Because it is not an automatic module, it is not added to the module graph, and therefore needs to be added explicitly using the JVM command line `--add-modules`.
To add the JPMS module `java.sql` to the module graph, you need to modify your custom module in the following way, using our `mysql.mod` as an example:
[source, screen, subs="{sub-order}"]
.mysql.mod
....
[description]
MySQL module
[lib]
lib/mysql/mysql-connector-java-*.jar
[jpms]
add-modules: java.sql
....
The new `[jpms]` section is only used when Jetty is started on the module-path via the `--jpms` command line option.
Assuming that `mysql-connector-java-*.jar` is a non JPMS modular jar, or an automatic JPMS modular jar, the Jetty start mechanism will add `mysql-connector-java-*.jar` to the module-path, and will add the JVM command line option `--add-modules java.sql`.
If `mysql-connector-java-*.jar` were a proper JPMS modular jar with name (for example) `com.mysql.jdbc`, then it would need to be explicitly added to the module graph, in this way:
[source, screen, subs="{sub-order}"]
.mysql.mod
....
[description]
MySQL module
[lib]
lib/mysql/mysql-connector-java-*.jar
[jpms]
add-modules: com.mysql.jdbc
....
The JPMS module `java.sql` does not need to be explicitly added because it would be a dependency of the `com.mysql.jdbc` module and therefore automatically added to the module graph.
The `[jpms]` section has the following format:
[source, screen, subs="{sub-order}"]
....
[jpms]
add-modules: <module name>(,<module name>)*
patch-module: <module>=<file>(:<file>)*
add-opens: <module>/<package>=<target-module>(,<target-module>)*
add-exports: <module>/<package>=<target-module>(,<target-module>)*
add-reads: <module>=<target-module>(,<target-module>)*
....

View File

@ -324,7 +324,7 @@
</goals>
<configuration>
<includeGroupIds>javax.annotation,org.eclipse.jetty.orbit,org.ow2.asm</includeGroupIds>
<includeArtifactIds>javax.annotation-api,asm,asm-commons</includeArtifactIds>
<includeArtifactIds>javax.annotation-api,asm,asm-commons,asm-tree,asm-analysis</includeArtifactIds>
<includeTypes>jar</includeTypes>
<outputDirectory>${assembly-directory}/lib/annotations</outputDirectory>
</configuration>
@ -337,7 +337,7 @@
</goals>
<configuration>
<includeGroupIds>javax.annotation,org.eclipse.jetty.orbit,org.ow2.asm</includeGroupIds>
<includeArtifactIds>javax.annotation-api,asm,asm-commons</includeArtifactIds>
<includeArtifactIds>javax.annotation-api,asm,asm-commons,asm-tree,asm-analysis</includeArtifactIds>
<includeTypes>jar</includeTypes>
<classifier>sources</classifier>
<outputDirectory>${source-assembly-directory}/lib/annotations</outputDirectory>
@ -547,6 +547,14 @@
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
</dependency>
<!-- jetty deps -->
<dependency>

View File

@ -52,9 +52,7 @@ public class BadMessageException extends RuntimeException
public BadMessageException(int code, String reason)
{
super(code+": "+reason);
_code=code;
_reason=reason;
this(code, reason, null);
}
public BadMessageException(int code, String reason, Throwable cause)

View File

@ -1092,7 +1092,7 @@ public class HttpParser
catch(NumberFormatException e)
{
LOG.ignore(e);
throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Invalid Content-Length Value");
throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Invalid Content-Length Value",e);
}
}

View File

@ -333,9 +333,10 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
}
case SettingsFrame.ENABLE_PUSH:
{
boolean enabled = value == 1;
if (LOG.isDebugEnabled())
LOG.debug("{} push for {}", pushEnabled ? "Enabling" : "Disabling", this);
pushEnabled = value == 1;
LOG.debug("{} push for {}", enabled ? "Enabling" : "Disabling", this);
pushEnabled = enabled;
break;
}
case SettingsFrame.MAX_CONCURRENT_STREAMS:

View File

@ -177,7 +177,8 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
@Override
public boolean isRemotelyClosed()
{
return closeState.get() == CloseState.REMOTELY_CLOSED;
CloseState state = closeState.get();
return state == CloseState.REMOTELY_CLOSED || state == CloseState.CLOSING;
}
public boolean isLocallyClosed()
@ -652,13 +653,14 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
@Override
public String toString()
{
return String.format("%s@%x#%d{sendWindow=%s,recvWindow=%s,reset=%b,%s,age=%d,attachment=%s}",
return String.format("%s@%x#%d{sendWindow=%s,recvWindow=%s,reset=%b/%b,%s,age=%d,attachment=%s}",
getClass().getSimpleName(),
hashCode(),
getId(),
sendWindow,
recvWindow,
isReset(),
localReset,
remoteReset,
closeState,
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - timeStamp),
attachment);

View File

@ -33,7 +33,7 @@ public class MetaDataBuilder
{
private final int _maxSize;
private int _size;
private int _status=-1;
private Integer _status;
private String _method;
private HttpScheme _scheme;
private HostPortHttpField _authority;
@ -47,7 +47,7 @@ public class MetaDataBuilder
/**
* @param maxHeadersSize The maximum size of the headers, expressed as total name and value characters.
*/
MetaDataBuilder(int maxHeadersSize)
protected MetaDataBuilder(int maxHeadersSize)
{
_maxSize=maxHeadersSize;
}
@ -84,7 +84,7 @@ public class MetaDataBuilder
switch(header)
{
case C_STATUS:
if(checkHeader(header, _status))
if(checkPseudoHeader(header, _status))
_status = (Integer)staticField.getStaticValue();
_response = true;
break;
@ -110,8 +110,8 @@ public class MetaDataBuilder
switch(header)
{
case C_STATUS:
if(checkHeader(header, _status))
_status = field.getIntValue();
if(checkPseudoHeader(header, _status))
_status = Integer.valueOf(field.getIntValue());
_response = true;
break;
@ -197,7 +197,7 @@ public class MetaDataBuilder
}
}
void streamException(String messageFormat, Object... args)
protected void streamException(String messageFormat, Object... args)
{
HpackException.StreamException stream = new HpackException.StreamException(messageFormat, args);
if (_streamException==null)
@ -206,20 +206,7 @@ public class MetaDataBuilder
_streamException.addSuppressed(stream);
}
private boolean checkHeader(HttpHeader header, int value)
{
if (_fields.size()>0)
{
streamException("Pseudo header %s after fields", header.asString());
return false;
}
if (value==-1)
return true;
streamException("Duplicate pseudo header %s", header.asString());
return false;
}
private boolean checkPseudoHeader(HttpHeader header, Object value)
protected boolean checkPseudoHeader(HttpHeader header, Object value)
{
if (_fields.size()>0)
{
@ -258,22 +245,26 @@ public class MetaDataBuilder
return new MetaData.Request(_method,_scheme,_authority,_path,HttpVersion.HTTP_2,fields,_contentLength);
}
if (_response)
return new MetaData.Response(HttpVersion.HTTP_2,_status,fields,_contentLength);
{
if (_status==null)
throw new HpackException.StreamException("No Status");
return new MetaData.Response(HttpVersion.HTTP_2, _status, fields, _contentLength);
}
return new MetaData(HttpVersion.HTTP_2,fields,_contentLength);
}
finally
{
_fields = new HttpFields(Math.max(10,fields.size()+5));
_request=false;
_response=false;
_status=-1;
_method=null;
_scheme=null;
_authority=null;
_path=null;
_size=0;
_contentLength=Long.MIN_VALUE;
_fields = new HttpFields(Math.max(10, fields.size() + 5));
_request = false;
_response = false;
_status = null;
_method = null;
_scheme = null;
_authority = null;
_path = null;
_size = 0;
_contentLength = Long.MIN_VALUE;
}
}

View File

@ -451,12 +451,15 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
}
catch (Throwable x)
{
closeNoExceptions(_selector);
_selector = null;
if (isRunning())
LOG.warn(x);
else
{
LOG.warn(x.toString());
LOG.debug(x);
}
closeNoExceptions(_selector);
}
return false;
}

View File

@ -39,7 +39,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
<version>2.9.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -43,7 +43,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>javax.transaction*;version="[1.1,1.3)",*</Import-Package>
<Import-Package>javax.transaction.*;version="1.1",*</Import-Package>
</instructions>
</configuration>
</plugin>

View File

@ -37,7 +37,6 @@
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -49,7 +48,6 @@
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.mail.glassfish</artifactId>
<version>1.4.1.v201005082020</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -24,6 +24,9 @@ lib/jetty-io-${jetty.version}.jar
[xml]
etc/jetty.xml
[jpms]
patch-module: servlet.api=lib/jetty-schemas-3.1.jar
[ini-template]
### Common HTTP configuration
## Scheme to use to build URIs for secure redirects

View File

@ -50,6 +50,7 @@
<artifact>org.eclipse.jetty:jetty-util</artifact>
<includes>
<include>org/eclipse/jetty/util/JavaVersion*</include>
<include>org/eclipse/jetty/util/ManifestUtils*</include>
<include>org/eclipse/jetty/util/TopologicalSort*</include>
</includes>
</filter>

View File

@ -18,11 +18,6 @@
package org.eclipse.jetty.start;
import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS;
import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN;
import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED;
import static org.eclipse.jetty.start.UsageException.ERR_UNKNOWN;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@ -44,6 +39,11 @@ import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.config.CommandLineConfigSource;
import org.eclipse.jetty.start.config.ConfigSource;
import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS;
import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN;
import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED;
import static org.eclipse.jetty.start.UsageException.ERR_UNKNOWN;
/**
* Main start class.
* <p>
@ -353,9 +353,13 @@ public class Main
// ------------------------------------------------------------
// 6) Resolve Extra XMLs
args.resolveExtraXmls();
// ------------------------------------------------------------
// 9) Resolve Property Files
// 7) JPMS Expansion
args.expandJPMS(activeModules);
// ------------------------------------------------------------
// 8) Resolve Property Files
args.resolvePropertyFiles();
return args;

View File

@ -59,7 +59,7 @@ import org.eclipse.jetty.start.Props.Prop;
*/
public class Module implements Comparable<Module>
{
private static final String VERSION_UNSPECIFIED = "9.2";
private static final String VERSION_UNSPECIFIED = "0.0";
static Pattern MOD_NAME = Pattern.compile("^(.*)\\.mod",Pattern.CASE_INSENSITIVE);
static Pattern SET_PROPERTY = Pattern.compile("^(#?)\\s*([^=\\s]+)=(.*)$");
@ -89,6 +89,9 @@ public class Module implements Comparable<Module>
/** List of library options for this Module */
private final List<String> _libs=new ArrayList<>();
/** List of JPMS options for this Module */
private final List<String> _jpms=new ArrayList<>();
/** List of files for this Module */
private final List<String> _files=new ArrayList<>();
@ -229,6 +232,11 @@ public class Module implements Comparable<Module>
{
return _xmls;
}
public List<String> getJPMS()
{
return _jpms;
}
public Version getVersion()
{
@ -350,6 +358,9 @@ public class Module implements Comparable<Module>
case "LIBS":
_libs.add(line);
break;
case "JPMS":
_jpms.add(line);
break;
case "LICENSE":
case "LICENSES":
case "LICENCE":

View File

@ -154,6 +154,10 @@ public class Modules implements Iterable<Module>
{
System.out.printf(" XML: %s%n",xml);
}
for (String jpms : module.getJPMS())
{
System.out.printf(" JPMS: %s%n",jpms);
}
for (String jvm : module.getJvmArgs())
{
System.out.printf(" JVM: %s%n",jvm);

View File

@ -27,21 +27,28 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.config.ConfigSource;
import org.eclipse.jetty.start.config.ConfigSources;
import org.eclipse.jetty.start.config.DirConfigSource;
import org.eclipse.jetty.util.JavaVersion;
import org.eclipse.jetty.util.ManifestUtils;
/**
* The Arguments required to start Jetty.
@ -59,15 +66,11 @@ public class StartArgs
// Use META-INF/MANIFEST.MF versions
if (ver == null)
{
Package pkg = StartArgs.class.getPackage();
if ((pkg != null) && "Eclipse.org - Jetty".equals(pkg.getImplementationVendor()) && (pkg.getImplementationVersion() != null))
{
ver = pkg.getImplementationVersion();
if (tag == null)
{
tag = "jetty-" + ver;
}
}
ver = ManifestUtils.getManifest(StartArgs.class)
.map(Manifest::getMainAttributes)
.filter(attributes -> "Eclipse.org - Jetty".equals(attributes.getValue("Implementation-Vendor")))
.map(attributes -> attributes.getValue("Implementation-Version"))
.orElse(null);
}
// Use jetty-version.properties values
@ -82,9 +85,9 @@ public class StartArgs
props.load(in);
ver = props.getProperty("jetty.version");
}
catch (IOException ignore)
catch (IOException x)
{
StartLog.debug(ignore);
StartLog.debug(x);
}
}
}
@ -94,23 +97,25 @@ public class StartArgs
{
ver = "0.0";
if (tag == null)
{
tag = "master";
}
}
else
{
if (tag == null)
tag = "jetty-" + ver;
}
// Set Tag Defaults
if (tag == null || tag.contains("-SNAPSHOT"))
{
if (tag.contains("-SNAPSHOT"))
tag = "master";
}
VERSION = ver;
System.setProperty("jetty.version",VERSION);
System.setProperty("jetty.tag.version",tag);
System.setProperty("jetty.version", VERSION);
System.setProperty("jetty.tag.version", tag);
}
private static final String SERVER_MAIN = "org.eclipse.jetty.xml.XmlConfiguration";
private static final String MAIN_CLASS = "org.eclipse.jetty.xml.XmlConfiguration";
private static final String MODULE_MAIN_CLASS = "org.eclipse.jetty.xml/org.eclipse.jetty.xml.XmlConfiguration";
private final BaseHome baseHome;
@ -132,6 +137,13 @@ public class StartArgs
/** List of all active [xml] sections from enabled modules */
private List<Path> xmls = new ArrayList<>();
/** List of all active [jpms] sections for enabled modules */
private Set<String> jmodAdds = new LinkedHashSet<>();
private Map<String, Set<String>> jmodPatch = new LinkedHashMap<>();
private Map<String, Set<String>> jmodOpens = new LinkedHashMap<>();
private Map<String, Set<String>> jmodExports = new LinkedHashMap<>();
private Map<String, Set<String>> jmodReads = new LinkedHashMap<>();
/** JVM arguments, found via command line and in all active [exec] sections from enabled modules */
private List<String> jvmArgs = new ArrayList<>();
@ -174,6 +186,7 @@ public class StartArgs
private boolean listConfig = false;
private boolean version = false;
private boolean dryRun = false;
private boolean jpms = false;
private boolean createStartd = false;
private boolean updateIni = false;
private String mavenBaseUri;
@ -403,8 +416,7 @@ public class StartArgs
return;
}
List<String> sortedKeys = new ArrayList<>();
sortedKeys.addAll(systemPropertySource.keySet());
List<String> sortedKeys = new ArrayList<>(systemPropertySource.keySet());
Collections.sort(sortedKeys);
for (String key : sortedKeys)
@ -446,11 +458,8 @@ public class StartArgs
/**
* Expand any command line added {@code --lib} lib references.
*
* @throws IOException
* if unable to expand the libraries
*/
public void expandSystemProperties() throws IOException
public void expandSystemProperties()
{
StartLog.debug("Expanding System Properties");
@ -467,7 +476,7 @@ public class StartArgs
}
/**
* Expand any command line added <code>--lib</code> lib references.
* Expand any command line added {@code --lib} lib references.
*
* @throws IOException
* if unable to expand the libraries
@ -541,6 +550,70 @@ public class StartArgs
}
}
void expandJPMS(List<Module> activeModules) throws IOException
{
for (Module module : activeModules)
{
for (String line : module.getJPMS())
{
line = properties.expand(line);
String directive;
if (line.startsWith(directive = "add-modules:"))
{
String[] names = line.substring(directive.length()).split(",");
Arrays.stream(names).map(String::trim).collect(Collectors.toCollection(() -> jmodAdds));
}
else if (line.startsWith(directive = "patch-module:"))
{
parseJPMSKeyValue(module, line, directive, true, jmodPatch);
}
else if (line.startsWith(directive = "add-opens:"))
{
parseJPMSKeyValue(module, line, directive, false, jmodOpens);
}
else if (line.startsWith(directive = "add-exports:"))
{
parseJPMSKeyValue(module, line, directive, false, jmodExports);
}
else if (line.startsWith(directive = "add-reads:"))
{
parseJPMSKeyValue(module, line, directive, false, jmodReads);
}
else
{
throw new IllegalArgumentException("Invalid [jpms] directive " + directive + " in module " + module.getName() + ": " + line);
}
}
}
StartLog.debug("Expanded JPMS directives:%nadd-modules: %s%npatch-modules: %s%nadd-opens: %s%nadd-exports: %s%nadd-reads: %s",
jmodAdds, jmodPatch, jmodOpens, jmodExports, jmodReads);
}
private void parseJPMSKeyValue(Module module, String line, String directive, boolean valueIsFile, Map<String, Set<String>> output) throws IOException
{
String valueString = line.substring(directive.length());
int equals = valueString.indexOf('=');
if (equals <= 0)
throw new IllegalArgumentException("Invalid [jpms] directive " + directive + " in module " + module.getName() + ": " + line);
String delimiter = valueIsFile ? File.pathSeparator : ",";
String key = valueString.substring(0, equals).trim();
String[] values = valueString.substring(equals + 1).split(delimiter);
Set<String> result = output.computeIfAbsent(key, k -> new LinkedHashSet<>());
for (String value : values)
{
value = value.trim();
if (valueIsFile)
{
List<Path> paths = baseHome.getPaths(value);
paths.stream().map(Path::toAbsolutePath).map(Path::toString).collect(Collectors.toCollection(() -> result));
}
else
{
result.add(value);
}
}
}
public List<String> getStartModules()
{
return startModules;
@ -588,7 +661,7 @@ public class StartArgs
cmd.addRawArg("-Djetty.home=" + baseHome.getHome());
cmd.addRawArg("-Djetty.base=" + baseHome.getBase());
for (String x : jvmArgs)
for (String x : getJvmArgs())
{
if (x.startsWith("-D"))
{
@ -612,9 +685,64 @@ public class StartArgs
cmd.addEqualsArg("-D" + propKey,value);
}
cmd.addRawArg("-cp");
cmd.addRawArg(classpath.toString());
cmd.addRawArg(getMainClassname());
if (isJPMS())
{
Map<Boolean, List<File>> dirsAndFiles = StreamSupport.stream(classpath.spliterator(), false)
.collect(Collectors.groupingBy(File::isDirectory));
List<File> files = dirsAndFiles.get(false);
if (files != null && !files.isEmpty())
{
cmd.addRawArg("--module-path");
String modules = files.stream()
.map(File::getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator));
cmd.addRawArg(modules);
}
List<File> dirs = dirsAndFiles.get(true);
if (dirs != null && !dirs.isEmpty())
{
cmd.addRawArg("--class-path");
String directories = dirs.stream()
.map(File::getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator));
cmd.addRawArg(directories);
}
if (!jmodAdds.isEmpty())
{
cmd.addRawArg("--add-modules");
cmd.addRawArg(String.join(",", jmodAdds));
}
for (Map.Entry<String, Set<String>> entry : jmodPatch.entrySet())
{
cmd.addRawArg("--patch-module");
cmd.addRawArg(entry.getKey() + "=" + String.join(File.pathSeparator, entry.getValue()));
}
for (Map.Entry<String, Set<String>> entry : jmodOpens.entrySet())
{
cmd.addRawArg("--add-opens");
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
}
for (Map.Entry<String, Set<String>> entry : jmodExports.entrySet())
{
cmd.addRawArg("--add-exports");
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
}
for (Map.Entry<String, Set<String>> entry : jmodReads.entrySet())
{
cmd.addRawArg("--add-reads");
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
}
cmd.addRawArg("--module");
cmd.addRawArg(getMainClassname());
}
else
{
cmd.addRawArg("-cp");
cmd.addRawArg(classpath.toString());
cmd.addRawArg(getMainClassname());
}
}
@ -657,8 +785,8 @@ public class StartArgs
public String getMainClassname()
{
String mainclass = System.getProperty("jetty.server",SERVER_MAIN);
return System.getProperty("main.class",mainclass);
String mainClass = System.getProperty("jetty.server", isJPMS() ? MODULE_MAIN_CLASS : MAIN_CLASS);
return System.getProperty("main.class", mainClass);
}
public String getMavenLocalRepoDir()
@ -765,6 +893,11 @@ public class StartArgs
return createFiles;
}
public boolean isJPMS()
{
return jpms;
}
public boolean isDryRun()
{
return dryRun;
@ -782,7 +915,7 @@ public class StartArgs
public boolean isNormalMainClass()
{
return SERVER_MAIN.equals(getMainClassname());
return MAIN_CLASS.equals(getMainClassname());
}
public boolean isHelp()
@ -974,6 +1107,14 @@ public class StartArgs
return;
}
if ("--jpms".equals(arg))
{
jpms = true;
// Need to fork because we cannot use JDK 9 Module APIs.
exec = true;
return;
}
if ("--dry-run".equals(arg) || "--exec-print".equals(arg))
{
dryRun = true;
@ -1084,10 +1225,7 @@ public class StartArgs
if (arg.startsWith("--skip-file-validation="))
{
List<String> moduleNames = Props.getValues(arg);
for (String moduleName : moduleNames)
{
skipFileValidationModules.add(moduleName);
}
skipFileValidationModules.addAll(moduleNames);
return;
}
@ -1231,12 +1369,7 @@ public class StartArgs
for (String moduleName : moduleNames)
{
modules.add(moduleName);
List<String> list = sources.get(moduleName);
if (list == null)
{
list = new ArrayList<>();
sources.put(moduleName,list);
}
List<String> list = sources.computeIfAbsent(moduleName, k -> new ArrayList<>());
list.add(source);
}
}
@ -1327,17 +1460,7 @@ public class StartArgs
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("StartArgs [enabledModules=");
builder.append(modules);
builder.append(", xmlRefs=");
builder.append(xmlRefs);
builder.append(", properties=");
builder.append(properties);
builder.append(", jvmArgs=");
builder.append(jvmArgs);
builder.append("]");
return builder.toString();
return String.format("%s[enabledModules=%s, xmlRefs=%s, properties=%s, jvmArgs=%s]",
getClass().getSimpleName(), modules, xmlRefs, properties, jvmArgs);
}
}

View File

@ -0,0 +1,5 @@
[files]
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.13.v20181017|lib/alpn/alpn-boot-8.1.13.v20181017.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.13.v20181017.jar

View File

@ -0,0 +1,5 @@
[files]
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.13.v20181017|lib/alpn/alpn-boot-8.1.13.v20181017.jar
[exec]
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.13.v20181017.jar

View File

@ -0,0 +1,85 @@
//
// ========================================================================
// Copyright (c) 1995-2018 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.util;
import java.io.File;
import java.net.URL;
import java.security.CodeSource;
import java.util.Optional;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
public class ManifestUtils
{
private ManifestUtils()
{
}
public static Optional<Manifest> getManifest(Class<?> klass)
{
try
{
CodeSource codeSource = klass.getProtectionDomain().getCodeSource();
if (codeSource != null)
{
URL location = codeSource.getLocation();
if (location != null)
{
try (JarFile jarFile = new JarFile(new File(location.toURI())))
{
return Optional.of(jarFile.getManifest());
}
}
}
return Optional.empty();
}
catch (Throwable x)
{
return Optional.empty();
}
}
/**
* <p>Attempts to return the version of the jar/module for the given class.</p>
* <p>First, retrieves the {@code Implementation-Version} main attribute of the manifest;
* if that is missing, retrieves the JPMS module version (via reflection);
* if that is missing, returns an empty Optional.</p>
*
* @param klass the class of the jar/module to retrieve the version
* @return the jar/module version, or an empty Optional
*/
public static Optional<String> getVersion(Class<?> klass)
{
Optional<String> version = getManifest(klass).map(Manifest::getMainAttributes)
.map(attributes -> attributes.getValue("Implementation-Version"));
if (version.isPresent())
return version;
try
{
Object module = klass.getClass().getMethod("getModule").invoke(klass);
Object descriptor = module.getClass().getMethod("getDescriptor").invoke(module);
return (Optional<String>)descriptor.getClass().getMethod("rawVersion").invoke(descriptor);
}
catch (Throwable x)
{
return Optional.empty();
}
}
}

View File

@ -39,8 +39,6 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Part;
@ -515,7 +513,7 @@ public class MultiPartInputStreamParser
public Part getPart(String name)
throws IOException
{
if(_parsed)
if(!_parsed)
parse();
throwIfError();
return _parts.getValue(name, 0);

View File

@ -105,7 +105,7 @@ public abstract class Credential implements Serializable
int l1 = known.length();
int l2 = unknown.length();
for (int i = 0; i < l2; ++i)
result &= known.charAt(i%l1) == unknown.charAt(i);
result &= ((l1==0)?unknown.charAt(l2-i-1):known.charAt(i%l1)) == unknown.charAt(i);
return result && l1 == l2;
}
@ -127,7 +127,7 @@ public abstract class Credential implements Serializable
int l1 = known.length;
int l2 = unknown.length;
for (int i = 0; i < l2; ++i)
result &= known[i%l1] == unknown[i];
result &= ((l1==0)?unknown[l2-i-1]:known[i%l1]) == unknown[i];
return result && l1 == l2;
}

View File

@ -20,13 +20,13 @@
package org.eclipse.jetty.util.security;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.eclipse.jetty.util.security.Credential.Crypt;
import org.eclipse.jetty.util.security.Credential.MD5;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* CredentialTest
@ -94,4 +94,20 @@ public class CredentialTest
assertFalse(Credential.byteEquals("foo".getBytes(),"fo".getBytes()));
assertFalse(Credential.byteEquals("foo".getBytes(),"bar".getBytes()));
}
@Test
public void testEmptyString()
{
assertFalse(Credential.stringEquals("fooo",""));
assertFalse(Credential.stringEquals("","fooo"));
assertTrue(Credential.stringEquals("",""));
}
@Test
public void testEmptyBytes()
{
assertFalse(Credential.byteEquals("fooo".getBytes(),"".getBytes()));
assertFalse(Credential.byteEquals("".getBytes(),"fooo".getBytes()));
assertTrue(Credential.byteEquals("".getBytes(),"".getBytes()));
}
}

View File

@ -30,3 +30,6 @@ lib/jetty-webapp-${jetty.version}.jar
##
#jetty.webapp.addSystemClasses+=,org.example.
#jetty.webapp.addServerClasses+=,org.example.
[jpms]
add-modules:java.instrument

View File

@ -159,8 +159,6 @@ public class WebInfConfiguration extends AbstractConfiguration
context.getMetaData().setWebInfClassesDirs(findClassDirs(context));
}
/**
* Find jars and directories that are on the container's classpath
* and apply an optional filter. The filter is a pattern applied to the
@ -177,15 +175,15 @@ public class WebInfConfiguration extends AbstractConfiguration
* @param context the WebAppContext being deployed
* @throws Exception if unable to apply optional filtering on the container's classpath
*/
public void findAndFilterContainerPaths (final WebAppContext context)
throws Exception
public void findAndFilterContainerPaths (final WebAppContext context) throws Exception
{
//assume the target jvm is the same as that running
int targetPlatform = JavaVersion.VERSION.getPlatform();
int currentPlatform = JavaVersion.VERSION.getPlatform();
//allow user to specify target jvm different to current runtime
int targetPlatform = currentPlatform;
Object target = context.getAttribute(JavaVersion.JAVA_TARGET_PLATFORM);
if (target!=null)
targetPlatform = Integer.valueOf(target.toString()).intValue();
targetPlatform = Integer.parseInt(target.toString());
//Apply an initial name filter to the jars to select which will be eventually
//scanned for META-INF info and annotations. The filter is based on inclusion patterns.
@ -199,7 +197,7 @@ public class WebInfConfiguration extends AbstractConfiguration
List<URI> containerUris = new ArrayList<>();
while (loader != null && (loader instanceof URLClassLoader))
while (loader instanceof URLClassLoader)
{
URL[] urls = ((URLClassLoader)loader).getURLs();
if (urls != null)
@ -219,12 +217,13 @@ public class WebInfConfiguration extends AbstractConfiguration
loader = loader.getParent();
}
if (LOG.isDebugEnabled()) LOG.debug("Matching container urls {}", containerUris);
if (LOG.isDebugEnabled())
LOG.debug("Matching container urls {}", containerUris);
containerPathNameMatcher.match(containerUris);
//if running on jvm 9 or above, we we won't be able to look at the application classloader
//to extract urls, so we need to examine the classpath instead.
if (JavaVersion.VERSION.getPlatform() >= 9)
if (currentPlatform >= 9)
{
tmp = System.getProperty("java.class.path");
if (tmp != null)
@ -236,7 +235,8 @@ public class WebInfConfiguration extends AbstractConfiguration
File f = new File(entry);
cpUris.add(f.toURI());
}
if (LOG.isDebugEnabled()) LOG.debug("Matching java.class.path {}", cpUris);
if (LOG.isDebugEnabled())
LOG.debug("Matching java.class.path {}", cpUris);
containerPathNameMatcher.match(cpUris);
}
}
@ -253,28 +253,33 @@ public class WebInfConfiguration extends AbstractConfiguration
{
List<URI> moduleUris = new ArrayList<>();
String[] entries = tmp.split(File.pathSeparator);
for (String entry:entries)
for (String entry : entries)
{
File dir = new File(entry);
File[] files = dir.listFiles();
if (files != null)
File file = new File(entry);
if (file.isDirectory())
{
for (File f:files)
File[] files = file.listFiles();
if (files != null)
{
moduleUris.add(f.toURI());
for (File f : files)
moduleUris.add(f.toURI());
}
}
else
{
moduleUris.add(file.toURI());
}
}
if (LOG.isDebugEnabled()) LOG.debug("Matching jdk.module.path {}", moduleUris);
if (LOG.isDebugEnabled())
LOG.debug("Matching jdk.module.path {}", moduleUris);
containerPathNameMatcher.match(moduleUris);
}
}
if (LOG.isDebugEnabled()) LOG.debug("Container paths selected:{}", context.getMetaData().getContainerResources());
if (LOG.isDebugEnabled())
LOG.debug("Container paths selected:{}", context.getMetaData().getContainerResources());
}
/**
* Finds the jars that are either physically or virtually in
* WEB-INF/lib, and applies an optional filter to their full

View File

@ -1,6 +1,5 @@
# Setup default logging implementation for during testing
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.LEVEL=INFO
#org.eclipse.jetty.LEVEL=DEBUG
# org.eclipse.jetty.webapp.WebAppClassLoader.LEVEL=DEBUG
# org.eclipse.jetty.util.LEVEL=DEBUG
# org.eclipse.jetty.util.PathWatcher.Noisy.LEVEL=OFF

98
pom.xml
View File

@ -39,9 +39,10 @@
<unix.socket.tmp></unix.socket.tmp>
<!-- enable or not TestTracker junit5 extension i.e log message when test method is starting -->
<jetty.testtracker.log>false</jetty.testtracker.log>
<jpms-module-name>${bundle-symbolic-name}</jpms-module-name>
<!-- some maven plugins versions -->
<maven.surefire.version>2.22.0</maven.surefire.version>
<maven.surefire.version>2.22.1</maven.surefire.version>
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
<maven.dependency.plugin.version>3.1.1</maven.dependency.plugin.version>
<maven.resources.plugin.version>3.1.0</maven.resources.plugin.version>
@ -49,7 +50,6 @@
<maven.war.plugin.version>3.2.2</maven.war.plugin.version>
<maven.plugin-tools.version>3.5.2</maven.plugin-tools.version>
<!-- testing -->
<jetty.test.version>5.1</jetty.test.version>
</properties>
@ -488,6 +488,7 @@
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Automatic-Module-Name>${jpms-module-name}</Automatic-Module-Name>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Vendor>Eclipse.org - Jetty</Implementation-Vendor>
<url>${jetty.url}</url>
@ -513,63 +514,6 @@
<link>http://docs.oracle.com/javase/8/docs/api/</link>
<link>http://docs.oracle.com/javaee/7/api/</link>
</links>
<tags>
<tag>
<name>org.apache.xbean.XBean</name>
<placement>X</placement>
<head />
</tag>
<tag>
<name>phase</name>
<placement>t</placement>
<head>Phase:</head>
</tag>
<tag>
<name>goal</name>
<placement>t</placement>
<head>Goal:</head>
</tag>
<tag>
<name>description</name>
<placement>a</placement>
<head>Description:</head>
</tag>
<tag>
<name>parameter</name>
<placement>f</placement>
<head>Parameter:</head>
</tag>
<tag>
<name>required</name>
<placement>f</placement>
<head>Required:</head>
</tag>
<tag>
<name>readonly</name>
<placement>f</placement>
<head>Read-Only:</head>
</tag>
<tag>
<name>execute</name>
<placement>X</placement>
<head />
</tag>
<tag>
<name>requiresDependencyResolution</name>
<placement>X</placement>
<head />
</tag>
<tag>
<name>requiresProject</name>
<placement>X</placement>
<head />
</tag>
<tag>
<name>threadSafe</name>
<placement>X</placement>
<head />
</tag>
</tags>
</configuration>
</plugin>
<plugin>
@ -960,6 +904,16 @@
<artifactId>asm-commons</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.security.auth.message</artifactId>
@ -1002,7 +956,7 @@
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
<version>1.3</version>
<scope>provided</scope>
</dependency>
<!-- maven deps -->
@ -1782,6 +1736,30 @@
<alpn.version>8.1.12.v20180117</alpn.version>
</properties>
</profile>
<profile>
<id>8u191</id>
<activation>
<property>
<name>java.version</name>
<value>1.8.0_191</value>
</property>
</activation>
<properties>
<alpn.version>8.1.13.v20181017</alpn.version>
</properties>
</profile>
<profile>
<id>8u192</id>
<activation>
<property>
<name>java.version</name>
<value>1.8.0_192</value>
</property>
</activation>
<properties>
<alpn.version>8.1.13.v20181017</alpn.version>
</properties>
</profile>
<profile>
<id>jdk9</id>
<activation>

View File

@ -44,7 +44,6 @@
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
@ -139,7 +138,7 @@
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<phase>process-test-classes</phase>
<goals>
<goal>copy</goal>
</goals>