Skip to content

Commit

Permalink
Remove arbitrary 1.5 second sleep() when launching jobs
Browse files Browse the repository at this point in the history
I think the sleep is supposed to make launch() not return until the job
has actually been launched but it doesn't work as launch()
and getCrawlController() are both synchronized therefore the
launcher thread can't actually call startContext() until launch()
returns after sleeping.

So let's replace the sleep call with join and unsynchronize launch()
so it doesn't deadlock. All the relevant methods it calls seem to be
synchronized so I think it's no worse to not synchronize it itself.
  • Loading branch information
ato committed Jun 22, 2021
1 parent c9369da commit 643f16d
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public synchronized boolean hasValidApplicationContext() {
* (Note the crawl may have been configured to start in a 'paused'
* state.)
*/
public synchronized void launch() {
public void launch() {
if (isProfile()) {
throw new IllegalArgumentException("Can't launch profile" + this);
}
Expand Down Expand Up @@ -449,9 +449,8 @@ public void run() {
getJobLogger().log(Level.INFO,"Job launched");
scanJobLog();
launcher.start();
// look busy (and give startContext/crawlStart a chance)
try {
Thread.sleep(1500);
launcher.join();
} catch (InterruptedException e) {
// do nothing
}
Expand Down

0 comments on commit 643f16d

Please sign in to comment.