Skip to content

Commit ff602e6

Browse files
committed
Change default version of Jetty to 9.3
Closes spring-projectsgh-5825
1 parent e1cafb1 commit ff602e6

File tree

13 files changed

+113
-66
lines changed

13 files changed

+113
-66
lines changed

spring-boot-dependencies/pom.xml

+1-12
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<jedis.version>2.8.1</jedis.version>
108108
<jersey.version>2.23</jersey.version>
109109
<jest.version>2.0.3</jest.version>
110-
<jetty.version>9.2.17.v20160517</jetty.version>
110+
<jetty.version>9.3.9.v20160517</jetty.version>
111111
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
112112
<jmustache.version>1.12</jmustache.version>
113113
<jna.version>4.2.2</jna.version>
@@ -1546,17 +1546,6 @@
15461546
<artifactId>jetty-io</artifactId>
15471547
<version>${jetty.version}</version>
15481548
</dependency>
1549-
<dependency>
1550-
<groupId>org.eclipse.jetty</groupId>
1551-
<artifactId>jetty-jsp</artifactId>
1552-
<version>${jetty.version}</version>
1553-
<exclusions>
1554-
<exclusion>
1555-
<groupId>org.eclipse.jetty.orbit</groupId>
1556-
<artifactId>javax.servlet</artifactId>
1557-
</exclusion>
1558-
</exclusions>
1559-
</dependency>
15601549
<dependency>
15611550
<groupId>org.eclipse.jetty</groupId>
15621551
<artifactId>jetty-jmx</artifactId>

spring-boot-docs/src/main/asciidoc/getting-started.adoc

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ diverge from the defaults.
3737
[[getting-started-system-requirements]]
3838
== System Requirements
3939
By default, Spring Boot {spring-boot-version} requires http://www.java.com[Java 7] and
40-
Spring Framework {spring-version} or above. You can use Spring Boot with Java 6 with some additional
41-
configuration. See <<howto.adoc#howto-use-java-6>> for more details. Explicit build support
42-
is provided for Maven (3.2+) and Gradle (1.12+).
40+
Spring Framework {spring-version} or above. You can use Spring Boot with Java 6 with some
41+
additional configuration. See <<howto.adoc#howto-use-java-6>> for more details. Explicit
42+
build support is provided for Maven (3.2+) and Gradle (1.12+).
4343

4444
TIP: Although you can use Spring Boot with Java 6 or 7, we generally recommend Java 8 if at
4545
all possible.
@@ -58,7 +58,11 @@ The following embedded servlet containers are supported out of the box:
5858
|3.0
5959
|Java 6+
6060

61-
|Jetty 9
61+
|Jetty 9.3
62+
|3.1
63+
|Java 8+
64+
65+
|Jetty 9.2
6266
|3.1
6367
|Java 7+
6468

spring-boot-docs/src/main/asciidoc/howto.adoc

+59-2
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,67 @@ You can change the Tomcat version by setting the `tomcat.version` property:
920920

921921

922922

923+
[[howto-use-jetty-9.2]]
924+
=== Use Jetty 9.2
925+
Jetty 9.2 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use
926+
Jetty 9.3 (for example, because you are using Java 7) you will need to change your
927+
classpath to reference Jetty 9.2.
928+
929+
930+
931+
[[howto-use-jetty-9.2-maven]]
932+
==== Use Jetty 9.2 with Maven
933+
934+
If you are using the starters and parent you can just add the Jetty starter and override
935+
the `jetty.version` property:
936+
937+
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
938+
----
939+
<properties>
940+
<jetty.version>9.2.17.v20160517</jetty.version>
941+
</properties>
942+
<dependencies>
943+
<dependency>
944+
<groupId>org.springframework.boot</groupId>
945+
<artifactId>spring-boot-starter-web</artifactId>
946+
<exclusions>
947+
<exclusion>
948+
<groupId>org.springframework.boot</groupId>
949+
<artifactId>spring-boot-starter-tomcat</artifactId>
950+
</exclusion>
951+
</exclusions>
952+
</dependency>
953+
<dependency>
954+
<groupId>org.springframework.boot</groupId>
955+
<artifactId>spring-boot-starter-jetty</artifactId>
956+
</dependency>
957+
</dependencies>
958+
----
959+
960+
961+
962+
[[howto-use-jetty-9.2-gradle]]
963+
==== Use Jetty 9.2 with Gradle
964+
965+
You can set the `jetty.version` property. For example, for a simple webapp or service:
966+
967+
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
968+
----
969+
ext['jetty.version'] = '9.2.17.v20160517'
970+
dependencies {
971+
compile ('org.springframework.boot:spring-boot-starter-web') {
972+
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
973+
}
974+
compile ('org.springframework.boot:spring-boot-starter-jetty')
975+
}
976+
----
977+
978+
979+
923980
[[howto-use-jetty-8]]
924981
=== Use Jetty 8
925-
Jetty 8 works with Spring Boot, but the default is to use Jetty 9. If you cannot use
926-
Jetty 9 (for example, because you are using Java 1.6) you will need to change your
982+
Jetty 8 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use
983+
Jetty 9.3 (for example, because you are using Java 1.6) you will need to change your
927984
classpath to reference Jetty 8. You will also need to exclude Jetty's WebSocket-related
928985
dependencies.
929986

spring-boot-samples/README.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ The following sample applications are provided:
117117
| link:spring-boot-sample-jetty8-ssl[spring-boot-sample-jetty8-ssl]
118118
| Embedded Jetty 8 SSL
119119

120-
| link:spring-boot-sample-jetty93[spring-boot-sample-jetty93]
121-
| Embedded Jetty 9.3
120+
| link:spring-boot-sample-jetty92[spring-boot-sample-jetty92]
121+
| Embedded Jetty 9.2
122122

123123
| link:spring-boot-sample-jooq[spring-boot-sample-jooq]
124124
| Stores data using jOOQ

spring-boot-samples/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<module>spring-boot-sample-jetty-ssl</module>
5959
<module>spring-boot-sample-jetty8</module>
6060
<module>spring-boot-sample-jetty8-ssl</module>
61-
<module>spring-boot-sample-jetty93</module>
61+
<module>spring-boot-sample-jetty92</module>
6262
<module>spring-boot-sample-jooq</module>
6363
<module>spring-boot-sample-jpa</module>
6464
<module>spring-boot-sample-jta-atomikos</module>

spring-boot-samples/spring-boot-sample-jetty93/pom.xml spring-boot-samples/spring-boot-sample-jetty92/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
<artifactId>spring-boot-samples</artifactId>
88
<version>1.4.0.BUILD-SNAPSHOT</version>
99
</parent>
10-
<artifactId>spring-boot-sample-jetty93</artifactId>
11-
<name>Spring Boot Jetty 9.3 Sample</name>
12-
<description>Spring Boot Jetty 9.3 Sample</description>
10+
<artifactId>spring-boot-sample-jetty92</artifactId>
11+
<name>Spring Boot Jetty 9.2 Sample</name>
12+
<description>Spring Boot Jetty 9.2 Sample</description>
1313
<url>http://projects.spring.io/spring-boot/</url>
1414
<organization>
1515
<name>Pivotal Software, Inc.</name>
1616
<url>http://www.spring.io</url>
1717
</organization>
1818
<properties>
1919
<main.basedir>${basedir}/../..</main.basedir>
20-
<jetty.version>9.3.0.v20150612</jetty.version>
20+
<jetty.version>9.2.17.v20160517</jetty.version>
2121
</properties>
2222
<dependencies>
2323
<dependency>

spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/SampleJetty93Application.java spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/SampleJetty92Application.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,16 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
package sample.jetty93;
17+
package sample.jetty92;
1818

1919
import org.springframework.boot.SpringApplication;
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
2121

2222
@SpringBootApplication
23-
public class SampleJetty93Application {
23+
public class SampleJetty92Application {
2424

2525
public static void main(String[] args) throws Exception {
26-
SpringApplication.run(SampleJetty93Application.class, args);
26+
SpringApplication.run(SampleJetty92Application.class, args);
2727
}
2828

2929
}

spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/service/HelloWorldService.java spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/service/HelloWorldService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package sample.jetty93.service;
17+
package sample.jetty92.service;
1818

1919
import org.springframework.beans.factory.annotation.Value;
2020
import org.springframework.stereotype.Component;

spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java spring-boot-samples/spring-boot-sample-jetty92/src/main/java/sample/jetty92/web/SampleController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package sample.jetty93.web;
17+
package sample.jetty92.web;
1818

19-
import sample.jetty93.service.HelloWorldService;
19+
import sample.jetty92.service.HelloWorldService;
2020

2121
import org.springframework.beans.factory.annotation.Autowired;
2222
import org.springframework.stereotype.Controller;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server.compression.enabled: true
2+
server.compression.min-response-size: 1

spring-boot-samples/spring-boot-sample-jetty93/src/test/java/sample/jetty93/SampleJetty93ApplicationTests.java spring-boot-samples/spring-boot-sample-jetty92/src/test/java/sample/jetty92/SampleJetty92ApplicationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package sample.jetty93;
17+
package sample.jetty92;
1818

1919
import java.io.ByteArrayInputStream;
2020
import java.nio.charset.Charset;
@@ -47,7 +47,7 @@
4747
@RunWith(SpringRunner.class)
4848
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
4949
@DirtiesContext
50-
public class SampleJetty93ApplicationTests {
50+
public class SampleJetty92ApplicationTests {
5151

5252
@LocalServerPort
5353
private int port;

spring-boot-samples/spring-boot-sample-jetty93/src/main/resources/application.properties

-2
This file was deleted.

spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java

+26-29
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
import org.eclipse.jetty.server.SslConnectionFactory;
4949
import org.eclipse.jetty.server.handler.ErrorHandler;
5050
import org.eclipse.jetty.server.handler.HandlerWrapper;
51+
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
5152
import org.eclipse.jetty.server.session.HashSessionManager;
5253
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
5354
import org.eclipse.jetty.servlet.ServletHolder;
5455
import org.eclipse.jetty.servlet.ServletMapping;
55-
import org.eclipse.jetty.servlets.gzip.GzipHandler;
5656
import org.eclipse.jetty.util.resource.JarResource;
5757
import org.eclipse.jetty.util.resource.Resource;
5858
import org.eclipse.jetty.util.ssl.SslContextFactory;
@@ -752,50 +752,47 @@ public HandlerWrapper createGzipHandler(Compression compression) {
752752

753753
private static class Jetty92GzipHandlerFactory implements GzipHandlerFactory {
754754

755-
@Override
756-
public HandlerWrapper createGzipHandler(Compression compression) {
757-
GzipHandler gzipHandler = new GzipHandler();
758-
gzipHandler.setMinGzipSize(compression.getMinResponseSize());
759-
gzipHandler.addIncludedMimeTypes(compression.getMimeTypes());
760-
if (compression.getExcludedUserAgents() != null) {
761-
gzipHandler.setExcluded(new HashSet<String>(
762-
Arrays.asList(compression.getExcludedUserAgents())));
763-
}
764-
return gzipHandler;
765-
}
766-
767-
}
768-
769-
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
770-
771755
@Override
772756
public HandlerWrapper createGzipHandler(Compression compression) {
773757
try {
774-
Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_3,
758+
Class<?> handlerClass = ClassUtils.forName(GZIP_HANDLER_JETTY_9_2,
775759
getClass().getClassLoader());
776-
HandlerWrapper handler = (HandlerWrapper) handlerClass.newInstance();
760+
HandlerWrapper gzipHandler = (HandlerWrapper) handlerClass.newInstance();
777761
ReflectionUtils.findMethod(handlerClass, "setMinGzipSize", int.class)
778-
.invoke(handler, compression.getMinResponseSize());
762+
.invoke(gzipHandler, compression.getMinResponseSize());
779763
ReflectionUtils
780-
.findMethod(handlerClass, "setIncludedMimeTypes", String[].class)
781-
.invoke(handler, new Object[] { compression.getMimeTypes() });
764+
.findMethod(handlerClass, "addIncludedMimeTypes", String[].class)
765+
.invoke(gzipHandler, new Object[] { compression.getMimeTypes() });
782766
if (compression.getExcludedUserAgents() != null) {
783-
ReflectionUtils
784-
.findMethod(handlerClass, "setExcludedAgentPatterns",
785-
String[].class)
786-
.invoke(handler,
787-
new Object[] { compression.getExcludedUserAgents() });
767+
ReflectionUtils.findMethod(handlerClass, "setExcluded", Set.class)
768+
.invoke(gzipHandler, new HashSet<String>(
769+
Arrays.asList(compression.getExcludedUserAgents())));
788770
}
789-
return handler;
771+
return gzipHandler;
790772
}
791773
catch (Exception ex) {
792-
throw new RuntimeException("Failed to configure Jetty 9.3 gzip handler",
774+
throw new RuntimeException("Failed to configure Jetty 9.2 gzip handler",
793775
ex);
794776
}
795777
}
796778

797779
}
798780

781+
private static class Jetty93GzipHandlerFactory implements GzipHandlerFactory {
782+
783+
@Override
784+
public HandlerWrapper createGzipHandler(Compression compression) {
785+
GzipHandler handler = new GzipHandler();
786+
handler.setMinGzipSize(compression.getMinResponseSize());
787+
handler.setIncludedMimeTypes(compression.getMimeTypes());
788+
if (compression.getExcludedUserAgents() != null) {
789+
handler.setExcludedAgentPatterns(compression.getExcludedUserAgents());
790+
}
791+
return handler;
792+
}
793+
794+
}
795+
799796
/**
800797
* {@link JettyServerCustomizer} to add {@link ForwardedRequestCustomizer}. Only
801798
* supported with Jetty 9 (hence the inner class)

0 commit comments

Comments
 (0)