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: [email protected] ReportedBy: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
