[jbosstools-commits] JBoss Tools SVN: r43891 - trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Sep 20 19:58:44 EDT 2012


Author: scabanovich
Date: 2012-09-20 19:58:44 -0400 (Thu, 20 Sep 2012)
New Revision: 43891

Modified:
   trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java
Log:
JBIDE-12479
https://issues.jboss.org/browse/JBIDE-12479
Cache unique Path objects.


Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java	2012-09-20 23:58:05 UTC (rev 43890)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/internal/LinkCollection.java	2012-09-20 23:58:44 UTC (rev 43891)
@@ -18,6 +18,7 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.jboss.tools.common.el.core.ELReference;
+import org.jboss.tools.common.util.UniquePaths;
 import org.jboss.tools.common.validation.ValidationMessages;
 import org.jboss.tools.common.xml.XMLUtilities;
 import org.w3c.dom.Element;
@@ -54,6 +55,8 @@
 		if(variableName==null) {
 			throw new IllegalArgumentException(ValidationMessages.VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL);
 		}
+		
+		linkedResourcePath = UniquePaths.getInstance().intern(linkedResourcePath);
 
 		if(resourcesByVariableName != null) {
 			synchronized(this) {
@@ -70,15 +73,18 @@
 			}
 		}
 
+		Set<String> variableNames = null;
 		// Save link between resource and variable names. It's needed if variable name changes in resource file.
-		Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
-		if(variableNames==null) {
-			variableNames = new HashSet<String>();
-			variableNamesByResource.put(linkedResourcePath, variableNames);
+		synchronized(this) {
+			variableNames = variableNamesByResource.get(linkedResourcePath);
+			if(variableNames==null) {
+				variableNames = new HashSet<String>();
+				variableNamesByResource.put(linkedResourcePath, variableNames);
+			}
+			if(variableNames.add(variableName.intern())) {
+				modifications++;
+			}
 		}
-		if(variableNames.add(variableName.intern())) {
-			modifications++;
-		}
 
 		if(declaration) {
 			synchronized(this) {



More information about the jbosstools-commits mailing list