From b2bdc7de30d512f3afbc4443f0b99f179010596e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 30 Dec 2023 15:51:05 +0100 Subject: [PATCH] Polishing --- .../AbstractAutowireCapableBeanFactory.java | 10 ++--- .../factory/support/AbstractBeanFactory.java | 4 +- .../factory/support/ConstructorResolver.java | 6 +-- .../cache/caffeine/CaffeineCacheManager.java | 2 +- .../cache/interceptor/CacheAspectSupport.java | 6 +-- .../interceptor/CacheOperationInvoker.java | 4 +- ...athScanningCandidateComponentProvider.java | 21 +++++----- .../support/AbstractApplicationContext.java | 2 +- .../scheduling/TaskScheduler.java | 4 +- .../PropertySourceAnnotationTests.java | 14 +++---- .../GenericApplicationContextTests.java | 10 ++--- ...mlBeanFactoryTests-delegationOverrides.xml | 33 ++++++--------- .../core/SerializableTypeWrapper.java | 2 +- .../core/metadata/CallMetaDataProvider.java | 40 +++++++++---------- .../metadata/GenericCallMetaDataProvider.java | 10 ++--- .../jdbc/datasource/AbstractDataSource.java | 20 +++------- .../jdbc/datasource/DelegatingDataSource.java | 36 ++++++----------- .../lookup/AbstractRoutingDataSource.java | 5 ++- .../interceptor/TransactionAspectSupport.java | 6 +-- .../ServletServerHttpAsyncRequestControl.java | 12 +++--- .../reactive/ServletHttpHandlerAdapter.java | 12 +++--- .../async/StandardServletAsyncWebRequest.java | 12 +++--- .../SimpleClientHttpRequestFactoryTests.java | 7 ++-- .../reactive/ClientHttpConnectorTests.java | 4 +- 24 files changed, 125 insertions(+), 157 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index fb0ba14b0be..50430f75712 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -97,10 +97,10 @@ import org.springframework.util.StringUtils; * Supports autowiring constructors, properties by name, and properties by type. * *

The main template method to be implemented by subclasses is - * {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, - * used for autowiring by type. In case of a factory which is capable of searching - * its bean definitions, matching beans will typically be implemented through such - * a search. For other factory styles, simplified matching algorithms can be implemented. + * {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, used for + * autowiring. In case of a {@link org.springframework.beans.factory.ListableBeanFactory} + * which is capable of searching its bean definitions, matching beans will typically be + * implemented through such a search. Otherwise, simplified matching can be implemented. * *

Note that this class does not assume or implement bean definition * registry capabilities. See {@link DefaultListableBeanFactory} for an implementation @@ -675,7 +675,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Apply SmartInstantiationAwareBeanPostProcessors to predict the // eventual type after a before-instantiation shortcut. if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) { - boolean matchingOnlyFactoryBean = typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class; + boolean matchingOnlyFactoryBean = (typesToMatch.length == 1 && typesToMatch[0] == FactoryBean.class); for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache().smartInstantiationAware) { Class predicted = bp.predictBeanType(targetType, beanName); if (predicted != null && diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 7303d69c270..651ace61dc2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.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. @@ -749,7 +749,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp aliases.add(fullBeanName); } String[] retrievedAliases = super.getAliases(beanName); - String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : ""; + String prefix = (factoryPrefix ? FACTORY_BEAN_PREFIX : ""); for (String retrievedAlias : retrievedAliases) { String alias = prefix + retrievedAlias; if (!alias.equals(name)) { 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 a30075f2731..ce54ef0b3eb 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 @@ -107,11 +107,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 e80cb747f39..e03d19c3141 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/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index 077850a2add..ed444aad3d9 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -547,10 +547,10 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker } /** - * Collect the {@link CachePutRequest} for all {@link CacheOperation} using - * the specified result value. + * Collect a {@link CachePutRequest} for every {@link CacheOperation} + * using the specified result value. * @param contexts the contexts to handle - * @param result the result value (never {@code null}) + * @param result the result value * @param putRequests the collection to update */ private void collectPutRequests(Collection contexts, 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 cfaab08137b..e37736480e5 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/context/annotation/ClassPathScanningCandidateComponentProvider.java b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java index 92d502a13f0..4c67efc9c58 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.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. @@ -62,11 +62,13 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; /** - * A component provider that provides candidate components from a base package. Can - * use {@link CandidateComponentsIndex the index} if it is available of scans the - * classpath otherwise. Candidate components are identified by applying exclude and - * include filters. {@link AnnotationTypeFilter}, {@link AssignableTypeFilter} include - * filters on an annotation/superclass that are annotated with {@link Indexed} are + * A component provider that scans for candidate components starting from a + * specified base package. Can use the {@linkplain CandidateComponentsIndex component + * index}, if it is available, and scans the classpath otherwise. + * + *

Candidate components are identified by applying exclude and include filters. + * {@link AnnotationTypeFilter} and {@link AssignableTypeFilter} include filters + * for an annotation/target-type that is annotated with {@link Indexed} are * supported: if any other include filter is specified, the index is ignored and * classpath scanning is used instead. * @@ -304,7 +306,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC /** - * Scan the class path for candidate components. + * Scan the component index or class path for candidate components. * @param basePackage the package to check for annotated classes * @return a corresponding Set of autodetected bean definitions */ @@ -318,7 +320,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC } /** - * Determine if the index can be used by this instance. + * Determine if the component index can be used by this instance. * @return {@code true} if the index is available and the configuration of this * instance is supported by it, {@code false} otherwise * @since 5.0 @@ -454,8 +456,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC } } catch (Throwable ex) { - throw new BeanDefinitionStoreException( - "Failed to read candidate component class: " + resource, ex); + throw new BeanDefinitionStoreException("Failed to read candidate component class: " + resource, ex); } } } diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index bd1d1af3160..a9b190f227d 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -211,7 +211,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** Flag that indicates whether this context has been closed already. */ private final AtomicBoolean closed = new AtomicBoolean(); - /** Synchronization monitor for the "refresh" and "destroy". */ + /** Synchronization monitor for "refresh" and "close". */ private final Object startupShutdownMonitor = new Object(); /** Reference to the JVM shutdown hook, if registered. */ 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 326923d10d4..e8cd73e15f8 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java +++ b/spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.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. @@ -29,7 +29,7 @@ import org.springframework.lang.Nullable; * {@link Runnable Runnables} based on different kinds of triggers. * *

This interface is separate from {@link SchedulingTaskExecutor} since it - * usually represents for a different kind of backend, i.e. a thread pool with + * usually represents a different kind of backend, i.e. a thread pool with * different characteristics and capabilities. Implementations may implement * both interfaces if they can handle both kinds of execution characteristics. * diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index f2d96acf3c2..af477fc083d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.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. @@ -138,8 +138,8 @@ class PropertySourceAnnotationTests { @Test void withUnresolvablePlaceholder() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class)) - .withCauseInstanceOf(IllegalArgumentException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class)) + .withCauseInstanceOf(IllegalArgumentException.class); } @Test @@ -170,8 +170,8 @@ class PropertySourceAnnotationTests { @Test void withEmptyResourceLocations() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class)) - .withCauseInstanceOf(IllegalArgumentException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class)) + .withCauseInstanceOf(IllegalArgumentException.class); } @Test @@ -253,8 +253,8 @@ class PropertySourceAnnotationTests { @Test void withMissingPropertySource() { assertThatExceptionOfType(BeanDefinitionStoreException.class) - .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) - .withCauseInstanceOf(FileNotFoundException.class); + .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) + .withCauseInstanceOf(FileNotFoundException.class); } @Test diff --git a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java index acc1894d327..e8b8ac3ac09 100644 --- a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.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. @@ -102,16 +102,16 @@ class GenericApplicationContextTests { assertThat(context.getBean(String.class)).isSameAs(context.getBean("testBean")); assertThat(context.getAutowireCapableBeanFactory().getBean(String.class)) - .isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean")); + .isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean")); context.close(); assertThatIllegalStateException() - .isThrownBy(() -> context.getBean(String.class)); + .isThrownBy(() -> context.getBean(String.class)); assertThatIllegalStateException() - .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class)); + .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class)); assertThatIllegalStateException() - .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean")); + .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean")); } @Test diff --git a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml index 175408a2cb3..d1a875359d3 100644 --- a/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml +++ b/spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml @@ -3,9 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - @@ -27,39 +24,34 @@ - + - + + + + - + - + - + - + + String - - + Jenny 30 @@ -68,8 +60,7 @@ - + Simple bean, without any collections. 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 bbd1399d5a7..eaafc246343 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-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java index 068a1c45781..1666daf420a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -43,7 +43,7 @@ public interface CallMetaDataProvider { /** * Initialize the database specific management of procedure column meta-data. - * This is only called for databases that are supported. This initialization + *

This is only called for databases that are supported. This initialization * can be turned off by specifying that column meta-data should not be used. * @param databaseMetaData used to retrieve database specific information * @param catalogName name of catalog to use (or {@code null} if none) @@ -55,30 +55,36 @@ public interface CallMetaDataProvider { void initializeWithProcedureColumnMetaData(DatabaseMetaData databaseMetaData, @Nullable String catalogName, @Nullable String schemaName, @Nullable String procedureName) throws SQLException; + /** + * Get the call parameter meta-data that is currently used. + * @return a List of {@link CallParameterMetaData} + */ + List getCallParameterMetaData(); + /** * Provide any modification of the procedure name passed in to match the meta-data currently used. - * This could include altering the case. + *

This could include altering the case. */ @Nullable String procedureNameToUse(@Nullable String procedureName); /** * Provide any modification of the catalog name passed in to match the meta-data currently used. - * This could include altering the case. + *

This could include altering the case. */ @Nullable String catalogNameToUse(@Nullable String catalogName); /** * Provide any modification of the schema name passed in to match the meta-data currently used. - * This could include altering the case. + *

This could include altering the case. */ @Nullable String schemaNameToUse(@Nullable String schemaName); /** * Provide any modification of the catalog name passed in to match the meta-data currently used. - * The returned value will be used for meta-data lookups. This could include altering the case + *

The returned value will be used for meta-data lookups. This could include altering the case * used or providing a base catalog if none is provided. */ @Nullable @@ -86,7 +92,7 @@ public interface CallMetaDataProvider { /** * Provide any modification of the schema name passed in to match the meta-data currently used. - * The returned value will be used for meta-data lookups. This could include altering the case + *

The returned value will be used for meta-data lookups. This could include altering the case * used or providing a base schema if none is provided. */ @Nullable @@ -94,7 +100,7 @@ public interface CallMetaDataProvider { /** * Provide any modification of the column name passed in to match the meta-data currently used. - * This could include altering the case. + *

This could include altering the case. * @param parameterName name of the parameter of column */ @Nullable @@ -102,7 +108,7 @@ public interface CallMetaDataProvider { /** * Create a default out parameter based on the provided meta-data. - * This is used when no explicit parameter declaration has been made. + *

This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter * @param meta meta-data used for this call * @return the configured SqlOutParameter @@ -111,7 +117,7 @@ public interface CallMetaDataProvider { /** * Create a default in/out parameter based on the provided meta-data. - * This is used when no explicit parameter declaration has been made. + *

This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter * @param meta meta-data used for this call * @return the configured SqlInOutParameter @@ -120,7 +126,7 @@ public interface CallMetaDataProvider { /** * Create a default in parameter based on the provided meta-data. - * This is used when no explicit parameter declaration has been made. + *

This is used when no explicit parameter declaration has been made. * @param parameterName the name of the parameter * @param meta meta-data used for this call * @return the configured SqlParameter @@ -142,7 +148,7 @@ public interface CallMetaDataProvider { /** * Does this database support returning ResultSets as ref cursors to be retrieved with - * {@link java.sql.CallableStatement#getObject(int)} for the specified column. + * {@link java.sql.CallableStatement#getObject(int)} for the specified column? */ boolean isRefCursorSupported(); @@ -158,18 +164,12 @@ public interface CallMetaDataProvider { boolean isProcedureColumnMetaDataUsed(); /** - * Should we bypass the return parameter with the specified name. - * This allows the database specific implementation to skip the processing + * Should we bypass the return parameter with the specified name? + *

This allows the database specific implementation to skip the processing * for specific results returned by the database call. */ boolean byPassReturnParameter(String parameterName); - /** - * Get the call parameter meta-data that is currently used. - * @return a List of {@link CallParameterMetaData} - */ - List getCallParameterMetaData(); - /** * Does the database support the use of catalog name in procedure calls? */ diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java index 3822fae85ba..789351ff5ee 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java @@ -168,11 +168,6 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { return identifierNameToUse(parameterName); } - @Override - public boolean byPassReturnParameter(String parameterName) { - return false; - } - @Override public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) { return new SqlOutParameter(parameterName, meta.getSqlType()); @@ -213,6 +208,11 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { return this.procedureColumnMetaDataUsed; } + @Override + public boolean byPassReturnParameter(String parameterName) { + return false; + } + /** * Specify whether the database supports the use of catalog name in procedure calls. diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java index 2bb62d1c3d6..33e6c31d94e 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -75,10 +75,10 @@ public abstract class AbstractDataSource implements DataSource { throw new UnsupportedOperationException("setLogWriter"); } - - //--------------------------------------------------------------------- - // Implementation of JDBC 4.0's Wrapper interface - //--------------------------------------------------------------------- + @Override + public Logger getParentLogger() { + return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + } @Override @SuppressWarnings("unchecked") @@ -95,14 +95,4 @@ public abstract class AbstractDataSource implements DataSource { return iface.isInstance(this); } - - //--------------------------------------------------------------------- - // Implementation of JDBC 4.1's getParentLogger method - //--------------------------------------------------------------------- - - @Override - public Logger getParentLogger() { - return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - } - } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java index 72043978205..a2a39f3aa18 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -105,29 +105,29 @@ public class DelegatingDataSource implements DataSource, InitializingBean { } @Override - public PrintWriter getLogWriter() throws SQLException { - return obtainTargetDataSource().getLogWriter(); + public int getLoginTimeout() throws SQLException { + return obtainTargetDataSource().getLoginTimeout(); } @Override - public void setLogWriter(PrintWriter out) throws SQLException { - obtainTargetDataSource().setLogWriter(out); + public void setLoginTimeout(int seconds) throws SQLException { + obtainTargetDataSource().setLoginTimeout(seconds); } @Override - public int getLoginTimeout() throws SQLException { - return obtainTargetDataSource().getLoginTimeout(); + public PrintWriter getLogWriter() throws SQLException { + return obtainTargetDataSource().getLogWriter(); } @Override - public void setLoginTimeout(int seconds) throws SQLException { - obtainTargetDataSource().setLoginTimeout(seconds); + public void setLogWriter(PrintWriter out) throws SQLException { + obtainTargetDataSource().setLogWriter(out); } - - //--------------------------------------------------------------------- - // Implementation of JDBC 4.0's Wrapper interface - //--------------------------------------------------------------------- + @Override + public Logger getParentLogger() { + return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + } @Override @SuppressWarnings("unchecked") @@ -143,14 +143,4 @@ public class DelegatingDataSource implements DataSource, InitializingBean { return (iface.isInstance(this) || obtainTargetDataSource().isWrapperFor(iface)); } - - //--------------------------------------------------------------------- - // Implementation of JDBC 4.1's getParentLogger method - //--------------------------------------------------------------------- - - @Override - public Logger getParentLogger() { - return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - } - } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java index ec33aba1019..84560a884d0 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.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. @@ -61,7 +61,7 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple /** * Specify the map of target DataSources, with the lookup key as key. - * The mapped value can either be a corresponding {@link javax.sql.DataSource} + *

The mapped value can either be a corresponding {@link javax.sql.DataSource} * instance or a data source name String (to be resolved via a * {@link #setDataSourceLookup DataSourceLookup}). *

The key can be of arbitrary type; this class implements the @@ -213,6 +213,7 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple return (iface.isInstance(this) || determineTargetDataSource().isWrapperFor(iface)); } + /** * Retrieve the current target DataSource. Determines the * {@link #determineCurrentLookupKey() current lookup key}, performs diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 1dbbdaa6055..fd674834ef0 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.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. @@ -355,8 +355,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init (isSuspendingFunction ? (hasSuspendingFlowReturnType ? Flux.class : Mono.class) : method.getReturnType()); ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(reactiveType); if (adapter == null) { - throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type: " + - method.getReturnType()); + throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type [" + + method.getReturnType() + "] with specified transaction manager: " + tm); } return new ReactiveTransactionSupport(adapter); }); diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java index 866b2422456..e4840e92152 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.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. @@ -115,13 +115,11 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ // --------------------------------------------------------------------- @Override - public void onComplete(AsyncEvent event) throws IOException { - this.asyncContext = null; - this.asyncCompleted.set(true); + public void onStartAsync(AsyncEvent event) throws IOException { } @Override - public void onStartAsync(AsyncEvent event) throws IOException { + public void onTimeout(AsyncEvent event) throws IOException { } @Override @@ -129,7 +127,9 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ } @Override - public void onTimeout(AsyncEvent event) throws IOException { + public void onComplete(AsyncEvent event) throws IOException { + this.asyncContext = null; + this.asyncCompleted.set(true); } } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java index 0cedc4dd1b7..b18f1f1f42f 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.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. @@ -276,6 +276,11 @@ public class ServletHttpHandlerAdapter implements Servlet { this.logPrefix = logPrefix; } + @Override + public void onStartAsync(AsyncEvent event) { + // no-op + } + @Override public void onTimeout(AsyncEvent event) { // Should never happen since we call asyncContext.setTimeout(-1) @@ -342,11 +347,6 @@ public class ServletHttpHandlerAdapter implements Servlet { } }); } - - @Override - public void onStartAsync(AsyncEvent event) { - // no-op - } } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java index 06e4721cb97..7d15d392f02 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.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. @@ -128,7 +128,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements @Override public void dispatch() { - Assert.notNull(this.asyncContext, "Cannot dispatch without an AsyncContext"); + Assert.state(this.asyncContext != null, "Cannot dispatch without an AsyncContext"); this.asyncContext.dispatch(); } @@ -142,13 +142,13 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements } @Override - public void onError(AsyncEvent event) throws IOException { - this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable())); + public void onTimeout(AsyncEvent event) throws IOException { + this.timeoutHandlers.forEach(Runnable::run); } @Override - public void onTimeout(AsyncEvent event) throws IOException { - this.timeoutHandlers.forEach(Runnable::run); + public void onError(AsyncEvent event) throws IOException { + this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable())); } @Override 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 df8f9a58893..19fb334ba8f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 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. @@ -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(HttpURLConnection.class); 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 3082fe0c31f..b92326e9e40 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();