Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jetty-start/src/main/java/org/eclipse/jetty/start/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,13 +27,57 @@

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;
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
{
Expand Down