Skip to content

Commit

Permalink
More appropriate usage of null key surrogate in Gson#getAdapter for b…
Browse files Browse the repository at this point in the history
…ackward compatibility
  • Loading branch information
qwwdfsad committed Mar 4, 2016
1 parent c561184 commit 31dcfa3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions gson/src/main/java/com/google/gson/Gson.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,7 @@ private static TypeAdapter<AtomicLongArray> atomicLongArrayAdapter(final TypeAda
*/
@SuppressWarnings("unchecked")
public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) {
if (type == null) {
type = (TypeToken<T>) NULL_KEY_SURROGATE;
}
TypeAdapter<?> cached = typeTokenCache.get(type);
TypeAdapter<?> cached = typeTokenCache.get(type == null ? NULL_KEY_SURROGATE : type);
if (cached != null) {
return (TypeAdapter<T>) cached;
}
Expand Down

0 comments on commit 31dcfa3

Please sign in to comment.