Skip to content

Commit

Permalink
Merge pull request #11913 from jetty/fix/12.0.x/start-concurrent-mod-…
Browse files Browse the repository at this point in the history
…exception

Issue #11909 - duplicate --modules=<name> can trigger ConcurrentModificationException
  • Loading branch information
joakime authored Jun 13, 2024
2 parents 8efde86 + a616aca commit cb66c6d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
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

0 comments on commit cb66c6d

Please sign in to comment.