From f24926619e3095d7d2ddd26d19b8ba2a5f2e0d68 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 6 Jun 2019 10:10:00 -0700 Subject: [PATCH] Fix method template signature broken in #639 (#700) --- .../src/main/java/com/google/api/client/util/Data.java | 2 +- .../src/test/java/com/google/api/client/util/DataTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/google-http-client/src/main/java/com/google/api/client/util/Data.java b/google-http-client/src/main/java/com/google/api/client/util/Data.java index 10e3fe5bd..5b2a91e4b 100644 --- a/google-http-client/src/main/java/com/google/api/client/util/Data.java +++ b/google-http-client/src/main/java/com/google/api/client/util/Data.java @@ -108,7 +108,7 @@ public class Data { * @return magic object instance that represents the "null" value (not Java {@code null}) * @throws IllegalArgumentException if unable to create a new instance */ - public static T nullOf(Class objClass) { + public static T nullOf(Class objClass) { // ConcurrentMap.computeIfAbsent is explicitly NOT used in the following logic. The // ConcurrentHashMap implementation of that method BLOCKS if the mappingFunction triggers // modification of the map which createNullInstance can do depending on the state of class diff --git a/google-http-client/src/test/java/com/google/api/client/util/DataTest.java b/google-http-client/src/test/java/com/google/api/client/util/DataTest.java index de428c60c..00f1dd5d2 100644 --- a/google-http-client/src/test/java/com/google/api/client/util/DataTest.java +++ b/google-http-client/src/test/java/com/google/api/client/util/DataTest.java @@ -14,6 +14,7 @@ package com.google.api.client.util; +import com.google.common.collect.ImmutableMap; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; @@ -68,6 +69,12 @@ public void testNullOf() { } } + public void testNullOfTemplateTypes() { + String nullValue = Data.nullOf(String.class); + Map nullField = ImmutableMap.of("v", nullValue); + assertEquals(nullValue, nullField.get("v")); + } + public void testIsNull() { assertTrue(Data.isNull(Data.NULL_BOOLEAN)); assertTrue(Data.isNull(Data.NULL_STRING));