|
49 | 49 | import org.eclipse.core.resources.IContainer;
|
50 | 50 | import org.eclipse.core.resources.IFile;
|
51 | 51 | import org.eclipse.core.resources.IProject;
|
| 52 | +import org.eclipse.core.resources.ResourcesPlugin; |
52 | 53 | import org.eclipse.core.runtime.CoreException;
|
53 | 54 | import org.eclipse.core.runtime.IPath;
|
54 | 55 | import org.eclipse.core.runtime.IProgressMonitor;
|
| 56 | +import org.eclipse.core.runtime.IStatus; |
55 | 57 | import org.eclipse.core.runtime.NullProgressMonitor;
|
56 | 58 | import org.eclipse.core.runtime.Path;
|
| 59 | +import org.eclipse.core.runtime.Status; |
57 | 60 | import org.eclipse.core.runtime.SubMonitor;
|
58 | 61 | import org.eclipse.core.runtime.jobs.Job;
|
59 | 62 | import org.eclipse.debug.core.DebugPlugin;
|
@@ -317,11 +320,26 @@ public void process(Document pom) {
|
317 | 320 |
|
318 | 321 | @Override
|
319 | 322 | public Job updateProjectConfiguration() {
|
320 |
| - Job job = new UpdateMavenProjectJob(new IProject[] { |
321 |
| - getProject() |
322 |
| - }); |
323 |
| - job.schedule(); |
324 |
| - return job; |
| 323 | + //We wrap the UpdateMavenProjectJob in another job to avoid a race condition |
| 324 | + //that causes a deadlock. The race condition is avoided by have the |
| 325 | + //waitForWorkspaceLock wrapper which ensures that pending workspace jobs |
| 326 | + //are finished before triggering maven project update. |
| 327 | + //See: https://github.com/spring-projects/sts4/issues/780 |
| 328 | + Job waitForWorkspaceLock = new Job("Wait for for workspace") { |
| 329 | + { |
| 330 | + setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); |
| 331 | + } |
| 332 | + |
| 333 | + @Override |
| 334 | + protected IStatus run(IProgressMonitor arg0) { |
| 335 | + Job job = new UpdateMavenProjectJob(new IProject[] { |
| 336 | + getProject() |
| 337 | + }); |
| 338 | + job.schedule(); |
| 339 | + return Status.OK_STATUS; |
| 340 | + } |
| 341 | + }; |
| 342 | + return waitForWorkspaceLock; |
325 | 343 | }
|
326 | 344 |
|
327 | 345 | @Override
|
|
0 commit comments