[jbosstools-commits] JBoss Tools SVN: r35474 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Oct 7 14:08:00 EDT 2011


Author: scabanovich
Date: 2011-10-07 14:08:00 -0400 (Fri, 07 Oct 2011)
New Revision: 35474

Modified:
   trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java
Log:
JBIDE-9867
https://issues.jboss.org/browse/JBIDE-9867
Deadlock in Libs.updatePaths() if fixed.

Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java	2011-10-07 18:06:26 UTC (rev 35473)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java	2011-10-07 18:08:00 UTC (rev 35474)
@@ -85,7 +85,8 @@
 	}
 
 	public boolean update() {
-		boolean result = updatePaths();
+		int cpv = classpathVersion;
+		boolean result = hasToUpdatePaths() && updatePaths(getNewPaths(), cpv);
 		if(result) fire();
 		if(paths == null && result) return true;
 	
@@ -99,21 +100,29 @@
 		classpathVersion++;
 	}
 
-	synchronized boolean updatePaths() {
-		if(classpathVersion <= pathsVersion) {
-			return false;
-		}
-		pathsVersion = classpathVersion;
-		List<String> newPaths = null;
+	synchronized boolean hasToUpdatePaths() {
+		return (classpathVersion > pathsVersion);
+	}
+
+	private List<String> getNewPaths() {
+		List<String> result = null;
 		try {
-			newPaths = EclipseResourceUtil.getClassPath(getProjectResource());
+			result = EclipseResourceUtil.getClassPath(getProjectResource());
 			List<String> jre = EclipseResourceUtil.getJREClassPath(getProjectResource());
-			if(jre != null) newPaths.removeAll(jre);
+			if(jre != null) result.removeAll(jre);
 		} catch (CoreException e) {
 			ModelPlugin.getDefault().logError(e);
 		} catch(IOException e) {
 			ModelPlugin.getDefault().logError(e);			
 		}
+		return result;
+	}
+
+	private synchronized boolean updatePaths(List<String> newPaths, int cpv) {
+		if(cpv <= pathsVersion) {
+			return false;
+		}
+		pathsVersion = cpv;
 		if(paths == null && newPaths == null) return false;
 		if((newPaths != null && paths != null) && (paths.size() == newPaths.size())) {
 			boolean b = false;



More information about the jbosstools-commits mailing list