From 033c8df53f097363564b2b3a7d57fc98eecd8b1a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 22 Dec 2023 12:54:16 +0100 Subject: [PATCH] Polishing --- .../aop/framework/AdvisedSupport.java | 34 +++++++++++-------- .../factory/support/ConstructorResolver.java | 6 +--- .../cache/caffeine/CaffeineCacheManager.java | 2 +- .../interceptor/CacheOperationInvoker.java | 4 +-- .../scheduling/TaskScheduler.java | 2 +- .../core/SerializableTypeWrapper.java | 2 +- .../spel/StandardTypeComparatorTests.java | 7 ++-- .../SimpleClientHttpRequestFactoryTests.java | 5 +-- .../reactive/ClientHttpConnectorTests.java | 4 +-- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index 41c5b1d21c..477c85c882 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -102,6 +102,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised { */ private List advisors = new ArrayList<>(); + /** + * List of minimal {@link AdvisorKeyEntry} instances, + * to be assigned to the {@link #advisors} field on reduction. + * @since 6.0.10 + * @see #reduceToAdvisorKey + */ private List advisorKey = this.advisors; @@ -557,18 +563,6 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } - //--------------------------------------------------------------------- - // Serialization support - //--------------------------------------------------------------------- - - private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - // Rely on default serialization; just initialize state after deserialization. - ois.defaultReadObject(); - - // Initialize transient fields. - this.methodCache = new ConcurrentHashMap<>(32); - } - @Override public String toProxyConfigString() { return toString(); @@ -590,6 +584,19 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } + //--------------------------------------------------------------------- + // Serialization support + //--------------------------------------------------------------------- + + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Rely on default serialization; just initialize state after deserialization. + ois.defaultReadObject(); + + // Initialize transient fields. + this.methodCache = new ConcurrentHashMap<>(32); + } + + /** * Simple wrapper class around a Method. Used as the key when * caching methods, for efficient equals and hashCode comparisons. @@ -639,7 +646,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { * @see #getConfigurationOnlyCopy() * @see #getAdvisorKey() */ - private static class AdvisorKeyEntry implements Advisor { + private static final class AdvisorKeyEntry implements Advisor { private final Class adviceType; @@ -649,7 +656,6 @@ public class AdvisedSupport extends ProxyConfig implements Advised { @Nullable private final String methodMatcherKey; - public AdvisorKeyEntry(Advisor advisor) { this.adviceType = advisor.getAdvice().getClass(); if (advisor instanceof PointcutAdvisor pointcutAdvisor) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 6af615a320..df91c0ca08 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -120,11 +120,7 @@ class ConstructorResolver { /** * "autowire constructor" (with constructor arguments by type) behavior. - * Also applied if explicit constructor argument values are specified, - * matching all remaining arguments with beans from the bean factory. - *

This corresponds to constructor injection: In this mode, a Spring - * bean factory is able to host components that expect constructor-based - * dependency resolution. + * Also applied if explicit constructor argument values are specified. * @param beanName the name of the bean * @param mbd the merged bean definition for the bean * @param chosenCtors chosen candidate constructors (or {@code null} if none) diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java index e80cb747f3..e03d19c314 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java @@ -236,7 +236,7 @@ public class CaffeineCacheManager implements CacheManager { * Build a common {@link CaffeineCache} instance for the specified cache name, * using the common Caffeine configuration specified on this cache manager. *

Delegates to {@link #adaptCaffeineCache} as the adaptation method to - * Spring's cache abstraction (allowing for centralized decoration etc), + * Spring's cache abstraction (allowing for centralized decoration etc.), * passing in a freshly built native Caffeine Cache instance. * @param name the name of the cache * @return the Spring CaffeineCache adapter (or a decorator thereof) diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java index cfaab08137..e37736480e 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 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. @@ -22,7 +22,7 @@ import org.springframework.lang.Nullable; * Abstract the invocation of a cache operation. * *

Does not provide a way to transmit checked exceptions but - * provide a special exception that should be used to wrap any + * provides a special exception that should be used to wrap any * exception that was thrown by the underlying invocation. * Callers are expected to handle this issue type specifically. * diff --git a/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java b/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java index 00cb01282c..a99d606920 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java +++ b/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java @@ -70,7 +70,7 @@ public interface TaskScheduler { * wrapping a cron expression * @return a {@link ScheduledFuture} representing pending completion of the task, * or {@code null} if the given Trigger object never fires (i.e. returns - * {@code null} from {@link Trigger#nextExecutionTime}) + * {@code null} from {@link Trigger#nextExecution}) * @throws org.springframework.core.task.TaskRejectedException if the given task was not accepted * for internal reasons (e.g. a pool overload handling policy or a pool shutdown in progress) * @see org.springframework.scheduling.support.CronTrigger diff --git a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java index 01e5a42b5e..44f5719ad7 100644 --- a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java +++ b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java @@ -159,7 +159,7 @@ final class SerializableTypeWrapper { /** * Return the source of the type, or {@code null} if not known. - *

The default implementations returns {@code null}. + *

The default implementation returns {@code null}. */ @Nullable default Object getSource() { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeComparatorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeComparatorTests.java index c962943c4c..48975c0819 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeComparatorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.TypeComparator; import org.springframework.expression.spel.support.StandardTypeComparator; -import org.springframework.lang.NonNull; import static org.assertj.core.api.Assertions.assertThat; @@ -134,6 +133,7 @@ public class StandardTypeComparatorTests { assertThat(comparator.compare(t2, t1)).isPositive(); } + static class ComparableType implements Comparable { private final int id; @@ -143,10 +143,9 @@ public class StandardTypeComparatorTests { } @Override - public int compareTo(@NonNull ComparableType other) { + public int compareTo(ComparableType other) { return this.id - other.id; } - } } diff --git a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java index fc4755db01..be08f3af12 100644 --- a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java @@ -32,14 +32,15 @@ import static org.mockito.Mockito.verify; */ public class SimpleClientHttpRequestFactoryTests { - - @Test // SPR-13225 + @Test // SPR-13225 public void headerWithNullValue() { HttpURLConnection urlConnection = mock(); given(urlConnection.getRequestMethod()).willReturn("GET"); + HttpHeaders headers = new HttpHeaders(); headers.set("foo", null); SimpleBufferingClientHttpRequest.addHeaders(urlConnection, headers); + verify(urlConnection, times(1)).addRequestProperty("foo", ""); } diff --git a/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java b/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java index a49b081680..827ba44dbd 100644 --- a/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -51,7 +51,6 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ReactiveHttpOutputMessage; -import org.springframework.lang.NonNull; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -173,7 +172,6 @@ public class ClientHttpConnectorTests { .verify(); } - @NonNull private Buffer randomBody(int size) { Buffer responseBody = new Buffer(); Random rnd = new Random();