Skip to content

Commit aed886d

Browse files
committed
use Jetty ALPN agent instead of Jetty ALPN
grpc#1497
1 parent cd8f828 commit aed886d

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

SECURITY.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,17 @@ dependencies {
217217

218218
If not using the Netty transport (or you are unable to use OpenSSL for some reason) another alternative is to use the JDK for TLS.
219219

220-
No standard Java release has built-in support for ALPN today ([there is a tracking issue](https://bugs.openjdk.java.net/browse/JDK-8051498) so go upvote it!) so we need to use the [Jetty-ALPN](https://github.com/jetty-project/jetty-alpn") (or [Jetty-NPN](https://github.com/jetty-project/jetty-npn) if on Java < 8) bootclasspath extension for OpenJDK. To do this, add a `Xbootclasspath` JVM option referencing the path to the Jetty `alpn-boot` jar.
220+
No standard Java release has built-in support for ALPN today ([there is a tracking issue](https://bugs.openjdk.java.net/browse/JDK-8051498) so go upvote it!) so we need to use the [Jetty-ALPN](https://github.com/jetty-project/jetty-alpn) (or [Jetty-NPN](https://github.com/jetty-project/jetty-npn) if on Java < 8) bootclasspath extension for OpenJDK. To do this, add an `Xbootclasspath` JVM option referencing the path to the Jetty `alpn-boot` jar.
221221

222222
```sh
223223
java -Xbootclasspath/p:/path/to/jetty/alpn/extension.jar ...
224224
```
225225

226-
Note that you must use the [release of the Jetty-ALPN jar](http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) specific to the version of Java you are using.
226+
Note that you must use the [release of the Jetty-ALPN jar](http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) specific to the version of Java you are using. However, you can use the JVM agent [Jeety-ALPN-Agent](https://github.com/jetty-project/jetty-alpn-agent) to load the correct Jetty `alpn-boot` jar file for the current Java version. To do this, instead of adding an `Xbootclasspath` option, add a `javaagent` JVM option referencing the path to the Jetty `alpn-agent` jar.
227+
228+
```sh
229+
java -javaagent:/path/to/jetty-alpn-agent.jar ...
230+
```
227231

228232
### JDK Ciphers
229233

benchmarks/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,31 @@ def vmArgs = [
5656
task qps_client(type: CreateStartScripts) {
5757
mainClassName = "io.grpc.benchmarks.qps.AsyncClient"
5858
applicationName = "qps_client"
59-
defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs
59+
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
6060
outputDir = new File(project.buildDir, 'tmp')
6161
classpath = jar.outputs.files + project.configurations.runtime
6262
}
6363

6464
task openloop_client(type: CreateStartScripts) {
6565
mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient"
6666
applicationName = "openloop_client"
67-
defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs
67+
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
6868
outputDir = new File(project.buildDir, 'tmp')
6969
classpath = jar.outputs.files + project.configurations.runtime
7070
}
7171

7272
task qps_server(type: CreateStartScripts) {
7373
mainClassName = "io.grpc.benchmarks.qps.AsyncServer"
7474
applicationName = "qps_server"
75-
defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs
75+
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
7676
outputDir = new File(project.buildDir, 'tmp')
7777
classpath = jar.outputs.files + project.configurations.runtime
7878
}
7979

8080
task benchmark_worker(type: CreateStartScripts) {
8181
mainClassName = "io.grpc.benchmarks.driver.LoadWorker"
8282
applicationName = "benchmark_worker"
83-
defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs
83+
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
8484
outputDir = new File(project.buildDir, 'tmp')
8585
classpath = jar.outputs.files + project.configurations.runtime
8686
}

build.gradle

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,24 @@ subprojects {
149149
// Benchmark dependencies
150150
hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.8',
151151
math: 'org.apache.commons:commons-math3:3.6',
152-
]
153-
154-
// Determine the correct version of Jetty ALPN boot to use based
155-
// on the Java version.
156-
def alpnboot_version = '8.1.2.v20141202'
157-
if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
158-
alpnboot_version = '7.1.3.v20150130'
159-
}
160152

161-
alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version
153+
// Jetty ALPN dependencies
154+
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.2'
155+
]
162156
}
163157

164-
// Define a separate configuration for managing the dependency on Jetty alpnboot jar.
158+
// Define a separate configuration for managing the dependency on Jetty ALPN agent.
165159
configurations {
166-
alpnboot
160+
alpnagent
167161
tcnative
168162
}
169163

170164
dependencies {
171165
testCompile libraries.junit,
172166
libraries.mockito
173167

174-
// Configuration for modules that use Jetty ALPN
175-
alpnboot alpnboot_package_name
168+
// Configuration for modules that use Jetty ALPN agent
169+
alpnagent libraries.jetty_alpn_agent
176170

177171
// Configuration for modules that use Netty tcnative (for OpenSSL).
178172
tcnative libraries.netty_tcnative

interop-testing/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929

3030
test {
3131
// For the automated tests, use Jetty ALPN.
32-
jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath
32+
jvmArgs "-javaagent:" + configurations.alpnagent.asPath
3333
}
3434

3535
// The application plugin uses the distribution plugin and configures the jars to be

netty/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
}
1010

1111
test {
12-
jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath
12+
jvmArgs "-javaagent:" + configurations.alpnagent.asPath
1313
}
1414

1515
javadoc.options.links 'http://netty.io/4.1/api/'

0 commit comments

Comments
 (0)