Prevent NPE when we get interrupted before getting a latchWithWorker.
@@ -272,6 +272,7 @@ public class ResourceManager implements ResourceEstimator {
} catch (InterruptedException e) {
// Synchronize on this to avoid any racing with #processWaitingThreads
synchronized (this) {
+ if (latchWithWorker != null) {
if (latchWithWorker.latch == null || latchWithWorker.latch.getCount() == 0) {
// Resources already acquired by other side. Release them, but not inside this
// synchronized block to avoid deadlock.
@@ -281,6 +282,7 @@ public class ResourceManager implements ResourceEstimator {
latchWithWorker.latch.countDown();
}
}
+ }
throw e;
}
