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 #11909 - duplicate --modules=<name> can trigger ConcurrentModificationException #11913

Merged
merged 1 commit into from
Jun 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,11 @@ private void selectModules(String source, List<String> moduleNames)
{
for (String moduleName : moduleNames)
{
modules.add(moduleName);
Set<String> set = sources.computeIfAbsent(moduleName, k -> new HashSet<>());
set.add(source);
if (modules.add(moduleName))
{
Set<String> set = sources.computeIfAbsent(moduleName, k -> new HashSet<>());
set.add(source);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -183,4 +184,27 @@ public void testJvmArgExpansion() throws Exception
);
assertThat(commandLine, containsString(expectedExpansion));
}

@Test
public void testModulesDeclaredTwice() throws Exception
{
List<String> cmdLineArgs = new ArrayList<>();

Path homePath = MavenPaths.findTestResourceDir("dist-home");
Path basePath = MavenPaths.findTestResourceDir("overdeclared-modules");
cmdLineArgs.add("jetty.home=" + homePath);
cmdLineArgs.add("user.dir=" + basePath);

Main main = new Main();

cmdLineArgs.add("--module=main");

// The "main" module is enabled in both ...
// 1) overdeclared-modules/start.d/config.ini
// 2) command-line
// This shouldn't result in an error
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[0]));

assertThat(args.getSelectedModules(), hasItem("main"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--modules=main
Loading