Skip to content

Commit

Permalink
central: Refresh workspace inside bndLock for cnf change
Browse files Browse the repository at this point in the history
If a change to cnf was detected, we called workspace refresh without
regard to any running builders. This caused issues where the workspace
refresh closed repos while a builder was running.

We now refresh the workspace while holding the bndLock. We use a job
to handle this in case we need to wait for the lock and don't want to
block the notification (which could be the main) thread.

Signed-off-by: BJ Hargrave <bj@hargrave.dev>
  • Loading branch information
bjhargrave committed Nov 11, 2021
1 parent efbb69f commit f9f2e2c
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 f9f2e2c

Please sign in to comment.