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 2005/01/16 16:50:29 UTC
DO NOT REPLY [Bug 33122] New: -
unchecked exception when paramId value already in the params map
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=33122>.
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=33122
Summary: unchecked exception when paramId value already in the
params map
Product: Struts
Version: 1.2.6 Beta
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Custom Tags
AssignedTo: dev@struts.apache.org
ReportedBy: uwe_ewald@yahoo.com
Within the computeParameters of org.apache.struts.taglib.TagUtils the paramValue
is added to the param Map.
If there is a value already been mapped to the key described by paramId, the new
value should be added to it as string array.
If the value is something other than a string or an array of strings the code
throws an unchecked exception.
It is obvious when looking at the code:
Object mapValue = results.get(paramId);
if (mapValue == null) {
results.put(paramId, paramString);
} else if (mapValue instanceof String) {
String newValues[] = new String[2];
newValues[0] = (String) mapValue;
newValues[1] = paramString;
results.put(paramId, newValues);
} else {
String oldValues[] = (String[]) mapValue;
String newValues[] = new String[oldValues.length + 1];
System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
newValues[oldValues.length] = paramString;
results.put(paramId, newValues);
}
Initially, when this lines were part of the RequestUtils there was the proper
instanceof check. But only as comment. Wonder why.
This would be correct:
Object mapValue = results.get(paramId);
if (mapValue == null) {
results.put(paramId, paramString);
} else if (mapValue instanceof String[]) {
String oldValues[] = (String[]) mapValue;
String newValues[] = new String[oldValues.length + 1];
System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
newValues[oldValues.length] = paramString;
results.put(paramId, newValues);
} else {
String newValues[] = new String[2];
newValues[0] = mapValue.toString();
newValues[1] = paramString;
results.put(paramId, newValues);
}
--
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