diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java index 0425e6314e9b..48802ef4cba0 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java @@ -417,14 +417,14 @@ public void process(BaseHome basehome) throws FileNotFoundException, IOException case "DEFAULTS": // old name introduced in 9.2.x case "INI": // new name for 9.3+ { - // All default properties are to be treated as `?=` by the configuration system - // even if they are present as `=` + // If a property is specified as `=` it is to be treated as `?=`. + // All other property usages are left as-is (eg: `+=`) int idx = line.indexOf('='); if (idx > 0) { String key = line.substring(0, idx); String value = line.substring(idx + 1); - if (key.endsWith("?")) + if (key.endsWith("?") || key.endsWith("+")) { // already the correct way _defaultConfig.add(line); diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java index 55f35976e5d6..09c977c42bbc 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoModulesTests.java @@ -15,8 +15,8 @@ import java.net.URI; import java.nio.file.Path; +import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.util.FormRequestContent; @@ -27,6 +27,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,6 +35,49 @@ public class DemoModulesTests extends AbstractJettyHomeTest { + @Test + public void testDemoAddServerClasses() throws Exception + { + Path jettyBase = newTestJettyBaseDirectory(); + String jettyVersion = System.getProperty("jettyVersion"); + JettyHomeTester distribution = JettyHomeTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .jettyBase(jettyBase) + .mavenLocalRepository(System.getProperty("mavenRepoPath")) + .build(); + + int httpPort = distribution.freePort(); + int httpsPort = distribution.freePort(); + assertThat("httpPort != httpsPort", httpPort, is(not(httpsPort))); + + String[] argsConfig = { + "--add-modules=demo" + }; + + try (JettyHomeTester.Run runConfig = distribution.start(argsConfig)) + { + assertTrue(runConfig.awaitFor(5, TimeUnit.SECONDS)); + assertEquals(0, runConfig.getExitValue()); + + try (JettyHomeTester.Run runListConfig = distribution.start("--list-config")) + { + assertTrue(runListConfig.awaitFor(5, TimeUnit.SECONDS)); + assertEquals(0, runListConfig.getExitValue()); + // Example of what we expect + // jetty.webapp.addServerClasses = org.eclipse.jetty.logging.,${jetty.home.uri}/lib/logging/,org.slf4j.,${jetty.base.uri}/lib/bouncycastle/ + String addServerKey = " jetty.webapp.addServerClasses = "; + String addServerClasses = runListConfig.getLogs().stream() + .filter(s -> s.startsWith(addServerKey)) + .findFirst() + .orElseThrow(() -> + new NoSuchElementException("Unable to find [" + addServerKey + "]")); + assertThat("'jetty.webapp.addServerClasses' entry count", + addServerClasses.split(",").length, + greaterThan(1)); + } + } + } + @Test public void testJspDump() throws Exception {