diff --git a/android-interop-testing/app/build.gradle b/android-interop-testing/app/build.gradle index 587b2e0fc3..4ab70edc71 100644 --- a/android-interop-testing/app/build.gradle +++ b/android-interop-testing/app/build.gradle @@ -57,9 +57,6 @@ protobuf { dependencies { compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.google.android.gms:play-services-base:7.3.0' - compile 'com.google.code.findbugs:jsr305:3.0.0' - compile 'com.google.guava:guava:18.0' - compile 'com.squareup.okhttp:okhttp:2.2.0' // You need to build grpc-java to obtain these libraries below. compile 'io.grpc:grpc-protobuf-nano:1.2.0-SNAPSHOT' // CURRENT_GRPC_VERSION compile 'io.grpc:grpc-okhttp:1.2.0-SNAPSHOT' // CURRENT_GRPC_VERSION diff --git a/build.gradle b/build.gradle index 1b02c1985b..f4ab1f787f 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,7 @@ subprojects { protocPluginBaseName = 'protoc-gen-grpc-java' javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix" - guavaVersion = '20.0' + guavaVersion = '19.0' protobufVersion = '3.2.0' protobufNanoVersion = '3.0.0-alpha-5' diff --git a/core/src/main/java/io/grpc/internal/LogExceptionRunnable.java b/core/src/main/java/io/grpc/internal/LogExceptionRunnable.java index 5bf192b86b..835c1cd882 100644 --- a/core/src/main/java/io/grpc/internal/LogExceptionRunnable.java +++ b/core/src/main/java/io/grpc/internal/LogExceptionRunnable.java @@ -33,7 +33,6 @@ package io.grpc.internal; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.base.Throwables; import java.util.logging.Level; import java.util.logging.Logger; @@ -57,7 +56,7 @@ public final class LogExceptionRunnable implements Runnable { task.run(); } catch (Throwable t) { log.log(Level.SEVERE, "Exception while executing runnable " + task, t); - Throwables.throwIfUnchecked(t); + MoreThrowables.throwIfUnchecked(t); throw new AssertionError(t); } } diff --git a/core/src/main/java/io/grpc/internal/MoreThrowables.java b/core/src/main/java/io/grpc/internal/MoreThrowables.java new file mode 100644 index 0000000000..2792218478 --- /dev/null +++ b/core/src/main/java/io/grpc/internal/MoreThrowables.java @@ -0,0 +1,56 @@ +/* + * Copyright 2017, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.grpc.internal; + +import com.google.common.base.Preconditions; + +/** Utility functions when interacting with {@link Throwables}. */ +final class MoreThrowables { + /** + * Throws {code t} if it is an instance of {@link RuntimeException} or {@link Error}. + * + *
This is intended to mimic Guava's method by the same name, but which is unavailable to us
+ * due to compatibility with older Guava versions.
+ */
+ public static void throwIfUnchecked(Throwable t) {
+ Preconditions.checkNotNull(t);
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ }
+ if (t instanceof Error) {
+ throw (Error) t;
+ }
+ }
+
+ // Prevent instantiation
+ private MoreThrowables() {}
+}
diff --git a/core/src/main/java/io/grpc/internal/ServerCallImpl.java b/core/src/main/java/io/grpc/internal/ServerCallImpl.java
index fad2b700cd..3584a45976 100644
--- a/core/src/main/java/io/grpc/internal/ServerCallImpl.java
+++ b/core/src/main/java/io/grpc/internal/ServerCallImpl.java
@@ -39,7 +39,6 @@ import static io.grpc.internal.GrpcUtil.MESSAGE_ACCEPT_ENCODING_KEY;
import static io.grpc.internal.GrpcUtil.MESSAGE_ENCODING_KEY;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Throwables;
import io.grpc.Attributes;
import io.grpc.Codec;
import io.grpc.Compressor;
@@ -248,7 +247,7 @@ final class ServerCallImpl