Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix method template signature broken in #639
  • Loading branch information
chingor13 committed Jun 6, 2019
commit 2d1d440fc5fef0422b87a7237c4fa65758c39e4d
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