Skip to content

Commit f249266

Browse files
authored
Fix method template signature broken in #639 (#700)
1 parent 3ae0858 commit f249266

File tree

2 files changed

+8
-1
lines changed
  • google-http-client/src

2 files changed

+8
-1
lines changed

google-http-client/src/main/java/com/google/api/client/util/Data.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class Data {
108108
* @return magic object instance that represents the "null" value (not Java {@code null})
109109
* @throws IllegalArgumentException if unable to create a new instance
110110
*/
111-
public static <T> T nullOf(Class<?> objClass) {
111+
public static <T> T nullOf(Class<T> objClass) {
112112
// ConcurrentMap.computeIfAbsent is explicitly NOT used in the following logic. The
113113
// ConcurrentHashMap implementation of that method BLOCKS if the mappingFunction triggers
114114
// modification of the map which createNullInstance can do depending on the state of class

google-http-client/src/test/java/com/google/api/client/util/DataTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.api.client.util;
1616

17+
import com.google.common.collect.ImmutableMap;
1718
import java.lang.reflect.ParameterizedType;
1819
import java.lang.reflect.Type;
1920
import java.lang.reflect.TypeVariable;
@@ -68,6 +69,12 @@ public void testNullOf() {
6869
}
6970
}
7071

72+
public void testNullOfTemplateTypes() {
73+
String nullValue = Data.nullOf(String.class);
74+
Map<String, String> nullField = ImmutableMap.of("v", nullValue);
75+
assertEquals(nullValue, nullField.get("v"));
76+
}
77+
7178
public void testIsNull() {
7279
assertTrue(Data.isNull(Data.NULL_BOOLEAN));
7380
assertTrue(Data.isNull(Data.NULL_STRING));

0 commit comments

Comments
 (0)