Get class loader to remember interrupts
Bug: 25606036
Monitor::Wait should not reset the interrupt flag unless it actually
throws the exception.
Change-Id: Id6a35c888160043831f30055f9bd39e7f0440439
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index da21fee..19c71f6 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -485,10 +485,7 @@
DCHECK(why == kTimedWaiting || why == kSleeping) << why;
self->GetWaitConditionVariable()->TimedWait(self, ms, ns);
}
- if (self->IsInterruptedLocked()) {
- was_interrupted = true;
- }
- self->SetInterruptedLocked(false);
+ was_interrupted = self->IsInterruptedLocked();
}
}
@@ -522,7 +519,7 @@
monitor_lock_.Unlock(self);
- if (was_interrupted) {
+ if (was_interrupted && interruptShouldThrow) {
/*
* We were interrupted while waiting, or somebody interrupted an
* un-interruptible thread earlier and we're bailing out immediately.
@@ -534,9 +531,7 @@
MutexLock mu(self, *self->GetWaitMutex());
self->SetInterruptedLocked(false);
}
- if (interruptShouldThrow) {
- self->ThrowNewException("Ljava/lang/InterruptedException;", nullptr);
- }
+ self->ThrowNewException("Ljava/lang/InterruptedException;", nullptr);
}
}