| Summary: | [ui] [repo] I can add the same repo twice | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Equinox | Reporter: | Susan McCourt <susan> | ||||
| Component: | p2 | Assignee: | John Arthorne <john.arthorne> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | john.arthorne, mober.at+eclipse, pascal, simon_kaegi | ||||
| Version: | 3.4 | ||||||
| Target Milestone: | 3.4 RC2 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Susan McCourt
From bug #232791: Build ID: I20080516-1333 (3.4rc1) Install some stuff into Eclipse via links/ Choose Help > Software Updates... Get attached display. There are several sites listed twice, which only differ by trailing slash. These sites should be listed once only. For instance: http://download.eclipse.org/tools/cdt/releases/ganymede http://download.eclipse.org/tools/cdt/releases/ganymede/ Marking this one RC2 so it can be investigated. I originally thought I had added the repo myself with different URL's, but it's possible that p2 itself is doing this. *** Bug 232791 has been marked as a duplicate of this bug. *** The problem here is that java.net.URL says those two URLs are not equal. A potential fix is to change our repository key to omit the slash:
private String getKey(URL location) {
String key = location.toExternalForm().replace('/', '_');
//remove trailing slash because it is equivalent with or without the slash
int len = key.length();
if (len > 0 && key.charAt(len - 1) == '_')
key = key.substring(0, len - 1);
return key;
}
This would ensure we don't store multiple repos that differ only in trailing slash, but doesn't mess with the URL that is used in loading the repository.
Note that java.net.URL.equals() and hashCode() should be avoided anyways, because they have very problematic performance characteristics: http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html Created attachment 101386 [details]
Fix v01
This fix adds a containment check before adding a repository. This revealed two test failures. These tests were relying on the side-effect of addRepository(URL) blowing away the existing repository in memory. Since we now do the containment check, this no longer happens. This may have been causing repositories to be flushed too often (for example when adding a repository reference or discovery site), that would have been causing excessive re-loading of repository contents.
+1 +1 Released. *** Bug 229069 has been marked as a duplicate of this bug. *** |