From d9ffed0a07ce7f896066915ecf4bad301f5490e1 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 14 Apr 2015 11:20:14 -0700 Subject: [PATCH] 451973 - Ambiguous module init location when mixing --add-to-start & --add-to-startd in the same exec + In case of ambiguous selection, defaults to start.ini, with warning message --- .../org/eclipse/jetty/start/BaseBuilder.java | 26 +++++++++---------- .../eclipse/jetty/start/graph/Selection.java | 11 ++++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java index aca72ab5b29..6ed1589cdec 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java @@ -157,25 +157,20 @@ public class BaseBuilder if (ambiguous.size() > 0) { - StringBuilder err = new StringBuilder(); - err.append("Unable to add "); - err.append(ambiguous.size()); - err.append(" module"); - if (ambiguous.size() > 1) - { - err.append('s'); - } - err.append(" (found declared via both --add-to-start and --add-to-startd): ["); + StringBuilder warn = new StringBuilder(); + warn.append("Ambiguous module locations detected, defaulting to --add-to-start for the following module selections:"); + warn.append(" ["); + for (int i = 0; i < ambiguous.size(); i++) { if (i > 0) { - err.append(", "); + warn.append(", "); } - err.append(ambiguous.get(i).getName()); + warn.append(ambiguous.get(i).getName()); } - err.append(']'); - throw new RuntimeException(err.toString()); + warn.append(']'); + StartLog.warn(warn.toString()); } StartLog.debug("Adding %s new module(s)",count); @@ -198,6 +193,11 @@ public class BaseBuilder StartDirBuilder builder = new StartDirBuilder(this); for (Module mod : startDModules) { + if (ambiguous.contains(mod)) + { + // skip ambiguous module + continue; + } dirty |= builder.addModule(mod); for (String file : mod.getFiles()) { diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Selection.java b/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Selection.java index 04f0166b3d5..d35c134c6fb 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Selection.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/graph/Selection.java @@ -18,6 +18,14 @@ package org.eclipse.jetty.start.graph; +/** + * Represents a selection technique. + *

+ * Each Selection can be used [0..n] times in the graph. + * The Selection must contain a unique 'how' description that represents + * how this selection was determined (what criteria the selection underwent) + *

+ */ public class Selection { private final boolean explicit; @@ -77,6 +85,9 @@ public class Selection return true; } + /** + * Get how this node was selected. + */ public String getHow() { return how;