Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 262118 - omni VersionRange NPE in intersects
Summary: omni VersionRange NPE in intersects
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Pascal Rapicault CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-22 22:10 EST by Henrik Lindberg CLA
Modified: 2009-01-23 12:29 EST (History)
2 users (show)

See Also:


Attachments
Fix of error in VersionRange intersect causing NPE (31.67 KB, patch)
2009-01-22 22:19 EST, Henrik Lindberg CLA
no flags Details | Diff
Inclusion of intersect test, and fix of issue with one of its tests (1.83 KB, patch)
2009-01-22 22:20 EST, Henrik Lindberg CLA
pascal: iplog+
Details | Diff
Patched VersionRange.java (with correct encoding) (15.53 KB, text/plain)
2009-01-23 06:31 EST, Thomas Hallgren CLA
pascal: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Henrik Lindberg CLA 2009-01-22 22:10:20 EST
When an intersects is performed on raw Versions the test for version equality fails.

Lines 87-88 in VersionRange.java should read like this:

else if (!(minVersion.getFormat() == null ? maxVersion.getFormat() == null :  minVersion.getFormat().equals(maxVersion.getFormat())))
					throw new IllegalArgumentException(NLS.bind(Messages.range_boundaries_0_and_1_cannot_have_different_formats, minVersion, maxVersion));

Don't know if this has been fixed in a yet uncommitted patch - I am happy to provide a patch for it otherwise.

Tested in eclipse-SDK-I20090122-0800-macosx-carbon

There is also a problem in that the intersect test is not added to AllTests, so it only runs on demand - that is probably why this bug slipped in. (I am happy to patch that too)
Comment 1 Henrik Lindberg CLA 2009-01-22 22:16:06 EST
There is also an error in IntersectText.testPartialEqualUpper  the test is wrong.
Comment 2 Pascal Rapicault CLA 2009-01-22 22:18:29 EST
You are the official maintainer of the OmniVersion support so a patch would be welcome :)
The OmniVersion test suite is part of the automated test. See class org.eclipse.equinox.p2.tests.AutomatedTests
Comment 3 Henrik Lindberg CLA 2009-01-22 22:19:41 EST
Created attachment 123477 [details]
Fix of error in VersionRange intersect causing NPE
Comment 4 Henrik Lindberg CLA 2009-01-22 22:20:52 EST
Created attachment 123478 [details]
Inclusion of intersect test, and fix of issue with one of its tests
Comment 5 Henrik Lindberg CLA 2009-01-22 22:23:20 EST
(In reply to comment #2)
> You are the official maintainer of the OmniVersion support so a patch would be
> welcome :)
Patches attached.
> The OmniVersion test suite is part of the automated test. See class
> org.eclipse.equinox.p2.tests.AutomatedTests
> 
Yes, I added it there, but IntersectTest was not included in OmniVersion AllTests. The patch fixes this oversight.
Comment 6 Henrik Lindberg CLA 2009-01-22 22:31:00 EST
hm - the VersionRange still has bad line endings - the patch is just one long line.... Can a comitter please fix this before I make another (functioning) patch?
Comment 7 Pascal Rapicault CLA 2009-01-22 22:48:35 EST
Could you please attach the full copy of the class as we still have this encoding issue. I'll look into this though I'm not sure where to look (if you have hints, lmk)

Comment 8 Pascal Rapicault CLA 2009-01-22 22:50:07 EST
Assigning to me just to make sure I don't forget about it.
Comment 9 Thomas Hallgren CLA 2009-01-23 06:31:12 EST
Created attachment 123503 [details]
Patched VersionRange.java (with correct encoding)

(In reply to comment #7)
> Could you please attach the full copy of the class as we still have this
> encoding issue. I'll look into this though I'm not sure where to look (if you
> have hints, lmk)
> 
You need to replace the content of the file by other means then pasting new content into the Eclipse IDE editor since it will preserve the old encoding. Here's how I'd do it:

See to that the file is not opened in your IDE.

From a shell, Use od -c on the file. Verify that it has the old format (you will see a lot of \r in it).

Use cp to copy the new file onto the old one. Use od -c on the file again. No \r should exist. They are all replaced by \n.

Refresh your workspace and commit the file.
Comment 10 Pascal Rapicault CLA 2009-01-23 12:27:33 EST
Changes released in HEAD.
Comment 11 Pascal Rapicault CLA 2009-01-23 12:29:03 EST
Comment on attachment 123503 [details]
Patched VersionRange.java (with correct encoding)

Note that the actual patch looks large, because of technical pb with the encoding of teh file in the repo, but the code contribution is actually quite small