Cleanup all unsafe and unchecked compiler warnings.

This commit is contained in:
John Blum
2020-07-23 14:56:10 -07:00
parent ba24c50ba2
commit 20b8c2d172
4 changed files with 14 additions and 12 deletions

View File

@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
* @see org.apache.geode.pdx.PdxInstance
* @since 1.0.0
*/
@SuppressWarnings("all")
@SuppressWarnings("unused")
public abstract class ObjectUtils extends org.springframework.util.ObjectUtils {
private static final Logger logger = LoggerFactory.getLogger(ObjectUtils.class);
@@ -251,6 +251,7 @@ public abstract class ObjectUtils extends org.springframework.util.ObjectUtils {
* @see java.lang.reflect.Field
* @see java.lang.Object
*/
@SuppressWarnings("unchecked")
public static <T> T get(Object obj, Field field) {
Assert.notNull(obj, "Object is required");
@@ -316,7 +317,7 @@ public abstract class ObjectUtils extends org.springframework.util.ObjectUtils {
* @return the given {@link Constructor}.
* @see java.lang.reflect.Constructor
*/
public static Constructor makeAccessible(@NonNull Constructor<?> constructor) {
public static Constructor<?> makeAccessible(@NonNull Constructor<?> constructor) {
ReflectionUtils.makeAccessible(constructor);

View File

@@ -129,7 +129,7 @@ public class SpringCachingWithMockObjectsUnitTests {
return mockCacheManager;
}
@SuppressWarnings("all")
@SuppressWarnings("unchecked")
private Cache mockCache(String name) {
Map<Object, Object> cacheMap = new ConcurrentHashMap<>();
@@ -158,9 +158,8 @@ public class SpringCachingWithMockObjectsUnitTests {
Object key = invocation.getArgument(0);
Object value = cacheMap.get(key);
Cache.ValueWrapper wrapper = value != null ? () -> value : null;
return asCacheValueWrapper(value);
return wrapper ;
});
when(mockCache.get(any(), any(Class.class))).thenAnswer(invocation -> {
@@ -174,7 +173,7 @@ public class SpringCachingWithMockObjectsUnitTests {
when(mockCache.get(any(), any(Callable.class))).thenAnswer(invocation -> {
Object key = invocation.getArgument(0);
Callable valueLoader = invocation.getArgument(1);
Callable<?> valueLoader = invocation.getArgument(1);
Object value = cacheMap.get(key);
return value != null ? value : valueLoader.call();
@@ -206,15 +205,17 @@ public class SpringCachingWithMockObjectsUnitTests {
Object newValue = invocation.getArgument(1);
Object existingValue = cacheMap.putIfAbsent(key, newValue);
Cache.ValueWrapper wrapper = () -> existingValue;
return wrapper;
return asCacheValueWrapper(existingValue);
}).when(mockCache).putIfAbsent(any(), any());
return mockCache;
}
private Cache.ValueWrapper asCacheValueWrapper(Object value) {
return value != null ? () -> value : null;
}
@Nullable @Override
public CacheManager getObject() {
return this.cacheManager;