hopefully make currentlyRunning more resilient

This commit is contained in:
Leijurv 2018-09-01 14:47:46 -07:00
parent e705f9808b
commit 2e22f1cf54
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -81,9 +81,19 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!"); throw new IllegalStateException("Path Finder is currently in use, and cannot be reused!");
} }
this.cancelRequested = false; this.cancelRequested = false;
Optional<IPath> path = calculate0(); try {
isFinished = true; Optional<IPath> path = calculate0();
return path; isFinished = true;
return path;
} catch (Exception e) {
currentlyRunning = null;
isFinished = true;
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
} }
protected abstract Optional<IPath> calculate0(); protected abstract Optional<IPath> calculate0();