Skip to content

Commit

Permalink
Don't return null in JobManager::createMonitor
Browse files Browse the repository at this point in the history
Revert unintentional change made in
9c3525c and don't return null when
creating a progress monitor. This is part of the contract of the method.

Contributes to
eclipse-platform#664
  • Loading branch information
fedejeanne committed Apr 4, 2024
1 parent 9150f9d commit 5919685
Showing 1 changed file with 9 additions and 13 deletions.
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

0 comments on commit 5919685

Please sign in to comment.