Skip to content

Commit 8a94077

Browse files
committed
Clean up warnings in spring-core
1 parent 8f4fb20 commit 8a94077

File tree

6 files changed

+10
-29
lines changed

6 files changed

+10
-29
lines changed

spring-core/src/main/java/org/springframework/core/MethodParameter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public Method getMethod() {
182182
*/
183183
@Nullable
184184
public Constructor<?> getConstructor() {
185-
return (this.executable instanceof Constructor ? (Constructor) this.executable : null);
185+
return (this.executable instanceof Constructor ? (Constructor<?>) this.executable : null);
186186
}
187187

188188
/**
@@ -586,7 +586,7 @@ public String getParameterName() {
586586
parameterNames = discoverer.getParameterNames((Method) this.executable);
587587
}
588588
else if (this.executable instanceof Constructor) {
589-
parameterNames = discoverer.getParameterNames((Constructor) this.executable);
589+
parameterNames = discoverer.getParameterNames((Constructor<?>) this.executable);
590590
}
591591
if (parameterNames != null) {
592592
this.parameterName = parameterNames[this.parameterIndex];

spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ public boolean hasAnnotation(Class<? extends Annotation> annotationType) {
251251
* @param annotationType the annotation type
252252
* @return the annotation, or {@code null} if no such annotation exists on this type descriptor
253253
*/
254-
@SuppressWarnings("unchecked")
255254
@Nullable
256255
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
257256
if (this.annotatedElement.isEmpty()) {

spring-core/src/main/java/org/springframework/core/convert/support/ObjectToOptionalConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ else if (source instanceof Optional) {
7676
else if (targetType.getResolvableType().hasGenerics()) {
7777
Object target = this.conversionService.convert(source, sourceType, new GenericTypeDescriptor(targetType));
7878
if (target == null || (target.getClass().isArray() && Array.getLength(target) == 0) ||
79-
(target instanceof Collection && ((Collection) target).isEmpty())) {
79+
(target instanceof Collection && ((Collection<?>) target).isEmpty())) {
8080
return Optional.empty();
8181
}
8282
return Optional.of(target);

spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.io.Serializable;
2020
import java.lang.reflect.Method;
21-
import java.lang.reflect.TypeVariable;
2221
import java.util.Collection;
2322
import java.util.Date;
2423
import java.util.HashMap;
@@ -43,16 +42,6 @@
4342
@SuppressWarnings("rawtypes")
4443
public class BridgeMethodResolverTests {
4544

46-
private static TypeVariable<?> findTypeVariable(Class<?> clazz, String name) {
47-
TypeVariable<?>[] variables = clazz.getTypeParameters();
48-
for (TypeVariable<?> variable : variables) {
49-
if (variable.getName().equals(name)) {
50-
return variable;
51-
}
52-
}
53-
return null;
54-
}
55-
5645
private static Method findMethodWithReturnType(String name, Class<?> returnType, Class<SettingsDaoImpl> targetType) {
5746
Method[] methods = targetType.getMethods();
5847
for (Method m : methods) {

spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.core.convert.support;
1718

1819
import java.time.Duration;
@@ -22,7 +23,6 @@
2223

2324
import io.reactivex.Flowable;
2425
import io.reactivex.Maybe;
25-
import org.junit.Before;
2626
import org.junit.Test;
2727
import org.reactivestreams.Publisher;
2828
import reactor.core.publisher.Flux;
@@ -50,13 +50,7 @@
5050
@SuppressWarnings("unchecked")
5151
public class ReactiveAdapterRegistryTests {
5252

53-
private ReactiveAdapterRegistry registry;
54-
55-
56-
@Before
57-
public void setUp() throws Exception {
58-
this.registry = new ReactiveAdapterRegistry();
59-
}
53+
private final ReactiveAdapterRegistry registry = new ReactiveAdapterRegistry();
6054

6155

6256
@Test
@@ -137,7 +131,7 @@ public void publisherToRxObservable() throws Exception {
137131
Publisher<Integer> source = Flowable.fromIterable(sequence);
138132
Object target = getAdapter(rx.Observable.class).fromPublisher(source);
139133
assertTrue(target instanceof rx.Observable);
140-
assertEquals(sequence, ((rx.Observable) target).toList().toBlocking().first());
134+
assertEquals(sequence, ((rx.Observable<?>) target).toList().toBlocking().first());
141135
}
142136

143137
@Test
@@ -162,7 +156,7 @@ public void publisherToReactivexFlowable() throws Exception {
162156
Publisher<Integer> source = Flux.fromIterable(sequence);
163157
Object target = getAdapter(io.reactivex.Flowable.class).fromPublisher(source);
164158
assertTrue(target instanceof io.reactivex.Flowable);
165-
assertEquals(sequence, ((io.reactivex.Flowable) target).toList().blockingGet());
159+
assertEquals(sequence, ((io.reactivex.Flowable<?>) target).toList().blockingGet());
166160
}
167161

168162
@Test
@@ -171,7 +165,7 @@ public void publisherToReactivexObservable() throws Exception {
171165
Publisher<Integer> source = Flowable.fromIterable(sequence);
172166
Object target = getAdapter(io.reactivex.Observable.class).fromPublisher(source);
173167
assertTrue(target instanceof io.reactivex.Observable);
174-
assertEquals(sequence, ((io.reactivex.Observable) target).toList().blockingGet());
168+
assertEquals(sequence, ((io.reactivex.Observable<?>) target).toList().blockingGet());
175169
}
176170

177171
@Test
@@ -251,7 +245,7 @@ public void reactivexCompletableToPublisher() throws Exception {
251245

252246
@Test
253247
public void CompletableFutureToPublisher() throws Exception {
254-
CompletableFuture<Integer> future = new CompletableFuture();
248+
CompletableFuture<Integer> future = new CompletableFuture<>();
255249
future.complete(1);
256250
Object target = getAdapter(CompletableFuture.class).toPublisher(future);
257251
assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono);

spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public void computeIfAbsentWithComputedValue() {
104104
}
105105

106106
@Test
107-
@SuppressWarnings("unchecked")
108107
public void mapClone() {
109108
map.put("key", "value1");
110109
LinkedCaseInsensitiveMap<String> copy = map.clone();

0 commit comments

Comments
 (0)