From abb321139498bf48e4d7635dca97910cd229bbd7 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 18 Dec 2024 15:35:23 -0800 Subject: [PATCH] Re-enable animalsniffer, fixing violations In 61f19d707a I swapped the signatures to use the version catalog. But I failed to preserve the `@signature` extension and it all seemed to work... But in fact all the animalsniffer tasks were completing as SKIPPED as they lacked signatures. The build.gradle changes in this commit are to fix that while still using version catalog. But while it was broken violations crept in. Most violations weren't too important and we're not surprised went unnoticed. For example, Netty with TLS has long required the Java 8 API `setEndpointIdentificationAlgorithm()`, so using `Optional` in the same code path didn't harm anything in particular. I still swapped it to Guava's `Optional` to avoid overuse of `@IgnoreJRERequirement`. One important violation has not been fixed and instead I've disabled the android signature in api/build.gradle for the moment. The violation is in StatusException using the `fillInStackTrace` overload of Exception. This problem [had been noticed][PR11066], but we couldn't figure out what was going on. AnimalSniffer is now noticing this and agreeing with the internal linter. There is still a question of why our interop tests failed to notice this, but given they are no longer running on pre-API level 24, that may forever be a mystery. [PR11066]: https://github.com/grpc/grpc-java/pull/11066 --- alts/build.gradle | 6 ++++- api/build.gradle | 15 +++++++++-- api/src/main/java/io/grpc/TimeUtils.java | 2 ++ .../test/java/io/grpc/CallOptionsTest.java | 2 ++ .../io/grpc/SynchronizationContextTest.java | 5 +++- api/src/test/java/io/grpc/TimeUtilsTest.java | 4 ++- auth/build.gradle | 12 +++++++-- authz/build.gradle | 6 ++++- benchmarks/build.gradle | 6 ++++- census/build.gradle | 12 +++++++-- contextstorage/build.gradle | 12 +++++++-- core/build.gradle | 12 +++++++-- .../java/io/grpc/internal/SpiffeUtil.java | 9 +++---- .../internal/ConcurrentTimeProviderTest.java | 7 ++---- .../internal/InstantTimeProviderTest.java | 2 ++ .../grpc/internal/ManagedChannelImplTest.java | 7 ++++-- .../java/io/grpc/internal/SpiffeUtilTest.java | 25 +++++++++++-------- gae-interop-testing/gae-jdk8/build.gradle | 6 ++++- gcp-csm-observability/build.gradle | 6 ++++- gcp-observability/build.gradle | 6 ++++- gcp-observability/interop/build.gradle | 6 ++++- googleapis/build.gradle | 6 ++++- grpclb/build.gradle | 6 ++++- inprocess/build.gradle | 12 +++++++-- interop-testing/build.gradle | 12 +++++++-- .../testing/integration/XdsTestClient.java | 2 ++ .../testing/integration/XdsTestServer.java | 2 ++ istio-interop-testing/build.gradle | 6 ++++- netty/build.gradle | 12 +++++++-- netty/shaded/build.gradle | 12 +++++++-- .../netty/InternalProtocolNegotiators.java | 6 ++--- .../io/grpc/netty/NettyChannelBuilder.java | 4 +-- .../io/grpc/netty/ProtocolNegotiators.java | 6 +++-- .../netty/NettyAdaptiveCumulatorTest.java | 3 +-- .../io/grpc/netty/NettyClientStreamTest.java | 11 +++++--- .../grpc/netty/NettyClientTransportTest.java | 4 +-- .../io/grpc/netty/NettyServerStreamTest.java | 20 ++++++++------- .../grpc/netty/ProtocolNegotiatorsTest.java | 12 ++++----- okhttp/build.gradle | 12 +++++++-- opentelemetry/build.gradle | 7 ++++-- protobuf-lite/build.gradle | 12 +++++++-- protobuf/build.gradle | 12 +++++++-- rls/build.gradle | 6 ++++- s2a/build.gradle | 6 ++++- .../S2AProtocolNegotiatorFactory.java | 4 +-- services/build.gradle | 6 ++++- stub/build.gradle | 12 +++++++-- .../main/java/io/grpc/stub/AbstractStub.java | 2 ++ .../java/io/grpc/stub/AbstractStubTest.java | 2 ++ testing-proto/build.gradle | 6 ++++- testing/build.gradle | 12 +++++++-- util/build.gradle | 12 +++++++-- .../util/OutlierDetectionLoadBalancer.java | 6 ++++- .../util/AdvancedTlsX509TrustManagerTest.java | 2 ++ xds/build.gradle | 6 ++++- 55 files changed, 325 insertions(+), 104 deletions(-) diff --git a/alts/build.gradle b/alts/build.gradle index de93c90546f..3e472d9cea6 100644 --- a/alts/build.gradle +++ b/alts/build.gradle @@ -44,7 +44,11 @@ dependencies { classifier = "linux-x86_64" } } - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/api/build.gradle b/api/build.gradle index 1d21c7bdcb6..5f7130f5896 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -36,6 +36,7 @@ tasks.named("jar").configure { dependencies { compileOnly sourceSets.context.output api libraries.jsr305, + libraries.animalsniffer.annotations, libraries.errorprone.annotations implementation libraries.guava @@ -48,8 +49,18 @@ dependencies { testImplementation project(':grpc-testing') testImplementation libraries.guava.testlib - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + // Temporarily disabled until StatusException is fixed. + // Context: https://github.com/grpc/grpc-java/pull/11066 + //signature (libraries.signature.android) { + // artifact { + // extension = "signature" + // } + //} } tasks.named("javadoc").configure { diff --git a/api/src/main/java/io/grpc/TimeUtils.java b/api/src/main/java/io/grpc/TimeUtils.java index c3031f13d94..c3cdf843d79 100644 --- a/api/src/main/java/io/grpc/TimeUtils.java +++ b/api/src/main/java/io/grpc/TimeUtils.java @@ -17,10 +17,12 @@ package io.grpc; import java.time.Duration; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; final class TimeUtils { private TimeUtils() {} + @IgnoreJRERequirement static long convertToNanos(Duration duration) { try { return duration.toNanos(); diff --git a/api/src/test/java/io/grpc/CallOptionsTest.java b/api/src/test/java/io/grpc/CallOptionsTest.java index d74c74ccd66..051c1b2d851 100644 --- a/api/src/test/java/io/grpc/CallOptionsTest.java +++ b/api/src/test/java/io/grpc/CallOptionsTest.java @@ -34,6 +34,7 @@ import io.grpc.internal.SerializingExecutor; import java.time.Duration; import java.util.concurrent.Executor; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -152,6 +153,7 @@ public void withDeadlineAfter() { } @Test + @IgnoreJRERequirement public void withDeadlineAfterDuration() { Deadline actual = CallOptions.DEFAULT.withDeadlineAfter(Duration.ofMinutes(1L)).getDeadline(); Deadline expected = Deadline.after(1, MINUTES); diff --git a/api/src/test/java/io/grpc/SynchronizationContextTest.java b/api/src/test/java/io/grpc/SynchronizationContextTest.java index f0797df227e..d063c58a978 100644 --- a/api/src/test/java/io/grpc/SynchronizationContextTest.java +++ b/api/src/test/java/io/grpc/SynchronizationContextTest.java @@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -248,6 +249,7 @@ public void schedule() { } @Test + @IgnoreJRERequirement public void scheduleDuration() { MockScheduledExecutorService executorService = new MockScheduledExecutorService(); ScheduledHandle handle = @@ -265,6 +267,7 @@ public void scheduleDuration() { } @Test + @IgnoreJRERequirement public void scheduleWithFixedDelayDuration() { MockScheduledExecutorService executorService = new MockScheduledExecutorService(); ScheduledHandle handle = @@ -402,4 +405,4 @@ static class MockScheduledExecutorService extends ForwardingScheduledExecutorSer return future = super.scheduleWithFixedDelay(command, intialDelay, delay, unit); } } -} \ No newline at end of file +} diff --git a/api/src/test/java/io/grpc/TimeUtilsTest.java b/api/src/test/java/io/grpc/TimeUtilsTest.java index 4faaa9cbf6d..75c0437ce26 100644 --- a/api/src/test/java/io/grpc/TimeUtilsTest.java +++ b/api/src/test/java/io/grpc/TimeUtilsTest.java @@ -19,12 +19,14 @@ import static org.junit.Assert.assertEquals; import java.time.Duration; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** Unit tests for {@link TimeUtils}. */ @RunWith(JUnit4.class) +@IgnoreJRERequirement public class TimeUtilsTest { @Test @@ -56,4 +58,4 @@ public void testConvertTooLargeNegativeDuration() { assertEquals(Long.MIN_VALUE, TimeUtils.convertToNanos(duration)); } -} \ No newline at end of file +} diff --git a/auth/build.gradle b/auth/build.gradle index 78bb720601b..d56802c14ca 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -22,6 +22,14 @@ dependencies { project(':grpc-core'), project(":grpc-context"), // Override google-auth dependency with our newer version libraries.google.auth.oauth2Http - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } diff --git a/authz/build.gradle b/authz/build.gradle index 60c86ca0dba..b72088bfbaa 100644 --- a/authz/build.gradle +++ b/authz/build.gradle @@ -26,7 +26,11 @@ dependencies { shadow configurations.implementation.getDependencies().minus([xdsDependency]) shadow project(path: ':grpc-xds', configuration: 'shadow') - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } tasks.named("jar").configure { diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index d00c0d76ebe..bf043106050 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -43,7 +43,11 @@ dependencies { testImplementation libraries.junit, libraries.mockito.core - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } import net.ltgt.gradle.errorprone.CheckSeverity diff --git a/census/build.gradle b/census/build.gradle index c1dc53e4c05..0993488ff83 100644 --- a/census/build.gradle +++ b/census/build.gradle @@ -27,8 +27,16 @@ dependencies { project(':grpc-testing'), libraries.opencensus.impl - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { diff --git a/contextstorage/build.gradle b/contextstorage/build.gradle index 39ea003d462..b1e78ea0e17 100644 --- a/contextstorage/build.gradle +++ b/contextstorage/build.gradle @@ -16,8 +16,16 @@ dependencies { libraries.assertj.core testImplementation 'junit:junit:4.13.1'// opentelemetry.sdk.testing uses compileOnly for assertj - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("jar").configure { diff --git a/core/build.gradle b/core/build.gradle index f8a95c37286..2fac9ddba04 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -39,8 +39,16 @@ dependencies { jmh project(':grpc-testing') - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { diff --git a/core/src/main/java/io/grpc/internal/SpiffeUtil.java b/core/src/main/java/io/grpc/internal/SpiffeUtil.java index 57e201d19ba..44ef343b6dc 100644 --- a/core/src/main/java/io/grpc/internal/SpiffeUtil.java +++ b/core/src/main/java/io/grpc/internal/SpiffeUtil.java @@ -23,13 +23,12 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.io.Files; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; @@ -188,8 +187,8 @@ public static SpiffeBundle loadTrustBundleFromFile(String trustBundleFile) throw } private static Map readTrustDomainsFromFile(String filePath) throws IOException { - Path path = Paths.get(checkNotNull(filePath, "trustBundleFile")); - String json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8); + File file = new File(checkNotNull(filePath, "trustBundleFile")); + String json = new String(Files.toByteArray(file), StandardCharsets.UTF_8); Object jsonObject = JsonParser.parse(json); if (!(jsonObject instanceof Map)) { throw new IllegalArgumentException( diff --git a/core/src/test/java/io/grpc/internal/ConcurrentTimeProviderTest.java b/core/src/test/java/io/grpc/internal/ConcurrentTimeProviderTest.java index a02cb6a6e42..7983530456c 100644 --- a/core/src/test/java/io/grpc/internal/ConcurrentTimeProviderTest.java +++ b/core/src/test/java/io/grpc/internal/ConcurrentTimeProviderTest.java @@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat; -import java.time.Instant; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,10 +35,8 @@ public void testConcurrentCurrentTimeNanos() { // Get the current time from the ConcurrentTimeProvider long actualTimeNanos = concurrentTimeProvider.currentTimeNanos(); - // Get the current time from Instant for comparison - Instant instantNow = Instant.now(); - long expectedTimeNanos = TimeUnit.SECONDS.toNanos(instantNow.getEpochSecond()) - + instantNow.getNano(); + // Get the current time from System for comparison + long expectedTimeNanos = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()); // Validate the time returned is close to the expected value within a tolerance // (i,e 10 millisecond tolerance in nanoseconds). diff --git a/core/src/test/java/io/grpc/internal/InstantTimeProviderTest.java b/core/src/test/java/io/grpc/internal/InstantTimeProviderTest.java index 46d1891cbb9..ac9a02fa936 100644 --- a/core/src/test/java/io/grpc/internal/InstantTimeProviderTest.java +++ b/core/src/test/java/io/grpc/internal/InstantTimeProviderTest.java @@ -20,6 +20,7 @@ import java.time.Instant; import java.util.concurrent.TimeUnit; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -28,6 +29,7 @@ * Unit tests for {@link InstantTimeProvider}. */ @RunWith(JUnit4.class) +@IgnoreJRERequirement public class InstantTimeProviderTest { @Test public void testInstantCurrentTimeNanos() throws Exception { diff --git a/core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java b/core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java index 535086716bd..2fe82aea972 100644 --- a/core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java +++ b/core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java @@ -57,6 +57,7 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; @@ -1199,8 +1200,10 @@ public void addressResolutionError_noPriorNameResolution_usesDefaultServiceConfi // config simply gets ignored and not gets reassigned. resolver.resolved(); timer.forwardNanos(1234); - assertThat(getStats(channel).channelTrace.events.stream().filter( - event -> event.description.equals("Service config changed")).count()).isEqualTo(0); + assertThat(Iterables.filter( + getStats(channel).channelTrace.events, + event -> event.description.equals("Service config changed"))) + .isEmpty(); } @Test diff --git a/core/src/test/java/io/grpc/internal/SpiffeUtilTest.java b/core/src/test/java/io/grpc/internal/SpiffeUtilTest.java index 244539501a6..6ded3ecc381 100644 --- a/core/src/test/java/io/grpc/internal/SpiffeUtilTest.java +++ b/core/src/test/java/io/grpc/internal/SpiffeUtilTest.java @@ -22,15 +22,16 @@ import static org.junit.Assert.assertTrue; import com.google.common.base.Optional; +import com.google.common.io.ByteStreams; import io.grpc.internal.SpiffeUtil.SpiffeBundle; import io.grpc.internal.SpiffeUtil.SpiffeId; import io.grpc.testing.TlsTesting; import io.grpc.util.CertificateUtils; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; +import java.io.OutputStream; import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Collection; @@ -247,10 +248,12 @@ public void setUp() throws Exception { } private String copyFileToTmp(String fileName) throws Exception { - Path tempFilePath = tempFolder.newFile(fileName).toPath(); + File tempFilePath = tempFolder.newFile(fileName); try (InputStream resourceStream = SpiffeUtilTest.class.getClassLoader() - .getResourceAsStream(TEST_DIRECTORY_PREFIX + fileName)) { - Files.copy(resourceStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING); + .getResourceAsStream(TEST_DIRECTORY_PREFIX + fileName); + OutputStream fileStream = new FileOutputStream(tempFilePath)) { + ByteStreams.copy(resourceStream, fileStream); + fileStream.flush(); } return tempFilePath.toString(); } @@ -358,9 +361,11 @@ public void loadTrustBundleFromFileParameterValidityTest() { NullPointerException npe = assertThrows(NullPointerException.class, () -> SpiffeUtil .loadTrustBundleFromFile(null)); assertEquals("trustBundleFile", npe.getMessage()); - NoSuchFileException nsfe = assertThrows(NoSuchFileException.class, () -> SpiffeUtil + FileNotFoundException nsfe = assertThrows(FileNotFoundException.class, () -> SpiffeUtil .loadTrustBundleFromFile("i_do_not_exist")); - assertEquals("i_do_not_exist", nsfe.getMessage()); + assertTrue( + "Did not contain expected substring: " + nsfe.getMessage(), + nsfe.getMessage().contains("i_do_not_exist")); } } -} \ No newline at end of file +} diff --git a/gae-interop-testing/gae-jdk8/build.gradle b/gae-interop-testing/gae-jdk8/build.gradle index a09a8e793c0..3ed395198c2 100644 --- a/gae-interop-testing/gae-jdk8/build.gradle +++ b/gae-interop-testing/gae-jdk8/build.gradle @@ -53,7 +53,11 @@ dependencies { implementation libraries.junit implementation libraries.protobuf.java runtimeOnly libraries.netty.tcnative, libraries.netty.tcnative.classes - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } tasks.named("compileJava").configure { diff --git a/gcp-csm-observability/build.gradle b/gcp-csm-observability/build.gradle index e29a56b1052..bda54ca8146 100644 --- a/gcp-csm-observability/build.gradle +++ b/gcp-csm-observability/build.gradle @@ -28,5 +28,9 @@ dependencies { libraries.opentelemetry.sdk.testing, libraries.assertj.core // opentelemetry.sdk.testing uses compileOnly for this dep - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } diff --git a/gcp-observability/build.gradle b/gcp-observability/build.gradle index f869bd61a76..c6d6fa28ddc 100644 --- a/gcp-observability/build.gradle +++ b/gcp-observability/build.gradle @@ -74,7 +74,11 @@ dependencies { exclude group: 'junit', module: 'junit' } - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/gcp-observability/interop/build.gradle b/gcp-observability/interop/build.gradle index 4a78c056eac..7e17624995a 100644 --- a/gcp-observability/interop/build.gradle +++ b/gcp-observability/interop/build.gradle @@ -10,7 +10,11 @@ dependencies { implementation project(':grpc-interop-testing'), project(':grpc-gcp-observability') - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } application { diff --git a/googleapis/build.gradle b/googleapis/build.gradle index 435e552d47d..3a7a3a2766a 100644 --- a/googleapis/build.gradle +++ b/googleapis/build.gradle @@ -21,5 +21,9 @@ dependencies { libraries.guava.jre // JRE required by transitive protobuf-java-util testImplementation testFixtures(project(':grpc-core')) - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } diff --git a/grpclb/build.gradle b/grpclb/build.gradle index 93331053b09..3f67181372b 100644 --- a/grpclb/build.gradle +++ b/grpclb/build.gradle @@ -28,7 +28,11 @@ dependencies { project(':grpc-inprocess'), testFixtures(project(':grpc-core')) - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/inprocess/build.gradle b/inprocess/build.gradle index edc97883b50..075968ccb9a 100644 --- a/inprocess/build.gradle +++ b/inprocess/build.gradle @@ -22,8 +22,16 @@ dependencies { testFixtures(project(':grpc-core')) testImplementation libraries.guava.testlib - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index a85aec97adf..97e7c69533a 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -53,8 +53,16 @@ dependencies { libraries.mockito.core, libraries.okhttp - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java index 23bc12a6b65..89519041a79 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestClient.java @@ -78,6 +78,7 @@ import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** Client for xDS interop tests. */ public final class XdsTestClient { @@ -261,6 +262,7 @@ private static RpcType parseRpc(String rpc) { } } + @IgnoreJRERequirement // OpenTelemetry uses Java 8+ APIs private void run() { if (enableCsmObservability) { csmObservability = CsmObservability.newBuilder() diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java index 1bc4ff88981..88f1bf468b6 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/XdsTestServer.java @@ -57,6 +57,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** Interop test server that implements the xDS testing service. */ public final class XdsTestServer { @@ -193,6 +194,7 @@ void parseArgs(String[] args) { } @SuppressWarnings("AddressSelection") + @IgnoreJRERequirement // OpenTelemetry uses Java 8+ APIs void start() throws Exception { if (enableCsmObservability) { csmObservability = CsmObservability.newBuilder() diff --git a/istio-interop-testing/build.gradle b/istio-interop-testing/build.gradle index e2fe228f13b..4550f0ea202 100644 --- a/istio-interop-testing/build.gradle +++ b/istio-interop-testing/build.gradle @@ -28,7 +28,11 @@ dependencies { libraries.junit, libraries.truth - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } sourceSets { diff --git a/netty/build.gradle b/netty/build.gradle index 5533038c85b..3662f8ec399 100644 --- a/netty/build.gradle +++ b/netty/build.gradle @@ -65,8 +65,16 @@ dependencies { classifier = "linux-x86_64" } } - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } import net.ltgt.gradle.errorprone.CheckSeverity diff --git a/netty/shaded/build.gradle b/netty/shaded/build.gradle index 25682d60b75..f805a4f4a1f 100644 --- a/netty/shaded/build.gradle +++ b/netty/shaded/build.gradle @@ -65,8 +65,16 @@ dependencies { shadow project(':grpc-netty').configurations.runtimeClasspath.allDependencies.matching { it.group != 'io.netty' } - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("jar").configure { diff --git a/netty/src/main/java/io/grpc/netty/InternalProtocolNegotiators.java b/netty/src/main/java/io/grpc/netty/InternalProtocolNegotiators.java index 8aeb44d0fc2..3d1aa83d9ff 100644 --- a/netty/src/main/java/io/grpc/netty/InternalProtocolNegotiators.java +++ b/netty/src/main/java/io/grpc/netty/InternalProtocolNegotiators.java @@ -16,6 +16,7 @@ package io.grpc.netty; +import com.google.common.base.Optional; import io.grpc.ChannelLogger; import io.grpc.internal.ObjectPool; import io.grpc.netty.ProtocolNegotiators.ClientTlsHandler; @@ -24,7 +25,6 @@ import io.netty.channel.ChannelHandler; import io.netty.handler.ssl.SslContext; import io.netty.util.AsciiString; -import java.util.Optional; import java.util.concurrent.Executor; /** @@ -72,7 +72,7 @@ public void close() { * may happen immediately, even before the TLS Handshake is complete. */ public static InternalProtocolNegotiator.ProtocolNegotiator tls(SslContext sslContext) { - return tls(sslContext, null, Optional.empty()); + return tls(sslContext, null, Optional.absent()); } /** @@ -170,7 +170,7 @@ public static ChannelHandler clientTlsHandler( ChannelHandler next, SslContext sslContext, String authority, ChannelLogger negotiationLogger) { return new ClientTlsHandler(next, sslContext, authority, null, negotiationLogger, - Optional.empty()); + Optional.absent()); } public static class ProtocolNegotiationHandler diff --git a/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java b/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java index fe226ec2ba9..8b80f7b4e46 100644 --- a/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java +++ b/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java @@ -23,6 +23,7 @@ import static io.grpc.internal.GrpcUtil.KEEPALIVE_TIME_NANOS_DISABLED; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; import com.google.common.base.Ticker; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CheckReturnValue; @@ -63,7 +64,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -652,7 +652,7 @@ static ProtocolNegotiator createProtocolNegotiatorByType( case PLAINTEXT_UPGRADE: return ProtocolNegotiators.plaintextUpgrade(); case TLS: - return ProtocolNegotiators.tls(sslContext, executorPool, Optional.empty()); + return ProtocolNegotiators.tls(sslContext, executorPool, Optional.absent()); default: throw new IllegalArgumentException("Unsupported negotiationType: " + negotiationType); } diff --git a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java index 84370ac8153..3f4d59bb334 100644 --- a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java +++ b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkState; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.errorprone.annotations.ForOverride; import io.grpc.Attributes; @@ -72,7 +73,6 @@ import java.nio.channels.ClosedChannelException; import java.util.Arrays; import java.util.EnumSet; -import java.util.Optional; import java.util.Set; import java.util.concurrent.Executor; import java.util.logging.Level; @@ -82,6 +82,7 @@ import javax.net.ssl.SSLException; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSession; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** * Common {@link ProtocolNegotiator}s used by gRPC. @@ -601,6 +602,7 @@ static final class ClientTlsHandler extends ProtocolNegotiationHandler { } @Override + @IgnoreJRERequirement protected void handlerAdded0(ChannelHandlerContext ctx) { SSLEngine sslEngine = sslContext.newEngine(ctx.alloc(), host, port); SSLParameters sslParams = sslEngine.getSSLParameters(); @@ -708,7 +710,7 @@ public static ProtocolNegotiator tls(SslContext sslContext, * may happen immediately, even before the TLS Handshake is complete. */ public static ProtocolNegotiator tls(SslContext sslContext) { - return tls(sslContext, null, Optional.empty()); + return tls(sslContext, null, Optional.absent()); } public static ProtocolNegotiator.ClientFactory tlsClientFactory(SslContext sslContext) { diff --git a/netty/src/test/java/io/grpc/netty/NettyAdaptiveCumulatorTest.java b/netty/src/test/java/io/grpc/netty/NettyAdaptiveCumulatorTest.java index 1037dab4712..68dc6dc0c80 100644 --- a/netty/src/test/java/io/grpc/netty/NettyAdaptiveCumulatorTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyAdaptiveCumulatorTest.java @@ -40,7 +40,6 @@ import io.netty.buffer.UnpooledByteBufAllocator; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -55,7 +54,7 @@ public class NettyAdaptiveCumulatorTest { private static Collection cartesianProductParams(List... lists) { - return Lists.cartesianProduct(lists).stream().map(List::toArray).collect(Collectors.toList()); + return Lists.transform(Lists.cartesianProduct(lists), List::toArray); } @RunWith(JUnit4.class) diff --git a/netty/src/test/java/io/grpc/netty/NettyClientStreamTest.java b/netty/src/test/java/io/grpc/netty/NettyClientStreamTest.java index 2a5a0df279a..a44a196ac8c 100644 --- a/netty/src/test/java/io/grpc/netty/NettyClientStreamTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyClientStreamTest.java @@ -46,6 +46,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.Iterables; import com.google.common.io.BaseEncoding; import io.grpc.CallOptions; import io.grpc.InternalStatus; @@ -239,11 +240,13 @@ public void writeFrameFutureFailedShouldCancelRpc() { // Get the CancelClientStreamCommand written to the queue. Above we verified that there is // only one CancelClientStreamCommand enqueued, and is the third enqueued command (create, // frame write failure, cancel). - CancelClientStreamCommand cancelCommand = Mockito.mockingDetails(writeQueue).getInvocations() - // Get enqueue() innovations only - .stream().filter(invocation -> invocation.getMethod().getName().equals("enqueue")) + CancelClientStreamCommand cancelCommand = Iterables.get( + Iterables.filter( + Mockito.mockingDetails(writeQueue).getInvocations(), + // Get enqueue() innovations only + invocation -> invocation.getMethod().getName().equals("enqueue")), // Get the third invocation of enqueue() - .skip(2).findFirst().get() + 2) // Get the first argument (QueuedCommand command) .getArgument(0); diff --git a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java index b7a3ff13a59..8d0d656859f 100644 --- a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java @@ -39,6 +39,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.base.Ticker; import com.google.common.io.ByteStreams; @@ -105,7 +106,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -803,7 +803,7 @@ public void tlsNegotiationServerExecutorShouldSucceed() throws Exception { .keyManager(clientCert, clientKey) .build(); ProtocolNegotiator negotiator = ProtocolNegotiators.tls(clientContext, clientExecutorPool, - Optional.empty()); + Optional.absent()); // after starting the client, the Executor in the client pool should be used assertEquals(true, clientExecutorPool.isInUse()); final NettyClientTransport transport = newTransport(negotiator); diff --git a/netty/src/test/java/io/grpc/netty/NettyServerStreamTest.java b/netty/src/test/java/io/grpc/netty/NettyServerStreamTest.java index 452f68341b1..0723e359752 100644 --- a/netty/src/test/java/io/grpc/netty/NettyServerStreamTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyServerStreamTest.java @@ -38,7 +38,9 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; import io.grpc.Attributes; import io.grpc.Metadata; import io.grpc.Status; @@ -57,7 +59,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; -import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -217,14 +218,15 @@ private CancelServerStreamCommand findCancelServerStreamCommand() { // Ensure there's no CancelServerStreamCommand enqueued with flush=false. verify(writeQueue, never()).enqueue(any(CancelServerStreamCommand.class), eq(false)); - List commands = Mockito.mockingDetails(writeQueue).getInvocations() - .stream() - // Get enqueue() innovations only. - .filter(invocation -> invocation.getMethod().getName().equals("enqueue")) - // Find the cancel commands. - .filter(invocation -> invocation.getArgument(0) instanceof CancelServerStreamCommand) - .map(invocation -> invocation.getArgument(0, CancelServerStreamCommand.class)) - .collect(Collectors.toList()); + List commands = Lists.newArrayList( + Iterables.transform( + Iterables.filter( + Mockito.mockingDetails(writeQueue).getInvocations(), + // Get enqueue() innovations only + invocation -> invocation.getMethod().getName().equals("enqueue") + // Find the cancel commands. + && invocation.getArgument(0) instanceof CancelServerStreamCommand), + invocation -> invocation.getArgument(0, CancelServerStreamCommand.class))); assertWithMessage("Expected exactly one CancelClientStreamCommand").that(commands).hasSize(1); return commands.get(0); diff --git a/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java b/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java index 2ccdb2de543..6dff3de2b2a 100644 --- a/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java +++ b/netty/src/test/java/io/grpc/netty/ProtocolNegotiatorsTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import com.google.common.base.Optional; import io.grpc.Attributes; import io.grpc.CallCredentials; import io.grpc.ChannelCredentials; @@ -120,7 +121,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Optional; import java.util.Queue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -877,7 +877,7 @@ public String applicationProtocol() { DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, - "authority", elg, noopLogger, Optional.empty()); + "authority", elg, noopLogger, Optional.absent()); pipeline.addLast(handler); pipeline.replace(SslHandler.class, null, goodSslHandler); pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT); @@ -915,7 +915,7 @@ public String applicationProtocol() { .applicationProtocolConfig(apn).build(); ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, - "authority", elg, noopLogger, Optional.empty()); + "authority", elg, noopLogger, Optional.absent()); pipeline.addLast(handler); pipeline.replace(SslHandler.class, null, goodSslHandler); pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT); @@ -939,7 +939,7 @@ public String applicationProtocol() { DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, - "authority", elg, noopLogger, Optional.empty()); + "authority", elg, noopLogger, Optional.absent()); pipeline.addLast(handler); final AtomicReference error = new AtomicReference<>(); @@ -967,7 +967,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { @Test public void clientTlsHandler_closeDuringNegotiation() throws Exception { ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, - "authority", null, noopLogger, Optional.empty()); + "authority", null, noopLogger, Optional.absent()); pipeline.addLast(new WriteBufferingAndExceptionHandler(handler)); ChannelFuture pendingWrite = channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE); @@ -1230,7 +1230,7 @@ public void clientTlsHandler_firesNegotiation() throws Exception { } FakeGrpcHttp2ConnectionHandler gh = FakeGrpcHttp2ConnectionHandler.newHandler(); ClientTlsProtocolNegotiator pn = new ClientTlsProtocolNegotiator(clientSslContext, - null, Optional.empty()); + null, Optional.absent()); WriteBufferingAndExceptionHandler clientWbaeh = new WriteBufferingAndExceptionHandler(pn.newHandler(gh)); diff --git a/okhttp/build.gradle b/okhttp/build.gradle index 063e4775de1..6c542feec9c 100644 --- a/okhttp/build.gradle +++ b/okhttp/build.gradle @@ -31,8 +31,16 @@ dependencies { project(':grpc-testing-proto'), libraries.netty.codec.http2, libraries.okhttp - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } project.sourceSets { diff --git a/opentelemetry/build.gradle b/opentelemetry/build.gradle index 00d913c280d..b729f393e4b 100644 --- a/opentelemetry/build.gradle +++ b/opentelemetry/build.gradle @@ -23,8 +23,11 @@ dependencies { annotationProcessor libraries.auto.value - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } tasks.named("jar").configure { diff --git a/protobuf-lite/build.gradle b/protobuf-lite/build.gradle index 11a49d4816d..16b622535e8 100644 --- a/protobuf-lite/build.gradle +++ b/protobuf-lite/build.gradle @@ -17,8 +17,16 @@ dependencies { testImplementation project(':grpc-core') - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("jar").configure { diff --git a/protobuf/build.gradle b/protobuf/build.gradle index c88ae836e0f..c477e41dceb 100644 --- a/protobuf/build.gradle +++ b/protobuf/build.gradle @@ -31,8 +31,16 @@ dependencies { exclude group: 'com.google.protobuf', module: 'protobuf-javalite' } - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { diff --git a/rls/build.gradle b/rls/build.gradle index 0629dce64c1..1dbcd91ec3c 100644 --- a/rls/build.gradle +++ b/rls/build.gradle @@ -30,7 +30,11 @@ dependencies { project(':grpc-testing-proto'), testFixtures(project(':grpc-api')), testFixtures(project(':grpc-core')) - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } tasks.named("compileJava").configure { diff --git a/s2a/build.gradle b/s2a/build.gradle index 572c48a0c5b..6ac193938ca 100644 --- a/s2a/build.gradle +++ b/s2a/build.gradle @@ -62,7 +62,11 @@ dependencies { } } - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java b/s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java index 7ad9de991cf..0822399aad6 100644 --- a/s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java +++ b/s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AProtocolNegotiatorFactory.java @@ -253,7 +253,7 @@ public void onSuccess(SslContext sslContext) { InternalProtocolNegotiators.tls( sslContext, SharedResourcePool.forResource(GrpcUtil.SHARED_CHANNEL_EXECUTOR), - Optional.of(new Runnable() { + com.google.common.base.Optional.of(new Runnable() { @Override public void run() { s2aStub.close(); @@ -278,4 +278,4 @@ public void onFailure(Throwable t) { } private S2AProtocolNegotiatorFactory() {} -} \ No newline at end of file +} diff --git a/services/build.gradle b/services/build.gradle index 6daa7b0511d..758f2a5c899 100644 --- a/services/build.gradle +++ b/services/build.gradle @@ -39,7 +39,11 @@ dependencies { testFixtures(project(':grpc-core')), testFixtures(project(':grpc-api')) testCompileOnly libraries.javax.annotation - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/stub/build.gradle b/stub/build.gradle index 867936f3ea3..a9a7cec5a0e 100644 --- a/stub/build.gradle +++ b/stub/build.gradle @@ -22,8 +22,16 @@ dependencies { project(':grpc-inprocess'), project(':grpc-testing'), testFixtures(project(':grpc-api')) - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { diff --git a/stub/src/main/java/io/grpc/stub/AbstractStub.java b/stub/src/main/java/io/grpc/stub/AbstractStub.java index 06dd55ff466..7b4bbed34a8 100644 --- a/stub/src/main/java/io/grpc/stub/AbstractStub.java +++ b/stub/src/main/java/io/grpc/stub/AbstractStub.java @@ -33,6 +33,7 @@ import javax.annotation.CheckReturnValue; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; /** * Common base type for stub implementations. Stub configuration is immutable; changing the @@ -152,6 +153,7 @@ public final S withDeadlineAfter(long duration, TimeUnit unit) { } @ExperimentalApi("https://github.com/grpc/grpc-java/issues/11657") + @IgnoreJRERequirement public final S withDeadlineAfter(Duration duration) { return withDeadlineAfter(convert(duration), TimeUnit.NANOSECONDS); } diff --git a/stub/src/test/java/io/grpc/stub/AbstractStubTest.java b/stub/src/test/java/io/grpc/stub/AbstractStubTest.java index a167c735160..352a2fb7fe2 100644 --- a/stub/src/test/java/io/grpc/stub/AbstractStubTest.java +++ b/stub/src/test/java/io/grpc/stub/AbstractStubTest.java @@ -28,6 +28,7 @@ import io.grpc.stub.AbstractStub.StubFactory; import io.grpc.stub.AbstractStubTest.NoopStub; import java.time.Duration; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -54,6 +55,7 @@ public NoopStub newStub(Channel channel, CallOptions callOptions) { } @Test + @IgnoreJRERequirement public void testDuration() { NoopStub stub = NoopStub.newStub(new StubFactory() { @Override diff --git a/testing-proto/build.gradle b/testing-proto/build.gradle index e6afce468f0..a34392b26d2 100644 --- a/testing-proto/build.gradle +++ b/testing-proto/build.gradle @@ -20,7 +20,11 @@ dependencies { compileOnly libraries.javax.annotation testImplementation libraries.truth testRuntimeOnly libraries.javax.annotation - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } } configureProtoCompilation() diff --git a/testing/build.gradle b/testing/build.gradle index cc83b7ad620..b92e39279c6 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -24,8 +24,16 @@ dependencies { testImplementation project(':grpc-testing-proto'), testFixtures(project(':grpc-core')) - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } tasks.named("javadoc").configure { exclude 'io/grpc/internal/**' } diff --git a/util/build.gradle b/util/build.gradle index 932ca66883e..6fbd6925c00 100644 --- a/util/build.gradle +++ b/util/build.gradle @@ -35,8 +35,16 @@ dependencies { project(':grpc-testing') jmh project(':grpc-testing') - signature libraries.signature.java - signature libraries.signature.android + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } + signature (libraries.signature.android) { + artifact { + extension = "signature" + } + } } animalsniffer { diff --git a/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java b/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java index 1f0290e76d7..928592e5534 100644 --- a/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java +++ b/util/src/main/java/io/grpc/util/OutlierDetectionLoadBalancer.java @@ -685,7 +685,11 @@ void updateTrackerConfigs(OutlierDetectionLoadBalancerConfig config) { /** Adds a new tracker for every given address. */ void putNewTrackers(OutlierDetectionLoadBalancerConfig config, Set> endpoints) { - endpoints.forEach(e -> trackerMap.putIfAbsent(e, new EndpointTracker(config))); + for (Set endpoint : endpoints) { + if (!trackerMap.containsKey(endpoint)) { + trackerMap.put(endpoint, new EndpointTracker(config)); + } + } } /** Resets the call counters for all the trackers in the map. */ diff --git a/util/src/test/java/io/grpc/util/AdvancedTlsX509TrustManagerTest.java b/util/src/test/java/io/grpc/util/AdvancedTlsX509TrustManagerTest.java index 36ef75abeaa..91159d121ad 100644 --- a/util/src/test/java/io/grpc/util/AdvancedTlsX509TrustManagerTest.java +++ b/util/src/test/java/io/grpc/util/AdvancedTlsX509TrustManagerTest.java @@ -44,6 +44,7 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import javax.net.ssl.SSLSocket; +import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,6 +52,7 @@ /** Unit tests for {@link AdvancedTlsX509TrustManager}. */ @RunWith(JUnit4.class) +@IgnoreJRERequirement public class AdvancedTlsX509TrustManagerTest { private static final String CA_PEM_FILE = "ca.pem"; diff --git a/xds/build.gradle b/xds/build.gradle index e09b42d06a9..c51fc2819d7 100644 --- a/xds/build.gradle +++ b/xds/build.gradle @@ -81,7 +81,11 @@ dependencies { shadow configurations.implementation.getDependencies().minus([nettyDependency]) shadow project(path: ':grpc-netty-shaded', configuration: 'shadow') - signature libraries.signature.java + signature (libraries.signature.java) { + artifact { + extension = "signature" + } + } testRuntimeOnly libraries.netty.tcnative, libraries.netty.tcnative.classes testRuntimeOnly (libraries.netty.tcnative) {