Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public void setUp() throws Exception {
@Override
public void tearDown() throws Exception {
super.tearDown();
// TODO(cpovirk): run tests in other thread instead of messing with main thread interrupt status
/*
* TODO(cpovirk): Run tests in another thread instead of messing with main thread's interrupted
* status.
*/
Thread.interrupted();
LocalCache.logger.removeHandler(logHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ public void run() {
shouldCompleteFunction.await();
combinerCompletedWithoutInterrupt.countDown();
} catch (InterruptedException e) {
// Ensure the thread's interrupt status is preserved.
// Ensure the thread's interrupted status is preserved.
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -2655,7 +2655,7 @@ public void run() {
try {
new CountDownLatch(1).await(); // wait for interrupt
} catch (InterruptedException expected) {
// Ensure the thread's interrupt status is preserved.
// Ensure the thread's interrupted status is preserved.
Thread.currentThread().interrupt();
gotException.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void setUp() {
* <p>Triggers test case failure if any thread assertions have failed, by rethrowing, in the test
* harness thread, any exception recorded earlier by threadRecordFailure.
*
* <p>Triggers test case failure if interrupt status is set in the main thread.
* <p>Triggers test case failure if interrupted status is set in the main thread.
*/
@Override
public void tearDown() throws Exception {
Expand All @@ -316,7 +316,9 @@ public void tearDown() throws Exception {
}
}

if (Thread.interrupted()) throw new AssertionFailedError("interrupt status set in main thread");
if (Thread.interrupted()) {
throw new AssertionFailedError("interrupted status set in main thread");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ private static void assertTimeNotPassed(Stopwatch stopwatch, long timelimitMilli
}

/**
* Await an interrupt, then clear the interrupt status. Similar to {@code
* Awaits an interrupt, then clears the interrupted status. Similar to {@code
* assertTrue(Thread.interrupted())} except that this version tolerates late interrupts.
*/
private static void assertInterrupted() {
Expand Down
6 changes: 3 additions & 3 deletions android/guava/src/com/google/common/cache/CacheLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected CacheLoader() {}
* @throws Exception if unable to load the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
*/
public abstract V load(K key) throws Exception;

Expand All @@ -90,7 +90,7 @@ protected CacheLoader() {}
* @throws Exception if unable to reload the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
* @since 11.0
*/
@GwtIncompatible // Futures
Expand Down Expand Up @@ -119,7 +119,7 @@ public ListenableFuture<V> reload(K key, V oldValue) throws Exception {
* @throws Exception if unable to load the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
* @since 11.0
*/
public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private void waitForInterrupt(Thread currentThread) {
currentThread.interrupt();
}
/*
* TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an interrupt
* before, during, or after runInterruptibly() (unless it produced an InterruptedException
* caught above) can linger and affect listeners.
* TODO(cpovirk): Clear interrupted status here? We currently don't, which means that an
* interrupt before, during, or after runInterruptibly() (unless it produced an
* InterruptedException caught above) can linger and affect listeners.
*/
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public boolean enterWhen(Guard guard, long time, TimeUnit unit) throws Interrupt
locked:
{
if (!fair) {
// Check interrupt status to get behavior consistent with fair case.
// Check interrupted status to get behavior consistent with the fair case.
if (Thread.interrupted()) {
throw new InterruptedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ public static boolean shutdownAndAwaitTermination(
service.awaitTermination(halfTimeoutNanos, NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
// Preserve interrupted status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public void setUp() throws Exception {
@Override
public void tearDown() throws Exception {
super.tearDown();
// TODO(cpovirk): run tests in other thread instead of messing with main thread interrupt status
/*
* TODO(cpovirk): Run tests in another thread instead of messing with main thread's interrupted
* status.
*/
Thread.interrupted();
LocalCache.logger.removeHandler(logHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ public void run() {
shouldCompleteFunction.await();
combinerCompletedWithoutInterrupt.countDown();
} catch (InterruptedException e) {
// Ensure the thread's interrupt status is preserved.
// Ensure the thread's interrupted status is preserved.
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -2655,7 +2655,7 @@ public void run() {
try {
new CountDownLatch(1).await(); // wait for interrupt
} catch (InterruptedException expected) {
// Ensure the thread's interrupt status is preserved.
// Ensure the thread's interrupted status is preserved.
Thread.currentThread().interrupt();
gotException.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void setUp() {
* <p>Triggers test case failure if any thread assertions have failed, by rethrowing, in the test
* harness thread, any exception recorded earlier by threadRecordFailure.
*
* <p>Triggers test case failure if interrupt status is set in the main thread.
* <p>Triggers test case failure if interrupted status is set in the main thread.
*/
@Override
public void tearDown() throws Exception {
Expand All @@ -316,7 +316,9 @@ public void tearDown() throws Exception {
}
}

if (Thread.interrupted()) throw new AssertionFailedError("interrupt status set in main thread");
if (Thread.interrupted()) {
throw new AssertionFailedError("interrupted status set in main thread");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ private static void assertTimeNotPassed(Stopwatch stopwatch, long timelimitMilli
}

/**
* Await an interrupt, then clear the interrupt status. Similar to {@code
* Awaits an interrupt, then clears the interrupted status. Similar to {@code
* assertTrue(Thread.interrupted())} except that this version tolerates late interrupts.
*/
private static void assertInterrupted() {
Expand Down
6 changes: 3 additions & 3 deletions guava/src/com/google/common/cache/CacheLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected CacheLoader() {}
* @throws Exception if unable to load the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
*/
public abstract V load(K key) throws Exception;

Expand All @@ -90,7 +90,7 @@ protected CacheLoader() {}
* @throws Exception if unable to reload the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
* @since 11.0
*/
@GwtIncompatible // Futures
Expand Down Expand Up @@ -119,7 +119,7 @@ public ListenableFuture<V> reload(K key, V oldValue) throws Exception {
* @throws Exception if unable to load the result
* @throws InterruptedException if this method is interrupted. {@code InterruptedException} is
* treated like any other {@code Exception} in all respects except that, when it is caught,
* the thread's interrupt status is set
* the thread's interrupted status is set
* @since 11.0
*/
public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ private void waitForInterrupt(Thread currentThread) {
currentThread.interrupt();
}
/*
* TODO(cpovirk): Clear interrupt status here? We currently don't, which means that an interrupt
* before, during, or after runInterruptibly() (unless it produced an InterruptedException
* caught above) can linger and affect listeners.
* TODO(cpovirk): Clear interrupted status here? We currently don't, which means that an
* interrupt before, during, or after runInterruptibly() (unless it produced an
* InterruptedException caught above) can linger and affect listeners.
*/
}

Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/util/concurrent/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public boolean enterWhen(Guard guard, long time, TimeUnit unit) throws Interrupt
locked:
{
if (!fair) {
// Check interrupt status to get behavior consistent with fair case.
// Check interrupted status to get behavior consistent with the fair case.
if (Thread.interrupted()) {
throw new InterruptedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public static boolean shutdownAndAwaitTermination(
service.awaitTermination(halfTimeoutNanos, NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
// Preserve interrupted status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
Expand Down
Loading