Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 260963 - string compare for Bugzilla versions is not robust
Summary: string compare for Bugzilla versions is not robust
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1   Edit
Assignee: Frank Becker CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 262508 (view as bug list)
Depends on:
Blocks: 166595
  Show dependency tree
 
Reported: 2009-01-13 22:16 EST by Steffen Pingel CLA
Modified: 2009-03-26 17:47 EDT (History)
2 users (show)

See Also:


Attachments
patch (15.24 KB, patch)
2009-01-18 07:54 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (4.67 KB, application/octet-stream)
2009-01-18 07:54 EST, Frank Becker CLA
no flags Details
patch with jUnit (15.74 KB, patch)
2009-01-19 16:06 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (5.26 KB, application/octet-stream)
2009-01-19 16:07 EST, Frank Becker CLA
no flags Details
updated patch (17.91 KB, patch)
2009-01-28 17:04 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (6.15 KB, application/octet-stream)
2009-01-28 17:04 EST, Frank Becker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2009-01-13 22:16:49 EST
BugzillaClient uses String comparison to determine if the server has a certain release or higher installed:

 String bugzillaVersion = repositoryConfiguration.getInstallVersion();
 if (bugzillaVersion.compareTo("2.18") < 0) {
  ...
 }
 
This is not robust for versions > 10, e.g. 2.18 < 2.2 although was released in 1999 and 2.18 in 2005. JiraVersion has an implementation that compares version numbers by segment.
Comment 1 Frank Becker CLA 2009-01-18 07:54:30 EST
Created attachment 122875 [details]
patch
Comment 2 Frank Becker CLA 2009-01-18 07:54:34 EST
Created attachment 122876 [details]
mylyn/context/zip
Comment 3 Steffen Pingel CLA 2009-01-19 14:29:27 EST
That looks good. Minor nit: We should probably not define constants in the code that are not used and it would be nice to have a few test cases for this :). 
Comment 4 Frank Becker CLA 2009-01-19 16:06:55 EST
Created attachment 123002 [details]
patch with jUnit

Should we add more tests?
Comment 5 Frank Becker CLA 2009-01-19 16:07:00 EST
Created attachment 123003 [details]
mylyn/context/zip
Comment 6 Steffen Pingel CLA 2009-01-19 16:25:25 EST
Looks great. Rob, can you review?
Comment 7 Robert Elves CLA 2009-01-27 00:12:57 EST
Great. One thought is that we should consider guarding against the possibility of a NuberFormatException i.e. in case someone out there is running a custom or forked bugzilla with an alphanumeric version string.
Comment 8 Steffen Pingel CLA 2009-01-27 01:46:15 EST
Good catch. The same fix needs to be applied to JiraVersion and a test added (bug 262508).
Comment 9 Frank Becker CLA 2009-01-28 17:04:42 EST
Created attachment 124098 [details]
updated patch

JiraVersion fix included. But the catch of NumberFormatException is to do.

For Bugzilla we catch this in setInstallVersion() and set the version to MIN_VERSION.
Comment 10 Frank Becker CLA 2009-01-28 17:04:44 EST
Created attachment 124099 [details]
mylyn/context/zip
Comment 11 Robert Elves CLA 2009-01-29 11:44:00 EST
Patch applied, ip log updated.  Updated JiraVersion.parse to catch the exception and return 0. Looks like the right behavior for JIRA, Steffen, please review.
Comment 12 Thomas Ehrnhoefer CLA 2009-03-26 17:47:01 EDT
*** Bug 262508 has been marked as a duplicate of this bug. ***