[426003] active modules with missing dependencies fail accordingly, non-active with missing deps fail silently

This commit is contained in:
Jesse McConnell 2014-02-04 14:09:04 -06:00
parent 4844508c5f
commit ba318ccbd3
7 changed files with 129 additions and 14 deletions

View File

@ -572,7 +572,7 @@ public class Main
args.setAllModules(modules);
List<Module> activeModules = modules.resolveEnabled();
// 7) Lib & XML Expansion / Resolution
args.expandModules(baseHome,activeModules);

View File

@ -39,6 +39,13 @@ import java.util.regex.Pattern;
public class Modules implements Iterable<Module>
{
private Map<String, Module> modules = new HashMap<>();
/*
* modules that may appear in the resolved graph but are undefined in the module system
*
* ex: modules/npn/npn-1.7.0_01.mod (property expansion resolves to non-existent file)
*/
private Set<String> missingModules = new HashSet<String>();
private int maxDepth = -1;
private Set<String> asNameSet(Set<Module> moduleSet)
@ -110,7 +117,7 @@ public class Modules implements Iterable<Module>
if (parent == null)
{
System.err.printf("WARNING: module not found [%s]%n",parentName);
StartLog.debug("module not found [%s]%n",parentName);
}
else
{
@ -124,7 +131,7 @@ public class Modules implements Iterable<Module>
Module optional = get(optionalParentName);
if (optional == null)
{
System.err.printf("WARNING: module not found [%s]%n",optionalParentName);
StartLog.debug("optional module not found [%s]%n",optionalParentName);
}
else if (optional.isEnabled())
{
@ -285,12 +292,12 @@ public class Modules implements Iterable<Module>
}
}
private void findParents(Module module, Set<Module> ret)
private void findParents(Module module, Map<String, Module> ret)
{
ret.add(module);
ret.put(module.getName(), module);
for (Module parent : module.getParentEdges())
{
ret.add(parent);
ret.put(parent.getName(), parent);
findParents(parent,ret);
}
}
@ -370,7 +377,7 @@ public class Modules implements Iterable<Module>
}
// load missing post-expanded dependent modules
boolean done = false;
boolean done = false;
while (!done)
{
done = true;
@ -380,7 +387,7 @@ public class Modules implements Iterable<Module>
{
for (String parent : m.getParentNames())
{
if (modules.containsKey(parent))
if (modules.containsKey(parent) || missingModules.contains(parent))
{
continue; // found. skip it.
}
@ -392,8 +399,16 @@ public class Modules implements Iterable<Module>
for (String missingParent : missingParents)
{
File file = basehome.getFile("modules/" + missingParent + ".mod");
Module module = registerModule(basehome,args,file);
updateParentReferencesTo(module);
if ( FS.canReadFile(file) )
{
Module module = registerModule(basehome,args,file);
updateParentReferencesTo(module);
}
else
{
StartLog.debug("Missing module definition: [ Mod: %s | File: %s]", missingParent, file);
missingModules.add(missingParent);
}
}
}
}
@ -425,7 +440,7 @@ public class Modules implements Iterable<Module>
*/
public List<Module> resolveEnabled()
{
Set<Module> active = new HashSet<Module>();
Map<String, Module> active = new HashMap<String,Module>();
for (Module module : modules.values())
{
@ -435,18 +450,37 @@ public class Modules implements Iterable<Module>
}
}
/*
* check against the missing modules
*
* Ex: npn should match anything under npn/
*/
for ( String missing : missingModules )
{
for (String activeModule: active.keySet())
{
if ( missing.startsWith(activeModule) )
{
StartLog.warn("** Unable to continue, required dependency missing. [%s]", missing);
StartLog.warn("** As configured, Jetty is unable to start due to a missing enabled module dependency.");
StartLog.warn("** This may be due to a transitive dependency akin to spdy on npn, which resolves based on the JDK in use.");
return Collections.emptyList();
}
}
}
List<Module> ordered = new ArrayList<>();
ordered.addAll(active);
ordered.addAll(active.values());
Collections.sort(ordered,new Module.DepthComparator());
return ordered;
}
public Set<String> resolveParentModulesOf(String moduleName)
{
Set<Module> ret = new HashSet<>();
Map<String,Module> ret = new HashMap<>();
Module module = get(moduleName);
findParents(module,ret);
return asNameSet(ret);
return ret.keySet();
}
private String toIndent(int depth)

View File

@ -61,11 +61,24 @@ public class TestUseCases
assertUseCase("home","base.jmx","assert-jmx.txt");
}
@Test
public void testWithMissingNpnVersion() throws Exception
{
assertUseCase("home","base.missing.npn.version","assert-missing-npn-version.txt","java.version=1.7.0_01");
}
@Test
public void testWithSpdy() throws Exception
{
assertUseCase("home","base.enable.spdy","assert-enable-spdy.txt","java.version=1.7.0_21");
}
@Test
public void testWithSpdyBadNpnVersion() throws Exception
{
//StartLog.enableDebug();
assertUseCase("home","base.enable.spdy.bad.npn.version","assert-enable-spdy-bad-npn-version.txt","java.version=1.7.0_01");
}
@Test
public void testWithDatabase() throws Exception

View File

@ -0,0 +1,16 @@
# The XMLs we expect (order is important)
# The LIBs we expect (order is irrelevant)
# The Properties we expect (order is irrelevant)
PROP|jetty.port=9090
PROP|jetty.keystore=etc/keystore
PROP|jetty.keystore.password=friendly
PROP|jetty.keymanager.password=icecream
PROP|jetty.truststore=etc/keystore
PROP|jetty.truststore.password=sundae
PROP|java.version=1.7.0_01
# The Downloads
# The Bootlib

View File

@ -0,0 +1,28 @@
# The XMLs we expect (order is important)
XML|${jetty.home}/etc/jetty-jmx.xml
XML|${jetty.home}/etc/jetty.xml
XML|${jetty.home}/etc/jetty-http.xml
# The LIBs we expect (order is irrelevant)
LIB|${jetty.home}/lib/jetty-continuation-TEST.jar
LIB|${jetty.home}/lib/jetty-http-TEST.jar
LIB|${jetty.home}/lib/jetty-io-TEST.jar
LIB|${jetty.home}/lib/jetty-jmx-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-server-TEST.jar
LIB|${jetty.home}/lib/jetty-util-TEST.jar
LIB|${jetty.home}/lib/jetty-xml-TEST.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
# The Properties we expect (order is irrelevant)
PROP|jetty.port=9090
PROP|jetty.keystore=etc/keystore
PROP|jetty.keystore.password=friendly
PROP|jetty.keymanager.password=icecream
PROP|jetty.truststore=etc/keystore
PROP|jetty.truststore.password=sundae
PROP|java.version=1.7.0_01
# The Downloads
# The Bootlib

View File

@ -0,0 +1,12 @@
--module=server,http,jmx,spdy
jetty.port=9090
# Some SSL keystore configuration
jetty.keystore=etc/keystore
jetty.keystore.password=friendly
jetty.keymanager.password=icecream
jetty.truststore=etc/keystore
jetty.truststore.password=sundae

View File

@ -0,0 +1,12 @@
--module=server,http,jmx
jetty.port=9090
# Some SSL keystore configuration
jetty.keystore=etc/keystore
jetty.keystore.password=friendly
jetty.keymanager.password=icecream
jetty.truststore=etc/keystore
jetty.truststore.password=sundae