You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/12/13 01:37:51 UTC
DO NOT REPLY [Bug 32661] New: -
NPE in ModuleUtils.selectModule
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32661>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32661
Summary: NPE in ModuleUtils.selectModule
Product: Struts
Version: Nightly Build
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: minor
Priority: P3
Component: Utilities
AssignedTo: dev@struts.apache.org
ReportedBy: rich@apache.org
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) {
+ request.setAttribute(key, resources);
+ } else {
+ request.removeAttribute(key);
+ }
+ }
} else {
request.removeAttribute(Globals.MODULE_KEY);
}
-
- 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);
- }
- }
}
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org