Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't return null in JobManager::createMonitor #1282

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,12 @@ private <T, J extends InternalJob> T withWriteLock(J job, Function<J, T> functio
* Returns a new progress monitor for this job. Never returns null.
*/
private IProgressMonitor createMonitor(Job job) {
if (progressProvider != null) {
return progressProvider.createMonitor(job);
}
return new NullProgressMonitor();
IProgressMonitor monitor = null;
if (progressProvider != null)
monitor = progressProvider.createMonitor(job);
if (monitor == null)
monitor = new NullProgressMonitor();
return monitor;
}

@Override
Expand Down Expand Up @@ -905,10 +907,8 @@ protected boolean isBlocking(InternalJob runningJob) {
while (previous != null) {
// ignore jobs of lower priority (higher priority value means lower priority)
if (previous.getPriority() < runningJob.getPriority()) {
if (!previous.isSystem())
return true;
// implicit jobs should interrupt unless they act on behalf of system jobs
if (previous instanceof ThreadJob && ((ThreadJob) previous).shouldInterrupt())
if (!previous.isSystem() || (previous instanceof ThreadJob && ((ThreadJob) previous).shouldInterrupt()))
return true;
}
previous = previous.previous();
Expand Down Expand Up @@ -953,10 +953,8 @@ protected boolean join(InternalJob job, long timeout, IProgressMonitor monitor)
final Semaphore barrier;
synchronized (lock) {
int state = job.getState();
if (state == Job.NONE)
return true;
//don't join a waiting or sleeping job when suspended (deadlock risk)
if (suspended && state != Job.RUNNING)
if ((state == Job.NONE) || (suspended && state != Job.RUNNING))
return true;
//it's an error for a job to join itself
if (state == Job.RUNNING && job.getThread() == Thread.currentThread())
Expand Down Expand Up @@ -1055,10 +1053,8 @@ public void scheduled(IJobChangeEvent event) {
Job job = event.getJob();
if (family == null || job.belongsTo(family)) {
// don't add to list if job is being rescheduled
if (((JobChangeEvent) event).reschedule)
return;
// if job manager is suspended we only wait for running jobs
if (isSuspended())
if (((JobChangeEvent) event).reschedule || isSuspended())
return;
boolean added = jobs.add(job);
assert added;
Expand Down