Skip to content

Commit

Permalink
Revert "STS-2472: wrapping getResolvedClasspath into a job to avoid t…
Browse files Browse the repository at this point in the history
…oo broad locking"

This reverts commit f872407.
  • Loading branch information
Martin Lippert committed Mar 2, 2012
1 parent f872407 commit 58fbd02
Showing 1 changed file with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.jdt.core.ElementChangedEvent;
Expand Down Expand Up @@ -126,7 +124,7 @@ private static void addClassPathUrls(IProject project, List<URL> paths, Set<IPro
if (JdtUtils.isJavaProject(project)) {
IJavaProject jp = JavaCore.create(project);
// configured classpath
IClasspathEntry[] classpath = safeGetResolvedClasspath(jp);
IClasspathEntry[] classpath = jp.getResolvedClasspath(true);

// add class path entries
for (int i = 0; i < classpath.length; i++) {
Expand Down Expand Up @@ -172,27 +170,7 @@ else if (path.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
catch (Exception e) {
// ignore
}
}

/**
* Gets the resolved classpath in a safe manner by first grabbing the build rule
* to prevent deadlock.
* @param jp
* @return resolved classpath of the project
*/
protected static IClasspathEntry[] safeGetResolvedClasspath(final IJavaProject jp) {
final IClasspathEntry[][] cp = new IClasspathEntry[1][];
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
cp[0] = jp.getResolvedClasspath(true);
}
}, ResourcesPlugin.getWorkspace().getRuleFactory().buildRule(), IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
SpringCore.log(e);
}
return cp[0];
}
}

private static void addUri(List<URL> paths, URI uri) throws MalformedURLException {
File file = new File(uri);
Expand Down

0 comments on commit 58fbd02

Please sign in to comment.