Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 307586

Summary: ResourceRegistry should preserve order
Product: [RT] RAP Reporter: Austin Riddle <austin.riddle>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cole
Version: 1.3   
Target Milestone: 1.3 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Austin Riddle CLA 2010-03-30 17:19:38 EDT
The ResourceRegistry should preserve the order that items were added in.


### Eclipse Workspace Patch 1.0
#P org.eclipse.rap.rwt
Index: src/org/eclipse/rwt/internal/resources/ResourceRegistry.java
===================================================================
RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/resources/ResourceRegistry.java,v
retrieving revision 1.2
diff -u -r1.2 ResourceRegistry.java
--- src/org/eclipse/rwt/internal/resources/ResourceRegistry.java	12 Jun 2008 13:12:16 -0000	1.2
+++ src/org/eclipse/rwt/internal/resources/ResourceRegistry.java	30 Mar 2010 21:16:44 -0000
@@ -11,8 +11,7 @@
 
 package org.eclipse.rwt.internal.resources;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
 
 import org.eclipse.rwt.internal.util.ParamCheck;
 import org.eclipse.rwt.resources.IResource;
@@ -20,7 +19,7 @@
 
 public final class ResourceRegistry {
   
-  private static final Set resources = new HashSet();
+  private static final Set resources = new LinkedHashSet();
 
   private ResourceRegistry() {
     // prevent instantiation
Comment 1 RĂ¼diger Herrmann CLA 2010-03-31 13:57:21 EDT
Could you explain why that would matter?
When filled from the o.e.rap.ui.resources extension, the order isn't predictable anyway.
Are you having problems with dependencies of Javascript resources?
Comment 2 Cole Markham CLA 2010-03-31 15:08:37 EDT
It's been awhile, but I believe we were having issues with javascript dependencies being contributed by a single bundle. In this case the order is predictable since it gets preserved when read from the plugin.xml. The specific use case is where you have a 3rd party javascript library that needs to be loaded for use by a custom RAP widget. I don't remember the specifics, and it could possibly be avoided within the javascript itself. All I know is that we needed to add this to make it work at the time.
Comment 3 RĂ¼diger Herrmann CLA 2010-04-12 11:10:07 EDT
For your convenience, I committed the proposed change. 
However, please note that the order in which resources are processed is still considered undefined. 
A mechanism to express dependencies or a way to let the application programmer define a set of resources is necessary to resolve this issue properly. Feel free to file a bugzilla for this.
Moreover, the order in which the extensin registry returns extensions is also undefined and may change without prior notice.