Message: A new issue has been created in JIRA.
--------------------------------------------------------------------- View the issue: http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-247 Here is an overview of the issue: --------------------------------------------------------------------- Key: WW-247 Summary: webwork.util.Sorter, dubious code in getDescending Type: Improvement Status: Assigned Priority: Minor Project: WebWork Assignee: Patrick Lightbody Reporter: Matthew Hague Created: Fri, 8 Aug 2003 12:15 PM Updated: Fri, 8 Aug 2003 12:15 PM Description: The following code is in webwork.util.Sorter. There's something not quite right as this: if (v2 instanceof Comparable && v1.getClass().equals(v2.getClass())) does not need to be used when v1 and v2 are declared Strings. In getAscending v1 and v2 are replaced by objects. The reason i found this i that some of my code gets a null pointer exception, probably caused by the lack of NP checking on findValue, before toString is called. public Comparator getDescending(final String anExpression) { return new Comparator() { private ValueStack stack = new ValueStack(); public int compare(Object o1, Object o2) { // Get value for first object stack.pushValue(o1); String v1 = stack.findValue(anExpression).toString(); stack.popValue(); // Get value for second object stack.pushValue(o2); String v2 = stack.findValue(anExpression).toString(); stack.popValue(); // Ensure non-null if (v1 == null) v1 = ""; if (v2 == null) v2 = ""; // Compare them if (v2 instanceof Comparable && v1.getClass().equals(v2.getClass())) { return ((Comparable)v2).compareTo(v1); } else { String s1 = v1.toString(); String s2 = v2.toString(); return s2.compareTo(s1); } } }; } --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.opensymphony.com/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork