Issue Details (XML | Word | Printable)

Key: JRA-10434
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jed Wesley-Smith [Atlassian]
Reporter: William Crighton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JIRA

ClassCastException in com/atlassian/jira/issue/comparator/IssueKeyComparator

Created: 14/Jun/06 01:14 PM   Updated: 30/Jul/06 07:35 PM
Component/s: Issue Links
Affects Version/s: 3.6.1
Fix Version/s: 3.6.3

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Time Spent - 3 hours
Time Spent: 3 hours
Time Spent - 3 hours

File Attachments: 1. Java Source File IssueKeyComparator.java (1 kB)

Environment: tomcat 4.1.30, MS SQL 2K, fedora core 1

Participants: Brenda Gillespie, Jed Wesley-Smith [Atlassian], Sam Chang [Atlassian] and William Crighton
Since last comment: 2 years, 12 weeks, 4 days ago
Resolution Date: 16/Jul/06 11:22 PM
Labels:


 Description  « Hide
We upgraded to 3.6.1 recently and now we are having problems when creating links to issues. I have checked all the permissions, they are all good. I can create a link to an issue, it will show up in the issue where I created it from as long as there is no other links there. As soon as I get more than one link, the links and attachments are no longer visible.

This is the error in the log:

SEVERE: METHOD: "showIssueDetails", exception:
java.lang.ClassCastException
at com.atlassian.jira.issue.comparator.IssueKeyComparator.compare(IssueKeyComparator.java:18)
at org.apache.commons.collections.comparators.ComparatorChain.compare(ComparatorChain.java:277)

The problem is that IssueKeyComparator is expecting a Issue object for certain compare's and GenericValues for others. The attached recompiled class file contains a fix. The code below replaces the code in the 'compare' routine:

String key1 = null;
String key2 = null;

if (o1 == null && o2 == null)
return 0;
else if (o2 == null) // any value is greater than null
return 1;
else if (o1 == null) // null is less than any value
return -1;

if(o1 instanceof GenericValue && o2 instanceof GenericValue)

{ key1 = ((GenericValue ) o1).getString("key"); key2 = ((GenericValue ) o2).getString("key"); }

else if(o1 instanceof Issue && o2 instanceof Issue)

{ key1 = ((Issue ) o1).getKey(); key2 = ((Issue ) o2).getKey(); }

return KeyComparator.COMPARATOR.compare(key1, key2);



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Sam Chang [Atlassian] added a comment - 04/Jul/06 02:46 AM
Hi William,

Thanks for this report.

The code change you suggest looks good - however, we are unable to reproduce this problem locally at present. We would like to see which client of the IssueKeyComparator passes it an issue object to fully evaluate the fix.

Would it be possible to attach the entire exception that is generated when you encounter this issue?
Can you also detail the steps taken to reproduce the exception?

Many Thanks,
Keith


Brenda Gillespie added a comment - 07/Jul/06 03:27 PM
Hi Keith,

See the issue JSP-5917. That is the exception that we were getting in the log file. We upgraded from 3.2.3 to 3.6.1. The system information is also on that issue.

To reproduce the issue was simple - have more than one link to issues. If only one link existed on the originall issue and the linked issue - works great. If there was more than one link you could no longer see any linked issues.


Jed Wesley-Smith [Atlassian] added a comment - 16/Jul/06 11:22 PM
Actual fix casts rhs & lhs separately so different inputs on each side do not provide a false equals. Also allows String as an input.

Jed Wesley-Smith [Atlassian] added a comment - 17/Jul/06 12:09 AM
did not quite make it into 3.6.3, apologies all

Jed Wesley-Smith [Atlassian] added a comment - 17/Jul/06 12:17 AM
actually, it just snuck into 3.6.3