Skip to content

Commit

Permalink
Merge pull request #5494 from eclipse/jetty-9.4.x-5492-java-features-…
Browse files Browse the repository at this point in the history
…start-properties

Issue #5492 - Adding java.features.* start properties
  • Loading branch information
joakime authored Feb 18, 2021
2 parents 7abd460 + f2bed13 commit bbcae23
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 34 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Enables the ALPN (Application Layer Protocol Negotiation) TLS extension.

[depend]
ssl
alpn-impl
alpn-impl/alpn-available-${runtime.feature.alpn}

[lib]
lib/jetty-alpn-client-${jetty.version}.jar
Expand Down
17 changes: 17 additions & 0 deletions jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -1505,10 +1505,14 @@ public void setProperty(String key, String value, String source)
{
JavaVersion ver = JavaVersion.parse(value);
properties.setProperty("java.version.platform", Integer.toString(ver.getPlatform()), source);

// @deprecated - below will be removed in Jetty 10.x
properties.setProperty("java.version.major", Integer.toString(ver.getMajor()), "Deprecated");
properties.setProperty("java.version.minor", Integer.toString(ver.getMinor()), "Deprecated");
properties.setProperty("java.version.micro", Integer.toString(ver.getMicro()), "Deprecated");

// ALPN feature exists
properties.setProperty("runtime.feature.alpn", Boolean.toString(isMethodAvailable(javax.net.ssl.SSLParameters.class, "getApplicationProtocols", null)), source);
}
catch (Throwable x)
{
Expand All @@ -1525,6 +1529,19 @@ public void setProperty(String key, String value, String source)
}
}

private boolean isMethodAvailable(Class<?> clazz, String methodName, Class<?>[] params)
{
try
{
clazz.getMethod(methodName, params);
return true;
}
catch (NoSuchMethodException e)
{
return false;
}
}

public void setRun(boolean run)
{
this.run = run;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static void assertConfiguration(BaseHome baseHome, StartArgs args, String
"jetty.base.uri".equals(name) ||
"user.dir".equals(name) ||
prop.source.equals(Props.ORIGIN_SYSPROP) ||
name.startsWith("runtime.feature.") ||
name.startsWith("java."))
{
// strip these out from assertion, to make assertions easier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ public void testJettyHomeWithSpaces() throws Exception
{
Path distPath = MavenTestingUtils.getTestResourceDir("dist-home").toPath().toRealPath();
Path homePath = MavenTestingUtils.getTargetTestingPath().resolve("dist home with spaces");
IO.copy(distPath.toFile(), homePath.toFile());
Files.createFile(homePath.resolve("lib/a library.jar"));
if (!Files.exists(homePath))
{
IO.copy(distPath.toFile(), homePath.toFile());
Files.createFile(homePath.resolve("lib/a library.jar"));
}

List<String> cmdLineArgs = new ArrayList<>();
cmdLineArgs.add("user.dir=" + homePath);
Expand Down

0 comments on commit bbcae23

Please sign in to comment.