Skip to content

Commit

Permalink
Under JDK20+, skip test that uses Thread.suspend.
Browse files Browse the repository at this point in the history
It [throws `UnsupportedOperationException`](https://bugs.openjdk.org/browse/JDK-8249627) under those versions.

(more work toward #6245)

PiperOrigin-RevId: 493001256
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 5, 2022
1 parent 0b179dc commit b2e3b0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package com.google.common.util.concurrent;

import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.internal.InternalFutureFailureAccess;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -293,6 +295,13 @@ public String pendingToString() {
@SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck"})
@AndroidIncompatible // Thread.suspend
public void testToString_delayedTimeout() throws Exception {
Integer javaVersion = Ints.tryParse(JAVA_SPECIFICATION_VERSION.value());
// Parsing to an integer might fail because Java 8 returns "1.8" instead of "8."
// We can continue if it's 1.8, and we can continue if it's an integer in [9, 20).
if (javaVersion != null && javaVersion >= 20) {
// TODO(b/261217224): Make this test work under newer JDKs.
return;
}
TimedWaiterThread thread =
new TimedWaiterThread(new AbstractFuture<Object>() {}, 2, TimeUnit.SECONDS);
thread.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package com.google.common.util.concurrent;

import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.internal.InternalFutureFailureAccess;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -293,6 +295,13 @@ public String pendingToString() {
@SuppressWarnings({"DeprecatedThreadMethods", "ThreadPriorityCheck"})
@AndroidIncompatible // Thread.suspend
public void testToString_delayedTimeout() throws Exception {
Integer javaVersion = Ints.tryParse(JAVA_SPECIFICATION_VERSION.value());
// Parsing to an integer might fail because Java 8 returns "1.8" instead of "8."
// We can continue if it's 1.8, and we can continue if it's an integer in [9, 20).
if (javaVersion != null && javaVersion >= 20) {
// TODO(b/261217224): Make this test work under newer JDKs.
return;
}
TimedWaiterThread thread =
new TimedWaiterThread(new AbstractFuture<Object>() {}, 2, TimeUnit.SECONDS);
thread.start();
Expand Down

0 comments on commit b2e3b0c

Please sign in to comment.