Skip to content

Commit 08bbf53

Browse files
cpovirknick-someone
authored andcommitted
Log warnings for users who send Guava types over GWT-RPC.
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
1 parent 5f2c9fd commit 08bbf53

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

guava/src/com/google/common/base/Platform.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,12 @@ static void checkGwtRpcEnabled() {
111111
"https://stackoverflow.com/q/5189914/28465",
112112
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
113113
}
114+
logger.log(
115+
java.util.logging.Level.WARNING,
116+
"In January 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
117+
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
118+
+ " can identify which type by looking at the class name in the attached stack trace.",
119+
new Throwable());
120+
114121
}
115122
}

guava/src/com/google/common/collect/Platform.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
*/
3333
@GwtCompatible(emulated = true)
3434
final class Platform {
35+
private static final java.util.logging.Logger logger =
36+
java.util.logging.Logger.getLogger(Platform.class.getName());
37+
3538
/** Returns the platform preferred implementation of a map based on a hash table. */
3639
static <K, V> Map<K, V> newHashMapWithExpectedSize(int expectedSize) {
3740
return Maps.newHashMapWithExpectedSize(expectedSize);
@@ -125,6 +128,13 @@ static void checkGwtRpcEnabled() {
125128
"https://stackoverflow.com/q/5189914/28465",
126129
"https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ"));
127130
}
131+
logger.log(
132+
java.util.logging.Level.WARNING,
133+
"In January 2020, we will remove GWT-RPC support for Guava types. You are seeing this"
134+
+ " warning because you are sending a Guava type over GWT-RPC, which will break. You"
135+
+ " can identify which type by looking at the class name in the attached stack trace.",
136+
new Throwable());
137+
128138
}
129139

130140
private Platform() {}

guava/src/com/google/common/primitives/Platform.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
/** Methods factored out so that they can be emulated differently in GWT. */
2323
@GwtCompatible(emulated = true)
2424
final class Platform {
25+
private static final java.util.logging.Logger logger =
26+
java.util.logging.Logger.getLogger(Platform.class.getName());
27+
2528
private static final String GWT_RPC_PROPERTY_NAME = "guava.gwt.emergency_reenable_rpc";
2629

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

4050
private Platform() {}

0 commit comments

Comments
 (0)