Issue #6017 - fix accidentally broken k+=v property usage (#7510)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2022-02-01 13:58:41 -06:00 committed by GitHub
parent 66d3165a8c
commit 3791f38684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 4 deletions

View File

@ -417,14 +417,14 @@ public class Module implements Comparable<Module>
case "DEFAULTS": // old name introduced in 9.2.x
case "INI": // new name for 9.3+
{
// All default properties are to be treated as `<k>?=<v>` by the configuration system
// even if they are present as `<k>=<v>`
// If a property is specified as `<k>=<v>` it is to be treated as `<k>?=<v>`.
// All other property usages are left as-is (eg: `<k>+=<v>`)
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);

View File

@ -15,8 +15,8 @@ package org.eclipse.jetty.tests.distribution;
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 org.junit.jupiter.api.Test;
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 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
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
{