Polishing

Closes gh-29284
This commit is contained in:
Johnny Lim 2022-10-08 09:26:52 +09:00 committed by Sam Brannen
parent c1ff812d84
commit ced37d53b4
5 changed files with 11 additions and 20 deletions

View File

@ -148,6 +148,7 @@ class AopProxyUtilsTests {
sealed interface SealedInterface { sealed interface SealedInterface {
} }
@SuppressWarnings("unused")
static final class SealedClass implements SealedInterface { static final class SealedClass implements SealedInterface {
} }

View File

@ -51,8 +51,8 @@ public class BeanUtilsBenchmark {
return BeanUtils.instantiateClass(this.constructor, 1, "str"); return BeanUtils.instantiateClass(this.constructor, 1, "str");
} }
static class TestClass1{ static class TestClass1 {
}; }
@SuppressWarnings("unused") @SuppressWarnings("unused")
static class TestClass2 { static class TestClass2 {

View File

@ -22,7 +22,6 @@ import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.springframework.cache.interceptor.CacheEvictOperation; import org.springframework.cache.interceptor.CacheEvictOperation;
@ -49,14 +48,7 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable { public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable {
private static final Set<Class<? extends Annotation>> CACHE_OPERATION_ANNOTATIONS = new LinkedHashSet<>(8); private static final Set<Class<? extends Annotation>> CACHE_OPERATION_ANNOTATIONS = Set.of(Cacheable.class, CacheEvict.class, CachePut.class, Caching.class);
static {
CACHE_OPERATION_ANNOTATIONS.add(Cacheable.class);
CACHE_OPERATION_ANNOTATIONS.add(CacheEvict.class);
CACHE_OPERATION_ANNOTATIONS.add(CachePut.class);
CACHE_OPERATION_ANNOTATIONS.add(Caching.class);
}
@Override @Override

View File

@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.aot.hint.ReflectionHints; import org.springframework.aot.hint.ReflectionHints;
@ -39,7 +38,7 @@ import org.springframework.util.ReflectionUtils;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Andy Wilkinson * @author Andy Wilkinson
* since 6.0 * @since 6.0
*/ */
public class ReflectiveRuntimeHintsRegistrar { public class ReflectiveRuntimeHintsRegistrar {
@ -92,11 +91,11 @@ public class ReflectiveRuntimeHintsRegistrar {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Entry createEntry(AnnotatedElement element) { private Entry createEntry(AnnotatedElement element) {
List<Class<? extends ReflectiveProcessor>> processorClasses = List<ReflectiveProcessor> processors =
MergedAnnotations.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY) MergedAnnotations.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
.stream(Reflective.class).flatMap(annotation -> Stream.of(annotation.getClassArray("value"))) .stream(Reflective.class).flatMap(annotation -> Stream.of(annotation.getClassArray("value")))
.map(type -> (Class<? extends ReflectiveProcessor>) type).collect(Collectors.toList()); .map(type -> (Class<? extends ReflectiveProcessor>) type)
List<ReflectiveProcessor> processors = processorClasses.stream().distinct() .distinct()
.map(processorClass -> this.processors.computeIfAbsent(processorClass, this::instantiateClass)) .map(processorClass -> this.processors.computeIfAbsent(processorClass, this::instantiateClass))
.toList(); .toList();
ReflectiveProcessor processorToUse = (processors.size() == 1 ? processors.get(0) ReflectiveProcessor processorToUse = (processors.size() == 1 ? processors.get(0)

View File

@ -20,7 +20,6 @@ import java.io.IOException;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -195,7 +194,7 @@ public abstract class AbstractJackson2Encoder extends Jackson2CodecSupport imple
delimiter, EMPTY_BYTES); delimiter, EMPTY_BYTES);
return (prefix.length > 0 ? return (prefix.length > 0 ?
bufferFactory.join(Arrays.asList(bufferFactory.wrap(prefix), dataBuffer)) : bufferFactory.join(List.of(bufferFactory.wrap(prefix), dataBuffer)) :
dataBuffer); dataBuffer);
}) })
.switchIfEmpty(Mono.fromCallable(() -> bufferFactory.wrap(helper.getPrefix()))) .switchIfEmpty(Mono.fromCallable(() -> bufferFactory.wrap(helper.getPrefix())))