From dbaf0bf69dc70004eb1a6954f89b70e041d6cf52 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 3 Mar 2020 13:51:33 -0600 Subject: [PATCH] Issue #4628 - Ensuring checkEnabledModules is required dependency aware Signed-off-by: Joakim Erdfelt --- .../java/org/eclipse/jetty/start/Modules.java | 22 ++++++++++--------- .../org/eclipse/jetty/start/ModulesTest.java | 3 +++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index bc33e2798280..4060d6cd6c35 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -487,17 +487,19 @@ public void checkEnabledModules() _modules.stream().filter(Module::isEnabled).forEach(m -> { // Check dependencies - m.getDepends().forEach(d -> - { - Set providers = getAvailableProviders(d); - if (providers.stream().filter(Module::isEnabled).count() == 0) + m.getDepends().stream() + .filter(Module::isRequiredDependency) + .forEach(d -> { - if (unsatisfied.length() > 0) - unsatisfied.append(','); - unsatisfied.append(m.getName()); - StartLog.error("Module %s requires a module providing %s from one of %s%n", m.getName(), d, providers); - } - }); + Set providers = getAvailableProviders(d); + if (providers.stream().noneMatch(Module::isEnabled)) + { + if (unsatisfied.length() > 0) + unsatisfied.append(','); + unsatisfied.append(m.getName()); + StartLog.error("Module %s requires a module providing %s from one of %s%n", m.getName(), d, providers); + } + }); }); if (unsatisfied.length() > 0) diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java index 461351ceea59..68dbe4a3de01 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java @@ -234,6 +234,7 @@ public void testResolveNotRequiredModuleNotFound() throws IOException // Collect active module list List active = modules.getEnabled(); + modules.checkEnabledModules(); // Assert names are correct, and in the right order List expectedNames = new ArrayList<>(); @@ -282,6 +283,7 @@ public void testResolveNotRequiredModuleFound() throws IOException // Collect active module list List active = modules.getEnabled(); + modules.checkEnabledModules(); // Assert names are correct, and in the right order List expectedNames = new ArrayList<>(); @@ -331,6 +333,7 @@ public void testResolveNotRequiredModuleFoundDynamic() throws IOException // Collect active module list List active = modules.getEnabled(); + modules.checkEnabledModules(); // Assert names are correct, and in the right order List expectedNames = new ArrayList<>();