Skip to content

Commit

Permalink
Fix method template signature broken in #639 (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 authored Jun 6, 2019
1 parent 3ae0858 commit f249266
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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> T nullOf(Class<?> objClass) {
public static <T> T nullOf(Class<T> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,6 +69,12 @@ public void testNullOf() {
}
}

public void testNullOfTemplateTypes() {
String nullValue = Data.nullOf(String.class);
Map<String, String> 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));
Expand Down

0 comments on commit f249266

Please sign in to comment.