diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index 6676d50328..1a6dda592d 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -182,7 +182,7 @@ public class MethodParameter { */ @Nullable public Constructor getConstructor() { - return (this.executable instanceof Constructor ? (Constructor) this.executable : null); + return (this.executable instanceof Constructor ? (Constructor) this.executable : null); } /** @@ -586,7 +586,7 @@ public class MethodParameter { parameterNames = discoverer.getParameterNames((Method) this.executable); } else if (this.executable instanceof Constructor) { - parameterNames = discoverer.getParameterNames((Constructor) this.executable); + parameterNames = discoverer.getParameterNames((Constructor) this.executable); } if (parameterNames != null) { this.parameterName = parameterNames[this.parameterIndex]; diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index 3444685e0b..73aa91d5e2 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -251,7 +251,6 @@ public class TypeDescriptor implements Serializable { * @param annotationType the annotation type * @return the annotation, or {@code null} if no such annotation exists on this type descriptor */ - @SuppressWarnings("unchecked") @Nullable public T getAnnotation(Class annotationType) { if (this.annotatedElement.isEmpty()) { diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java index 27635ca74b..de76a9f4a7 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java @@ -76,7 +76,7 @@ final class ObjectToOptionalConverter implements ConditionalGenericConverter { else if (targetType.getResolvableType().hasGenerics()) { Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType)); if (target == null || (target.getClass().isArray() && Array.getLength(target) == 0) || - (target instanceof Collection && ((Collection) target).isEmpty())) { + (target instanceof Collection && ((Collection) target).isEmpty())) { return Optional.empty(); } return Optional.of(target); diff --git a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java index da0cbab1a8..0aa4d075cc 100644 --- a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java @@ -18,7 +18,6 @@ package org.springframework.core; import java.io.Serializable; import java.lang.reflect.Method; -import java.lang.reflect.TypeVariable; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -43,16 +42,6 @@ import static org.junit.Assert.*; @SuppressWarnings("rawtypes") public class BridgeMethodResolverTests { - private static TypeVariable findTypeVariable(Class clazz, String name) { - TypeVariable[] variables = clazz.getTypeParameters(); - for (TypeVariable variable : variables) { - if (variable.getName().equals(name)) { - return variable; - } - } - return null; - } - private static Method findMethodWithReturnType(String name, Class returnType, Class targetType) { Method[] methods = targetType.getMethods(); for (Method m : methods) { diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java index 50fc78ea98..f20d3a2441 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.core.convert.support; import java.time.Duration; @@ -22,7 +23,6 @@ import java.util.concurrent.CompletableFuture; import io.reactivex.Flowable; import io.reactivex.Maybe; -import org.junit.Before; import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -50,13 +50,7 @@ import static org.junit.Assert.assertTrue; @SuppressWarnings("unchecked") public class ReactiveAdapterRegistryTests { - private ReactiveAdapterRegistry registry; - - - @Before - public void setUp() throws Exception { - this.registry = new ReactiveAdapterRegistry(); - } + private final ReactiveAdapterRegistry registry = new ReactiveAdapterRegistry(); @Test @@ -137,7 +131,7 @@ public class ReactiveAdapterRegistryTests { Publisher source = Flowable.fromIterable(sequence); Object target = getAdapter(rx.Observable.class).fromPublisher(source); assertTrue(target instanceof rx.Observable); - assertEquals(sequence, ((rx.Observable) target).toList().toBlocking().first()); + assertEquals(sequence, ((rx.Observable) target).toList().toBlocking().first()); } @Test @@ -162,7 +156,7 @@ public class ReactiveAdapterRegistryTests { Publisher source = Flux.fromIterable(sequence); Object target = getAdapter(io.reactivex.Flowable.class).fromPublisher(source); assertTrue(target instanceof io.reactivex.Flowable); - assertEquals(sequence, ((io.reactivex.Flowable) target).toList().blockingGet()); + assertEquals(sequence, ((io.reactivex.Flowable) target).toList().blockingGet()); } @Test @@ -171,7 +165,7 @@ public class ReactiveAdapterRegistryTests { Publisher source = Flowable.fromIterable(sequence); Object target = getAdapter(io.reactivex.Observable.class).fromPublisher(source); assertTrue(target instanceof io.reactivex.Observable); - assertEquals(sequence, ((io.reactivex.Observable) target).toList().blockingGet()); + assertEquals(sequence, ((io.reactivex.Observable) target).toList().blockingGet()); } @Test @@ -251,7 +245,7 @@ public class ReactiveAdapterRegistryTests { @Test public void CompletableFutureToPublisher() throws Exception { - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); future.complete(1); Object target = getAdapter(CompletableFuture.class).toPublisher(future); assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono); diff --git a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java index e632c28ea2..ae0fd141be 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java @@ -104,7 +104,6 @@ public class LinkedCaseInsensitiveMapTests { } @Test - @SuppressWarnings("unchecked") public void mapClone() { map.put("key", "value1"); LinkedCaseInsensitiveMap copy = map.clone();