Skip to content

Commit

Permalink
1.3.9b <=> startup edge case fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mynttt committed May 24, 2020
1 parent 7c1ec2f commit a506003
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.9
1.3.9b
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'com.github.spotbugs' version '2.0.1'
}

version = '1.3.9'
version = '1.3.9b'
sourceCompatibility = '11'

new File(projectDir, "VERSION").text = version;
Expand Down
31 changes: 4 additions & 27 deletions src/main/java/updatetool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ public void prepare(Implementation impl) {

public void go() {
Logger.info("Scheduler is loading tasks... Blocking until completely set-up and ready to go.");
var blocker = new Lock();
service.submit(blocker);
List<Runnable> tasks = new ArrayList<>();
Logger.info("Scheduling tasks...");
jobs.forEach((k, v) -> {
int run = interval.get(k);
Expand All @@ -255,34 +254,12 @@ public void go() {
});

runAtStartup.forEach(k -> {
service.submit(jobs.get(k));
tasks.add(jobs.get(k));
Logger.info("Queued task {} for immediate execution.", k);
});
Logger.info("Unblocking scheduler...");
blocker.unblock();

Logger.info("Running supplied tasks immediately NOW!");
}
}

class Lock implements Runnable {

@Override
@SuppressFBWarnings({"UW_UNCOND_WAIT", "WA_NOT_IN_LOOP"})
public void run() {
synchronized (this) {
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

@SuppressFBWarnings("NN_NAKED_NOTIFY")
public void unblock() {
synchronized (this) {
notify();
}
tasks.forEach(service::submit);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.9
1.3.9b

0 comments on commit a506003

Please sign in to comment.