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

Bug 337957

Summary: Redundant caching call in DefaultOppositeEndFinder
Product: [Modeling] OCL Reporter: Axel Uhl <eclipse>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ed
Version: 3.1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Axel Uhl CLA 2011-02-23 05:36:02 EST
What should have been a side effect free getter (getLoadedPackages()) performs a side effect on the packages member variable and redundantly calls cachePackage(...). This shouldn't be the case. The following patch fixes this:

@@ -130,14 +130,14 @@ public class DefaultOppositeEndFinder
 	}
 	
 	private Set<EPackage> getLoadedPackages() {
+		Set<EPackage> result = new HashSet<EPackage>();
 		for (Object key : registry.values()) {
 			// if it's not a package descriptor indicating a not yet loaded package, add it
 			if (key instanceof EPackage) {
-				packages.add((EPackage) key);
-				cachePackage((EPackage) key);
+				result.add((EPackage) key);
 			}
 		}
-		return packages;
+		return result;
 	}
 
 	protected DefaultOppositeEndFinder(Registry registry) {
Comment 1 Ed Willink CLA 2011-02-23 05:46:51 EST
+1

Since it's a simple private method, perhaps it could be flattened.
Comment 2 Axel Uhl CLA 2011-02-23 05:57:12 EST
Inlined as suggested and committed.
Comment 3 Ed Willink CLA 2011-05-27 03:13:39 EDT
Closing