Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.2.2, 1.2.4, 1.2.6 Beta, Nightly Build
-
None
-
Operating System: Windows XP
Platform: PC
-
32661
Description
If you pass in an unresolvable module prefix to ModuleUtils.selectModule(), you
get an NPE when the method tries to find message resources for the (null)
module. It looks like the method is meant to handle unresolvable modules,
though, since it initially does a null check after calling getModuleConfig().
Made this P3 because it's easy to work around. To reproduce this, just call
ModuleUtils.getInstance().selectModule( "/xyzzy", request, context ); where
"/xyzzy" is not a registered module.
Here's a patch (as if you need it ):
Index: src/share/org/apache/struts/util/ModuleUtils.java
===================================================================
— src/share/org/apache/struts/util/ModuleUtils.java (revision 111678)
+++ src/share/org/apache/struts/util/ModuleUtils.java (working copy)
@@ -241,20 +241,20 @@
if (config != null) {
request.setAttribute(Globals.MODULE_KEY, config);
+
+ MessageResourcesConfig[] mrConfig =
config.findMessageResourcesConfigs();
+ for(int i = 0; i < mrConfig.length; i++) {
+ String key = mrConfig[i].getKey();
+ MessageResources resources =
+ (MessageResources) context.getAttribute(key + prefix);
+ if (resources != null)
else
{ + request.removeAttribute(key); + }+ }
} else
-
- MessageResourcesConfig[] mrConfig = config.findMessageResourcesConfigs();
- for(int i = 0; i < mrConfig.length; i++) {
- String key = mrConfig[i].getKey();
- MessageResources resources =
- (MessageResources) context.getAttribute(key + prefix);
- if (resources != null)
{
- request.setAttribute(key, resources);
- }
else
{ - request.removeAttribute(key); - } - }
}
}