Remove arbitrary 1.5 second sleep() when launching jobs

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.
This commit is contained in:
Alex Osborne
2021-06-22 13:40:09 +09:00
parent c9369da6b8
commit 643f16d20c
@@ -408,7 +408,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
* (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);
}
@@ -449,9 +449,8 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
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
}