Skip to content

Commit

Permalink
Log warnings for users who send Guava types over GWT-RPC.
Browse files Browse the repository at this point in the history
I've left this change out of the Android branch. For starters, it's not necessary there, since we don't support GWT. But normally we'd include it anyway to minimize diffs. However, doing so increases the number of classes retained after running Proguard (thanks, I assume, to the Logger field). There are other ways of getting around this, but for a temporary feature, the diffs seem tolerable.

RELNOTES=***Warning to users of GWT-RPC:*** The first Guava release of 2020 will [remove support for GWT-serializing Guava types](https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ). To test ahead of time with GWT-RPC support for Guava types disabled, set the `guava.gwt.emergency_reenable_rpc` system property to `false`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=273803350
  • Loading branch information
cpovirk authored and nick-someone committed Oct 10, 2019
1 parent 5f2c9fd commit 08bbf53
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions guava/src/com/google/common/base/Platform.java
Expand Up @@ -111,5 +111,12 @@ static void checkGwtRpcEnabled() {
"https://stackoverflow.com/q/5189914/28465",
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
}
logger.log(
java.util.logging.Level.WARNING,
"In January 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());

}
}
10 changes: 10 additions & 0 deletions guava/src/com/google/common/collect/Platform.java
Expand Up @@ -32,6 +32,9 @@
*/
@GwtCompatible(emulated = true)
final class Platform {
private static final java.util.logging.Logger logger =
java.util.logging.Logger.getLogger(Platform.class.getName());

/** Returns the platform preferred implementation of a map based on a hash table. */
static <K, V> Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
return Maps.newHashMapWithExpectedSize(expectedSize);
Expand Down Expand Up @@ -125,6 +128,13 @@ static void checkGwtRpcEnabled() {
"https://stackoverflow.com/q/5189914/28465",
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
}
logger.log(
java.util.logging.Level.WARNING,
"In January 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());

}

private Platform() {}
Expand Down
10 changes: 10 additions & 0 deletions guava/src/com/google/common/primitives/Platform.java
Expand Up @@ -22,6 +22,9 @@
/** Methods factored out so that they can be emulated differently in GWT. */
@GwtCompatible(emulated = true)
final class Platform {
private static final java.util.logging.Logger logger =
java.util.logging.Logger.getLogger(Platform.class.getName());

private static final String GWT_RPC_PROPERTY_NAME = "guava.gwt.emergency_reenable_rpc";

static void checkGwtRpcEnabled() {
Expand All @@ -35,6 +38,13 @@ static void checkGwtRpcEnabled() {
"https://stackoverflow.com/q/5189914/28465",
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
}
logger.log(
java.util.logging.Level.WARNING,
"In January 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
+ " can identify which type by looking at the class name in the attached stack trace.",
new Throwable());

}

private Platform() {}
Expand Down

0 comments on commit 08bbf53

Please sign in to comment.