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
This commit is contained in:
Eric Anderson 2024-12-19 07:54:54 -08:00 committed by GitHub
parent f8f613984f
commit 8ea3629378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 329 additions and 105 deletions

View File

@ -44,7 +44,11 @@ dependencies {
classifier = "linux-x86_64" classifier = "linux-x86_64"
} }
} }
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -13,5 +13,6 @@ java_library(
artifact("com.google.errorprone:error_prone_annotations"), artifact("com.google.errorprone:error_prone_annotations"),
artifact("com.google.guava:failureaccess"), # future transitive dep of Guava. See #5214 artifact("com.google.guava:failureaccess"), # future transitive dep of Guava. See #5214
artifact("com.google.guava:guava"), artifact("com.google.guava:guava"),
artifact("org.codehaus.mojo:animal-sniffer-annotations"),
], ],
) )

View File

@ -36,6 +36,7 @@ tasks.named("jar").configure {
dependencies { dependencies {
compileOnly sourceSets.context.output compileOnly sourceSets.context.output
api libraries.jsr305, api libraries.jsr305,
libraries.animalsniffer.annotations,
libraries.errorprone.annotations libraries.errorprone.annotations
implementation libraries.guava implementation libraries.guava
@ -48,8 +49,18 @@ dependencies {
testImplementation project(':grpc-testing') testImplementation project(':grpc-testing')
testImplementation libraries.guava.testlib testImplementation libraries.guava.testlib
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
// TODO: 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 { tasks.named("javadoc").configure {

View File

@ -17,10 +17,12 @@
package io.grpc; package io.grpc;
import java.time.Duration; import java.time.Duration;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
final class TimeUtils { final class TimeUtils {
private TimeUtils() {} private TimeUtils() {}
@IgnoreJRERequirement
static long convertToNanos(Duration duration) { static long convertToNanos(Duration duration) {
try { try {
return duration.toNanos(); return duration.toNanos();

View File

@ -34,6 +34,7 @@ import io.grpc.ClientStreamTracer.StreamInfo;
import io.grpc.internal.SerializingExecutor; import io.grpc.internal.SerializingExecutor;
import java.time.Duration; import java.time.Duration;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@ -152,6 +153,7 @@ public class CallOptionsTest {
} }
@Test @Test
@IgnoreJRERequirement
public void withDeadlineAfterDuration() { public void withDeadlineAfterDuration() {
Deadline actual = CallOptions.DEFAULT.withDeadlineAfter(Duration.ofMinutes(1L)).getDeadline(); Deadline actual = CallOptions.DEFAULT.withDeadlineAfter(Duration.ofMinutes(1L)).getDeadline();
Deadline expected = Deadline.after(1, MINUTES); Deadline expected = Deadline.after(1, MINUTES);

View File

@ -36,6 +36,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.After; import org.junit.After;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -248,6 +249,7 @@ public class SynchronizationContextTest {
} }
@Test @Test
@IgnoreJRERequirement
public void scheduleDuration() { public void scheduleDuration() {
MockScheduledExecutorService executorService = new MockScheduledExecutorService(); MockScheduledExecutorService executorService = new MockScheduledExecutorService();
ScheduledHandle handle = ScheduledHandle handle =
@ -265,6 +267,7 @@ public class SynchronizationContextTest {
} }
@Test @Test
@IgnoreJRERequirement
public void scheduleWithFixedDelayDuration() { public void scheduleWithFixedDelayDuration() {
MockScheduledExecutorService executorService = new MockScheduledExecutorService(); MockScheduledExecutorService executorService = new MockScheduledExecutorService();
ScheduledHandle handle = ScheduledHandle handle =
@ -402,4 +405,4 @@ public class SynchronizationContextTest {
return future = super.scheduleWithFixedDelay(command, intialDelay, delay, unit); return future = super.scheduleWithFixedDelay(command, intialDelay, delay, unit);
} }
} }
} }

View File

@ -19,12 +19,14 @@ package io.grpc;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.time.Duration; import java.time.Duration;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
/** Unit tests for {@link TimeUtils}. */ /** Unit tests for {@link TimeUtils}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
@IgnoreJRERequirement
public class TimeUtilsTest { public class TimeUtilsTest {
@Test @Test
@ -56,4 +58,4 @@ public class TimeUtilsTest {
assertEquals(Long.MIN_VALUE, TimeUtils.convertToNanos(duration)); assertEquals(Long.MIN_VALUE, TimeUtils.convertToNanos(duration));
} }
} }

View File

@ -22,6 +22,14 @@ dependencies {
project(':grpc-core'), project(':grpc-core'),
project(":grpc-context"), // Override google-auth dependency with our newer version project(":grpc-context"), // Override google-auth dependency with our newer version
libraries.google.auth.oauth2Http libraries.google.auth.oauth2Http
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }

View File

@ -26,7 +26,11 @@ dependencies {
shadow configurations.implementation.getDependencies().minus([xdsDependency]) shadow configurations.implementation.getDependencies().minus([xdsDependency])
shadow project(path: ':grpc-xds', configuration: 'shadow') shadow project(path: ':grpc-xds', configuration: 'shadow')
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
tasks.named("jar").configure { tasks.named("jar").configure {

View File

@ -43,7 +43,11 @@ dependencies {
testImplementation libraries.junit, testImplementation libraries.junit,
libraries.mockito.core libraries.mockito.core
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
import net.ltgt.gradle.errorprone.CheckSeverity import net.ltgt.gradle.errorprone.CheckSeverity

View File

@ -27,8 +27,16 @@ dependencies {
project(':grpc-testing'), project(':grpc-testing'),
libraries.opencensus.impl libraries.opencensus.impl
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { tasks.named("javadoc").configure {

View File

@ -16,8 +16,16 @@ dependencies {
libraries.assertj.core libraries.assertj.core
testImplementation 'junit:junit:4.13.1'// opentelemetry.sdk.testing uses compileOnly for assertj testImplementation 'junit:junit:4.13.1'// opentelemetry.sdk.testing uses compileOnly for assertj
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("jar").configure { tasks.named("jar").configure {

View File

@ -39,8 +39,16 @@ dependencies {
jmh project(':grpc-testing') jmh project(':grpc-testing')
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { tasks.named("javadoc").configure {

View File

@ -23,13 +23,12 @@ import com.google.common.base.Optional;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; 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.Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
@ -188,8 +187,8 @@ public final class SpiffeUtil {
} }
private static Map<String, ?> readTrustDomainsFromFile(String filePath) throws IOException { private static Map<String, ?> readTrustDomainsFromFile(String filePath) throws IOException {
Path path = Paths.get(checkNotNull(filePath, "trustBundleFile")); File file = new File(checkNotNull(filePath, "trustBundleFile"));
String json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8); String json = new String(Files.toByteArray(file), StandardCharsets.UTF_8);
Object jsonObject = JsonParser.parse(json); Object jsonObject = JsonParser.parse(json);
if (!(jsonObject instanceof Map)) { if (!(jsonObject instanceof Map)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(

View File

@ -18,7 +18,6 @@ package io.grpc.internal;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import java.time.Instant;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -36,10 +35,8 @@ public class ConcurrentTimeProviderTest {
// Get the current time from the ConcurrentTimeProvider // Get the current time from the ConcurrentTimeProvider
long actualTimeNanos = concurrentTimeProvider.currentTimeNanos(); long actualTimeNanos = concurrentTimeProvider.currentTimeNanos();
// Get the current time from Instant for comparison // Get the current time from System for comparison
Instant instantNow = Instant.now(); long expectedTimeNanos = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
long expectedTimeNanos = TimeUnit.SECONDS.toNanos(instantNow.getEpochSecond())
+ instantNow.getNano();
// Validate the time returned is close to the expected value within a tolerance // Validate the time returned is close to the expected value within a tolerance
// (i,e 10 millisecond tolerance in nanoseconds). // (i,e 10 millisecond tolerance in nanoseconds).

View File

@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import java.time.Instant; import java.time.Instant;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@ -28,6 +29,7 @@ import org.junit.runners.JUnit4;
* Unit tests for {@link InstantTimeProvider}. * Unit tests for {@link InstantTimeProvider}.
*/ */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
@IgnoreJRERequirement
public class InstantTimeProviderTest { public class InstantTimeProviderTest {
@Test @Test
public void testInstantCurrentTimeNanos() throws Exception { public void testInstantCurrentTimeNanos() throws Exception {

View File

@ -57,6 +57,7 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; 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.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
@ -1199,8 +1200,10 @@ public class ManagedChannelImplTest {
// config simply gets ignored and not gets reassigned. // config simply gets ignored and not gets reassigned.
resolver.resolved(); resolver.resolved();
timer.forwardNanos(1234); timer.forwardNanos(1234);
assertThat(getStats(channel).channelTrace.events.stream().filter( assertThat(Iterables.filter(
event -> event.description.equals("Service config changed")).count()).isEqualTo(0); getStats(channel).channelTrace.events,
event -> event.description.equals("Service config changed")))
.isEmpty();
} }
@Test @Test

View File

@ -22,15 +22,16 @@ import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.io.ByteStreams;
import io.grpc.internal.SpiffeUtil.SpiffeBundle; import io.grpc.internal.SpiffeUtil.SpiffeBundle;
import io.grpc.internal.SpiffeUtil.SpiffeId; import io.grpc.internal.SpiffeUtil.SpiffeId;
import io.grpc.testing.TlsTesting; import io.grpc.testing.TlsTesting;
import io.grpc.util.CertificateUtils; import io.grpc.util.CertificateUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.io.OutputStream;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -247,12 +248,14 @@ public class SpiffeUtilTest {
} }
private String copyFileToTmp(String fileName) throws Exception { private String copyFileToTmp(String fileName) throws Exception {
Path tempFilePath = tempFolder.newFile(fileName).toPath(); File tempFile = tempFolder.newFile(fileName);
try (InputStream resourceStream = SpiffeUtilTest.class.getClassLoader() try (InputStream resourceStream = SpiffeUtilTest.class.getClassLoader()
.getResourceAsStream(TEST_DIRECTORY_PREFIX + fileName)) { .getResourceAsStream(TEST_DIRECTORY_PREFIX + fileName);
Files.copy(resourceStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING); OutputStream fileStream = new FileOutputStream(tempFile)) {
ByteStreams.copy(resourceStream, fileStream);
fileStream.flush();
} }
return tempFilePath.toString(); return tempFile.toString();
} }
@Test @Test
@ -358,9 +361,11 @@ public class SpiffeUtilTest {
NullPointerException npe = assertThrows(NullPointerException.class, () -> SpiffeUtil NullPointerException npe = assertThrows(NullPointerException.class, () -> SpiffeUtil
.loadTrustBundleFromFile(null)); .loadTrustBundleFromFile(null));
assertEquals("trustBundleFile", npe.getMessage()); assertEquals("trustBundleFile", npe.getMessage());
NoSuchFileException nsfe = assertThrows(NoSuchFileException.class, () -> SpiffeUtil FileNotFoundException nsfe = assertThrows(FileNotFoundException.class, () -> SpiffeUtil
.loadTrustBundleFromFile("i_do_not_exist")); .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"));
} }
} }
} }

View File

@ -53,7 +53,11 @@ dependencies {
implementation libraries.junit implementation libraries.junit
implementation libraries.protobuf.java implementation libraries.protobuf.java
runtimeOnly libraries.netty.tcnative, libraries.netty.tcnative.classes runtimeOnly libraries.netty.tcnative, libraries.netty.tcnative.classes
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
tasks.named("compileJava").configure { tasks.named("compileJava").configure {

View File

@ -28,5 +28,9 @@ dependencies {
libraries.opentelemetry.sdk.testing, libraries.opentelemetry.sdk.testing,
libraries.assertj.core // opentelemetry.sdk.testing uses compileOnly for this dep libraries.assertj.core // opentelemetry.sdk.testing uses compileOnly for this dep
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }

View File

@ -74,7 +74,11 @@ dependencies {
exclude group: 'junit', module: 'junit' exclude group: 'junit', module: 'junit'
} }
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -10,7 +10,11 @@ dependencies {
implementation project(':grpc-interop-testing'), implementation project(':grpc-interop-testing'),
project(':grpc-gcp-observability') project(':grpc-gcp-observability')
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
application { application {

View File

@ -21,5 +21,9 @@ dependencies {
libraries.guava.jre // JRE required by transitive protobuf-java-util libraries.guava.jre // JRE required by transitive protobuf-java-util
testImplementation testFixtures(project(':grpc-core')) testImplementation testFixtures(project(':grpc-core'))
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }

View File

@ -28,7 +28,11 @@ dependencies {
project(':grpc-inprocess'), project(':grpc-inprocess'),
testFixtures(project(':grpc-core')) testFixtures(project(':grpc-core'))
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -22,8 +22,16 @@ dependencies {
testFixtures(project(':grpc-core')) testFixtures(project(':grpc-core'))
testImplementation libraries.guava.testlib testImplementation libraries.guava.testlib
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { tasks.named("javadoc").configure {

View File

@ -53,8 +53,16 @@ dependencies {
libraries.mockito.core, libraries.mockito.core,
libraries.okhttp libraries.okhttp
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -78,6 +78,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe; import javax.annotation.concurrent.ThreadSafe;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/** Client for xDS interop tests. */ /** Client for xDS interop tests. */
public final class XdsTestClient { public final class XdsTestClient {
@ -261,6 +262,7 @@ public final class XdsTestClient {
} }
} }
@IgnoreJRERequirement // OpenTelemetry uses Java 8+ APIs
private void run() { private void run() {
if (enableCsmObservability) { if (enableCsmObservability) {
csmObservability = CsmObservability.newBuilder() csmObservability = CsmObservability.newBuilder()

View File

@ -57,6 +57,7 @@ import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/** Interop test server that implements the xDS testing service. */ /** Interop test server that implements the xDS testing service. */
public final class XdsTestServer { public final class XdsTestServer {
@ -193,6 +194,7 @@ public final class XdsTestServer {
} }
@SuppressWarnings("AddressSelection") @SuppressWarnings("AddressSelection")
@IgnoreJRERequirement // OpenTelemetry uses Java 8+ APIs
void start() throws Exception { void start() throws Exception {
if (enableCsmObservability) { if (enableCsmObservability) {
csmObservability = CsmObservability.newBuilder() csmObservability = CsmObservability.newBuilder()

View File

@ -28,7 +28,11 @@ dependencies {
libraries.junit, libraries.junit,
libraries.truth libraries.truth
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
sourceSets { sourceSets {

View File

@ -27,6 +27,7 @@ java_library(
artifact("io.netty:netty-transport"), artifact("io.netty:netty-transport"),
artifact("io.netty:netty-transport-native-unix-common"), artifact("io.netty:netty-transport-native-unix-common"),
artifact("io.perfmark:perfmark-api"), artifact("io.perfmark:perfmark-api"),
artifact("org.codehaus.mojo:animal-sniffer-annotations"),
], ],
) )

View File

@ -65,8 +65,16 @@ dependencies {
classifier = "linux-x86_64" classifier = "linux-x86_64"
} }
} }
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
import net.ltgt.gradle.errorprone.CheckSeverity import net.ltgt.gradle.errorprone.CheckSeverity

View File

@ -65,8 +65,16 @@ dependencies {
shadow project(':grpc-netty').configurations.runtimeClasspath.allDependencies.matching { shadow project(':grpc-netty').configurations.runtimeClasspath.allDependencies.matching {
it.group != 'io.netty' it.group != 'io.netty'
} }
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("jar").configure { tasks.named("jar").configure {

View File

@ -16,6 +16,7 @@
package io.grpc.netty; package io.grpc.netty;
import com.google.common.base.Optional;
import io.grpc.ChannelLogger; import io.grpc.ChannelLogger;
import io.grpc.internal.ObjectPool; import io.grpc.internal.ObjectPool;
import io.grpc.netty.ProtocolNegotiators.ClientTlsHandler; import io.grpc.netty.ProtocolNegotiators.ClientTlsHandler;
@ -24,7 +25,6 @@ import io.grpc.netty.ProtocolNegotiators.WaitUntilActiveHandler;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContext;
import io.netty.util.AsciiString; import io.netty.util.AsciiString;
import java.util.Optional;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
/** /**
@ -72,7 +72,7 @@ public final class InternalProtocolNegotiators {
* may happen immediately, even before the TLS Handshake is complete. * may happen immediately, even before the TLS Handshake is complete.
*/ */
public static InternalProtocolNegotiator.ProtocolNegotiator tls(SslContext sslContext) { public static InternalProtocolNegotiator.ProtocolNegotiator tls(SslContext sslContext) {
return tls(sslContext, null, Optional.empty()); return tls(sslContext, null, Optional.absent());
} }
/** /**
@ -170,7 +170,7 @@ public final class InternalProtocolNegotiators {
ChannelHandler next, SslContext sslContext, String authority, ChannelHandler next, SslContext sslContext, String authority,
ChannelLogger negotiationLogger) { ChannelLogger negotiationLogger) {
return new ClientTlsHandler(next, sslContext, authority, null, negotiationLogger, return new ClientTlsHandler(next, sslContext, authority, null, negotiationLogger,
Optional.empty()); Optional.absent());
} }
public static class ProtocolNegotiationHandler public static class ProtocolNegotiationHandler

View File

@ -23,6 +23,7 @@ import static io.grpc.internal.GrpcUtil.DEFAULT_KEEPALIVE_TIMEOUT_NANOS;
import static io.grpc.internal.GrpcUtil.KEEPALIVE_TIME_NANOS_DISABLED; import static io.grpc.internal.GrpcUtil.KEEPALIVE_TIME_NANOS_DISABLED;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Ticker; import com.google.common.base.Ticker;
import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CheckReturnValue; import com.google.errorprone.annotations.CheckReturnValue;
@ -63,7 +64,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -652,7 +652,7 @@ public final class NettyChannelBuilder extends ForwardingChannelBuilder2<NettyCh
case PLAINTEXT_UPGRADE: case PLAINTEXT_UPGRADE:
return ProtocolNegotiators.plaintextUpgrade(); return ProtocolNegotiators.plaintextUpgrade();
case TLS: case TLS:
return ProtocolNegotiators.tls(sslContext, executorPool, Optional.empty()); return ProtocolNegotiators.tls(sslContext, executorPool, Optional.absent());
default: default:
throw new IllegalArgumentException("Unsupported negotiationType: " + negotiationType); throw new IllegalArgumentException("Unsupported negotiationType: " + negotiationType);
} }

View File

@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.ForOverride; import com.google.errorprone.annotations.ForOverride;
import io.grpc.Attributes; import io.grpc.Attributes;
@ -72,7 +73,6 @@ import java.net.URI;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.logging.Level; import java.util.logging.Level;
@ -82,6 +82,7 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/** /**
* Common {@link ProtocolNegotiator}s used by gRPC. * Common {@link ProtocolNegotiator}s used by gRPC.
@ -601,6 +602,7 @@ final class ProtocolNegotiators {
} }
@Override @Override
@IgnoreJRERequirement
protected void handlerAdded0(ChannelHandlerContext ctx) { protected void handlerAdded0(ChannelHandlerContext ctx) {
SSLEngine sslEngine = sslContext.newEngine(ctx.alloc(), host, port); SSLEngine sslEngine = sslContext.newEngine(ctx.alloc(), host, port);
SSLParameters sslParams = sslEngine.getSSLParameters(); SSLParameters sslParams = sslEngine.getSSLParameters();
@ -708,7 +710,7 @@ final class ProtocolNegotiators {
* may happen immediately, even before the TLS Handshake is complete. * may happen immediately, even before the TLS Handshake is complete.
*/ */
public static ProtocolNegotiator tls(SslContext sslContext) { 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) { public static ProtocolNegotiator.ClientFactory tlsClientFactory(SslContext sslContext) {

View File

@ -40,7 +40,6 @@ import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -55,7 +54,7 @@ import org.junit.runners.Parameterized.Parameters;
public class NettyAdaptiveCumulatorTest { public class NettyAdaptiveCumulatorTest {
private static Collection<Object[]> cartesianProductParams(List<?>... lists) { private static Collection<Object[]> 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) @RunWith(JUnit4.class)

View File

@ -46,6 +46,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalStatus; import io.grpc.InternalStatus;
@ -239,11 +240,13 @@ public class NettyClientStreamTest extends NettyStreamTestBase<NettyClientStream
// Get the CancelClientStreamCommand written to the queue. Above we verified that there is // Get the CancelClientStreamCommand written to the queue. Above we verified that there is
// only one CancelClientStreamCommand enqueued, and is the third enqueued command (create, // only one CancelClientStreamCommand enqueued, and is the third enqueued command (create,
// frame write failure, cancel). // frame write failure, cancel).
CancelClientStreamCommand cancelCommand = Mockito.mockingDetails(writeQueue).getInvocations() CancelClientStreamCommand cancelCommand = Iterables.get(
// Get enqueue() innovations only Iterables.filter(
.stream().filter(invocation -> invocation.getMethod().getName().equals("enqueue")) Mockito.mockingDetails(writeQueue).getInvocations(),
// Get enqueue() innovations only
invocation -> invocation.getMethod().getName().equals("enqueue")),
// Get the third invocation of enqueue() // Get the third invocation of enqueue()
.skip(2).findFirst().get() 2)
// Get the first argument (QueuedCommand command) // Get the first argument (QueuedCommand command)
.getArgument(0); .getArgument(0);

View File

@ -39,6 +39,7 @@ import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.base.Ticker; import com.google.common.base.Ticker;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
@ -105,7 +106,6 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -803,7 +803,7 @@ public class NettyClientTransportTest {
.keyManager(clientCert, clientKey) .keyManager(clientCert, clientKey)
.build(); .build();
ProtocolNegotiator negotiator = ProtocolNegotiators.tls(clientContext, clientExecutorPool, ProtocolNegotiator negotiator = ProtocolNegotiators.tls(clientContext, clientExecutorPool,
Optional.empty()); Optional.absent());
// after starting the client, the Executor in the client pool should be used // after starting the client, the Executor in the client pool should be used
assertEquals(true, clientExecutorPool.isInUse()); assertEquals(true, clientExecutorPool.isInUse());
final NettyClientTransport transport = newTransport(negotiator); final NettyClientTransport transport = newTransport(negotiator);

View File

@ -38,7 +38,9 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.Status; import io.grpc.Status;
@ -57,7 +59,6 @@ import java.io.InputStream;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
import java.util.stream.Collectors;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -217,14 +218,15 @@ public class NettyServerStreamTest extends NettyStreamTestBase<NettyServerStream
// Ensure there's no CancelServerStreamCommand enqueued with flush=false. // Ensure there's no CancelServerStreamCommand enqueued with flush=false.
verify(writeQueue, never()).enqueue(any(CancelServerStreamCommand.class), eq(false)); verify(writeQueue, never()).enqueue(any(CancelServerStreamCommand.class), eq(false));
List<CancelServerStreamCommand> commands = Mockito.mockingDetails(writeQueue).getInvocations() List<CancelServerStreamCommand> commands = Lists.newArrayList(
.stream() Iterables.transform(
// Get enqueue() innovations only. Iterables.filter(
.filter(invocation -> invocation.getMethod().getName().equals("enqueue")) Mockito.mockingDetails(writeQueue).getInvocations(),
// Find the cancel commands. // Get enqueue() innovations only
.filter(invocation -> invocation.getArgument(0) instanceof CancelServerStreamCommand) invocation -> invocation.getMethod().getName().equals("enqueue")
.map(invocation -> invocation.getArgument(0, CancelServerStreamCommand.class)) // Find the cancel commands.
.collect(Collectors.toList()); && invocation.getArgument(0) instanceof CancelServerStreamCommand),
invocation -> invocation.getArgument(0, CancelServerStreamCommand.class)));
assertWithMessage("Expected exactly one CancelClientStreamCommand").that(commands).hasSize(1); assertWithMessage("Expected exactly one CancelClientStreamCommand").that(commands).hasSize(1);
return commands.get(0); return commands.get(0);

View File

@ -31,6 +31,7 @@ import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import com.google.common.base.Optional;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallCredentials; import io.grpc.CallCredentials;
import io.grpc.ChannelCredentials; import io.grpc.ChannelCredentials;
@ -120,7 +121,6 @@ import java.util.ArrayDeque;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -877,7 +877,7 @@ public class ProtocolNegotiatorsTest {
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext,
"authority", elg, noopLogger, Optional.empty()); "authority", elg, noopLogger, Optional.absent());
pipeline.addLast(handler); pipeline.addLast(handler);
pipeline.replace(SslHandler.class, null, goodSslHandler); pipeline.replace(SslHandler.class, null, goodSslHandler);
pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT); pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT);
@ -915,7 +915,7 @@ public class ProtocolNegotiatorsTest {
.applicationProtocolConfig(apn).build(); .applicationProtocolConfig(apn).build();
ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext,
"authority", elg, noopLogger, Optional.empty()); "authority", elg, noopLogger, Optional.absent());
pipeline.addLast(handler); pipeline.addLast(handler);
pipeline.replace(SslHandler.class, null, goodSslHandler); pipeline.replace(SslHandler.class, null, goodSslHandler);
pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT); pipeline.fireUserEventTriggered(ProtocolNegotiationEvent.DEFAULT);
@ -939,7 +939,7 @@ public class ProtocolNegotiatorsTest {
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1); DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext,
"authority", elg, noopLogger, Optional.empty()); "authority", elg, noopLogger, Optional.absent());
pipeline.addLast(handler); pipeline.addLast(handler);
final AtomicReference<Throwable> error = new AtomicReference<>(); final AtomicReference<Throwable> error = new AtomicReference<>();
@ -967,7 +967,7 @@ public class ProtocolNegotiatorsTest {
@Test @Test
public void clientTlsHandler_closeDuringNegotiation() throws Exception { public void clientTlsHandler_closeDuringNegotiation() throws Exception {
ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext, ClientTlsHandler handler = new ClientTlsHandler(grpcHandler, sslContext,
"authority", null, noopLogger, Optional.empty()); "authority", null, noopLogger, Optional.absent());
pipeline.addLast(new WriteBufferingAndExceptionHandler(handler)); pipeline.addLast(new WriteBufferingAndExceptionHandler(handler));
ChannelFuture pendingWrite = channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE); ChannelFuture pendingWrite = channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE);
@ -1230,7 +1230,7 @@ public class ProtocolNegotiatorsTest {
} }
FakeGrpcHttp2ConnectionHandler gh = FakeGrpcHttp2ConnectionHandler.newHandler(); FakeGrpcHttp2ConnectionHandler gh = FakeGrpcHttp2ConnectionHandler.newHandler();
ClientTlsProtocolNegotiator pn = new ClientTlsProtocolNegotiator(clientSslContext, ClientTlsProtocolNegotiator pn = new ClientTlsProtocolNegotiator(clientSslContext,
null, Optional.empty()); null, Optional.absent());
WriteBufferingAndExceptionHandler clientWbaeh = WriteBufferingAndExceptionHandler clientWbaeh =
new WriteBufferingAndExceptionHandler(pn.newHandler(gh)); new WriteBufferingAndExceptionHandler(pn.newHandler(gh));

View File

@ -31,8 +31,16 @@ dependencies {
project(':grpc-testing-proto'), project(':grpc-testing-proto'),
libraries.netty.codec.http2, libraries.netty.codec.http2,
libraries.okhttp libraries.okhttp
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
project.sourceSets { project.sourceSets {

View File

@ -23,8 +23,11 @@ dependencies {
annotationProcessor libraries.auto.value annotationProcessor libraries.auto.value
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
} }
tasks.named("jar").configure { tasks.named("jar").configure {

View File

@ -17,8 +17,16 @@ dependencies {
testImplementation project(':grpc-core') testImplementation project(':grpc-core')
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("jar").configure { tasks.named("jar").configure {

View File

@ -31,8 +31,16 @@ dependencies {
exclude group: 'com.google.protobuf', module: 'protobuf-javalite' exclude group: 'com.google.protobuf', module: 'protobuf-javalite'
} }
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { tasks.named("javadoc").configure {

View File

@ -30,7 +30,11 @@ dependencies {
project(':grpc-testing-proto'), project(':grpc-testing-proto'),
testFixtures(project(':grpc-api')), testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-core')) testFixtures(project(':grpc-core'))
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
tasks.named("compileJava").configure { tasks.named("compileJava").configure {

View File

@ -62,7 +62,11 @@ dependencies {
} }
} }
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -253,7 +253,7 @@ public final class S2AProtocolNegotiatorFactory {
InternalProtocolNegotiators.tls( InternalProtocolNegotiators.tls(
sslContext, sslContext,
SharedResourcePool.forResource(GrpcUtil.SHARED_CHANNEL_EXECUTOR), SharedResourcePool.forResource(GrpcUtil.SHARED_CHANNEL_EXECUTOR),
Optional.of(new Runnable() { com.google.common.base.Optional.of(new Runnable() {
@Override @Override
public void run() { public void run() {
s2aStub.close(); s2aStub.close();
@ -278,4 +278,4 @@ public final class S2AProtocolNegotiatorFactory {
} }
private S2AProtocolNegotiatorFactory() {} private S2AProtocolNegotiatorFactory() {}
} }

View File

@ -39,7 +39,11 @@ dependencies {
testFixtures(project(':grpc-core')), testFixtures(project(':grpc-core')),
testFixtures(project(':grpc-api')) testFixtures(project(':grpc-api'))
testCompileOnly libraries.javax.annotation testCompileOnly libraries.javax.annotation
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -12,6 +12,7 @@ java_library(
artifact("com.google.code.findbugs:jsr305"), artifact("com.google.code.findbugs:jsr305"),
artifact("com.google.errorprone:error_prone_annotations"), artifact("com.google.errorprone:error_prone_annotations"),
artifact("com.google.guava:guava"), artifact("com.google.guava:guava"),
artifact("org.codehaus.mojo:animal-sniffer-annotations"),
], ],
) )

View File

@ -22,8 +22,16 @@ dependencies {
project(':grpc-inprocess'), project(':grpc-inprocess'),
project(':grpc-testing'), project(':grpc-testing'),
testFixtures(project(':grpc-api')) testFixtures(project(':grpc-api'))
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { tasks.named("javadoc").configure {

View File

@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.CheckReturnValue; import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe; import javax.annotation.concurrent.ThreadSafe;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
/** /**
* Common base type for stub implementations. Stub configuration is immutable; changing the * Common base type for stub implementations. Stub configuration is immutable; changing the
@ -152,6 +153,7 @@ public abstract class AbstractStub<S extends AbstractStub<S>> {
} }
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/11657") @ExperimentalApi("https://github.com/grpc/grpc-java/issues/11657")
@IgnoreJRERequirement
public final S withDeadlineAfter(Duration duration) { public final S withDeadlineAfter(Duration duration) {
return withDeadlineAfter(convert(duration), TimeUnit.NANOSECONDS); return withDeadlineAfter(convert(duration), TimeUnit.NANOSECONDS);
} }

View File

@ -28,6 +28,7 @@ import io.grpc.Deadline;
import io.grpc.stub.AbstractStub.StubFactory; import io.grpc.stub.AbstractStub.StubFactory;
import io.grpc.stub.AbstractStubTest.NoopStub; import io.grpc.stub.AbstractStubTest.NoopStub;
import java.time.Duration; import java.time.Duration;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@ -54,6 +55,7 @@ public class AbstractStubTest extends BaseAbstractStubTest<NoopStub> {
} }
@Test @Test
@IgnoreJRERequirement
public void testDuration() { public void testDuration() {
NoopStub stub = NoopStub.newStub(new StubFactory<NoopStub>() { NoopStub stub = NoopStub.newStub(new StubFactory<NoopStub>() {
@Override @Override

View File

@ -20,7 +20,11 @@ dependencies {
compileOnly libraries.javax.annotation compileOnly libraries.javax.annotation
testImplementation libraries.truth testImplementation libraries.truth
testRuntimeOnly libraries.javax.annotation testRuntimeOnly libraries.javax.annotation
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -24,8 +24,16 @@ dependencies {
testImplementation project(':grpc-testing-proto'), testImplementation project(':grpc-testing-proto'),
testFixtures(project(':grpc-core')) testFixtures(project(':grpc-core'))
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
tasks.named("javadoc").configure { exclude 'io/grpc/internal/**' } tasks.named("javadoc").configure { exclude 'io/grpc/internal/**' }

View File

@ -35,8 +35,16 @@ dependencies {
project(':grpc-testing') project(':grpc-testing')
jmh project(':grpc-testing') jmh project(':grpc-testing')
signature libraries.signature.java signature (libraries.signature.java) {
signature libraries.signature.android artifact {
extension = "signature"
}
}
signature (libraries.signature.android) {
artifact {
extension = "signature"
}
}
} }
animalsniffer { animalsniffer {

View File

@ -685,7 +685,11 @@ public final class OutlierDetectionLoadBalancer extends LoadBalancer {
/** Adds a new tracker for every given address. */ /** Adds a new tracker for every given address. */
void putNewTrackers(OutlierDetectionLoadBalancerConfig config, void putNewTrackers(OutlierDetectionLoadBalancerConfig config,
Set<Set<SocketAddress>> endpoints) { Set<Set<SocketAddress>> endpoints) {
endpoints.forEach(e -> trackerMap.putIfAbsent(e, new EndpointTracker(config))); for (Set<SocketAddress> endpoint : endpoints) {
if (!trackerMap.containsKey(endpoint)) {
trackerMap.put(endpoint, new EndpointTracker(config));
}
}
} }
/** Resets the call counters for all the trackers in the map. */ /** Resets the call counters for all the trackers in the map. */

View File

@ -44,6 +44,7 @@ import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -51,6 +52,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link AdvancedTlsX509TrustManager}. */ /** Unit tests for {@link AdvancedTlsX509TrustManager}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
@IgnoreJRERequirement
public class AdvancedTlsX509TrustManagerTest { public class AdvancedTlsX509TrustManagerTest {
private static final String CA_PEM_FILE = "ca.pem"; private static final String CA_PEM_FILE = "ca.pem";

View File

@ -81,7 +81,11 @@ dependencies {
shadow configurations.implementation.getDependencies().minus([nettyDependency]) shadow configurations.implementation.getDependencies().minus([nettyDependency])
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow') shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')
signature libraries.signature.java signature (libraries.signature.java) {
artifact {
extension = "signature"
}
}
testRuntimeOnly libraries.netty.tcnative, testRuntimeOnly libraries.netty.tcnative,
libraries.netty.tcnative.classes libraries.netty.tcnative.classes
testRuntimeOnly (libraries.netty.tcnative) { testRuntimeOnly (libraries.netty.tcnative) {