Skip to content

Commit

Permalink
Merge pull request #4944 from bjhargrave/race-condition-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhargrave committed Nov 11, 2021
2 parents efbb69f + f9f2e2c commit 37c9c11
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bndtools.core/src/bndtools/central/Central.java
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.TreeViewer;
Expand Down Expand Up @@ -429,8 +430,21 @@ private static void addCnfChangeListener(final Workspace workspace) {
}
IResourceDelta rootDelta = event.getDelta();
if (isCnfChanged(workspace, rootDelta)) {
logger.error("cnf changed; refreshing workspace");
workspace.refresh();
logger.info("cnf changed; refreshing workspace");
// Move off notification thread
Job job = new Job("Refreshing workspace for cnf change") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
// Avoid race condition with BndtoolsBuilder
bndCall(after -> workspace.refresh(), monitor);
} catch (Exception e) {
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, "error during workspace refresh", e);
}
return Status.OK_STATUS;
}
};
job.schedule();
}
});
}
Expand Down

0 comments on commit 37c9c11

Please sign in to comment.