Cleanup all unsafe and unchecked compiler warnings.
This commit is contained in:
@@ -39,7 +39,7 @@ public class EnableSubscriptionConfigurationUnitTests {
|
||||
|
||||
private EnableSubscriptionConfiguration configuration = new EnableSubscriptionConfiguration();
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getFieldValue(Object target, String fieldName) {
|
||||
|
||||
return Optional.ofNullable(target)
|
||||
@@ -49,7 +49,7 @@ public class EnableSubscriptionConfigurationUnitTests {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
return field;
|
||||
})
|
||||
.<T>map(field -> (T) ReflectionUtils.getField(field, target))
|
||||
.map(field -> (T) ReflectionUtils.getField(field, target))
|
||||
.orElseThrow(() -> newIllegalArgumentException("Unable to get value of field [%s] on object of type [%s]",
|
||||
fieldName, target != null ? target.getClass().getName() : null));
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class LogbackSupport {
|
||||
appenderName, nullSafeTypeName(appenderType), nullSafeLoggerName(logger))));
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static <E, T extends Appender<E>> Class<T> nullSafeAppenderType(Class<T> appenderType) {
|
||||
return appenderType != null ? appenderType : (Class) Appender.class;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user