Browse Source

Polishing

pull/32173/head
Juergen Hoeller 2 years ago
parent
commit
b2bdc7de30
  1. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  3. 6
      spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java
  4. 2
      spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java
  5. 6
      spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java
  6. 4
      spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java
  7. 21
      spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
  8. 2
      spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
  9. 4
      spring-context/src/main/java/org/springframework/scheduling/TaskScheduler.java
  10. 14
      spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java
  11. 10
      spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java
  12. 33
      spring-context/src/test/resources/org/springframework/beans/factory/xml/XmlBeanFactoryTests-delegationOverrides.xml
  13. 2
      spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java
  14. 40
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProvider.java
  15. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java
  16. 20
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java
  17. 36
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java
  18. 5
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java
  19. 6
      spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java
  20. 12
      spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java
  21. 12
      spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java
  22. 12
      spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java
  23. 7
      spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java
  24. 4
      spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java

10
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. * Supports autowiring constructors, properties by name, and properties by type.
* *
* <p>The main template method to be implemented by subclasses is * <p>The main template method to be implemented by subclasses is
* {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, * {@link #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)}, used for
* used for autowiring by type. In case of a factory which is capable of searching * autowiring. In case of a {@link org.springframework.beans.factory.ListableBeanFactory}
* its bean definitions, matching beans will typically be implemented through such * which is capable of searching its bean definitions, matching beans will typically be
* a search. For other factory styles, simplified matching algorithms can be implemented. * implemented through such a search. Otherwise, simplified matching can be implemented.
* *
* <p>Note that this class does <i>not</i> assume or implement bean definition * <p>Note that this class does <i>not</i> assume or implement bean definition
* registry capabilities. See {@link DefaultListableBeanFactory} for an implementation * registry capabilities. See {@link DefaultListableBeanFactory} for an implementation
@ -675,7 +675,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Apply SmartInstantiationAwareBeanPostProcessors to predict the // Apply SmartInstantiationAwareBeanPostProcessors to predict the
// eventual type after a before-instantiation shortcut. // eventual type after a before-instantiation shortcut.
if (targetType != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) { 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) { for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache().smartInstantiationAware) {
Class<?> predicted = bp.predictBeanType(targetType, beanName); Class<?> predicted = bp.predictBeanType(targetType, beanName);
if (predicted != null && if (predicted != null &&

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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); aliases.add(fullBeanName);
} }
String[] retrievedAliases = super.getAliases(beanName); String[] retrievedAliases = super.getAliases(beanName);
String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : ""; String prefix = (factoryPrefix ? FACTORY_BEAN_PREFIX : "");
for (String retrievedAlias : retrievedAliases) { for (String retrievedAlias : retrievedAliases) {
String alias = prefix + retrievedAlias; String alias = prefix + retrievedAlias;
if (!alias.equals(name)) { if (!alias.equals(name)) {

6
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. * "autowire constructor" (with constructor arguments by type) behavior.
* Also applied if explicit constructor argument values are specified, * Also applied if explicit constructor argument values are specified.
* matching all remaining arguments with beans from the bean factory.
* <p>This corresponds to constructor injection: In this mode, a Spring
* bean factory is able to host components that expect constructor-based
* dependency resolution.
* @param beanName the name of the bean * @param beanName the name of the bean
* @param mbd the merged bean definition for the bean * @param mbd the merged bean definition for the bean
* @param chosenCtors chosen candidate constructors (or {@code null} if none) * @param chosenCtors chosen candidate constructors (or {@code null} if none)

2
spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java vendored

@ -236,7 +236,7 @@ public class CaffeineCacheManager implements CacheManager {
* Build a common {@link CaffeineCache} instance for the specified cache name, * Build a common {@link CaffeineCache} instance for the specified cache name,
* using the common Caffeine configuration specified on this cache manager. * using the common Caffeine configuration specified on this cache manager.
* <p>Delegates to {@link #adaptCaffeineCache} as the adaptation method to * <p>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. * passing in a freshly built native Caffeine Cache instance.
* @param name the name of the cache * @param name the name of the cache
* @return the Spring CaffeineCache adapter (or a decorator thereof) * @return the Spring CaffeineCache adapter (or a decorator thereof)

6
spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java vendored

@ -547,10 +547,10 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
} }
/** /**
* Collect the {@link CachePutRequest} for all {@link CacheOperation} using * Collect a {@link CachePutRequest} for every {@link CacheOperation}
* the specified result value. * using the specified result value.
* @param contexts the contexts to handle * @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 * @param putRequests the collection to update
*/ */
private void collectPutRequests(Collection<CacheOperationContext> contexts, private void collectPutRequests(Collection<CacheOperationContext> contexts,

4
spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationInvoker.java vendored

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Abstract the invocation of a cache operation.
* *
* <p>Does not provide a way to transmit checked exceptions but * <p>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. * exception that was thrown by the underlying invocation.
* Callers are expected to handle this issue type specifically. * Callers are expected to handle this issue type specifically.
* *

21
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; import org.springframework.util.ClassUtils;
/** /**
* A component provider that provides candidate components from a base package. Can * A component provider that scans for candidate components starting from a
* use {@link CandidateComponentsIndex the index} if it is available of scans the * specified base package. Can use the {@linkplain CandidateComponentsIndex component
* classpath otherwise. Candidate components are identified by applying exclude and * index}, if it is available, and scans the classpath otherwise.
* include filters. {@link AnnotationTypeFilter}, {@link AssignableTypeFilter} include *
* filters on an annotation/superclass that are annotated with {@link Indexed} are * <p>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 * supported: if any other include filter is specified, the index is ignored and
* classpath scanning is used instead. * 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 * @param basePackage the package to check for annotated classes
* @return a corresponding Set of autodetected bean definitions * @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 * @return {@code true} if the index is available and the configuration of this
* instance is supported by it, {@code false} otherwise * instance is supported by it, {@code false} otherwise
* @since 5.0 * @since 5.0
@ -454,8 +456,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
} }
} }
catch (Throwable ex) { catch (Throwable ex) {
throw new BeanDefinitionStoreException( throw new BeanDefinitionStoreException("Failed to read candidate component class: " + resource, ex);
"Failed to read candidate component class: " + resource, ex);
} }
} }
} }

2
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. */ /** Flag that indicates whether this context has been closed already. */
private final AtomicBoolean closed = new AtomicBoolean(); 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(); private final Object startupShutdownMonitor = new Object();
/** Reference to the JVM shutdown hook, if registered. */ /** Reference to the JVM shutdown hook, if registered. */

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * {@link Runnable Runnables} based on different kinds of triggers.
* *
* <p>This interface is separate from {@link SchedulingTaskExecutor} since it * <p>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 * different characteristics and capabilities. Implementations may implement
* both interfaces if they can handle both kinds of execution characteristics. * both interfaces if they can handle both kinds of execution characteristics.
* *

14
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -138,8 +138,8 @@ class PropertySourceAnnotationTests {
@Test @Test
void withUnresolvablePlaceholder() { void withUnresolvablePlaceholder() {
assertThatExceptionOfType(BeanDefinitionStoreException.class) assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class)) .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithUnresolvablePlaceholder.class))
.withCauseInstanceOf(IllegalArgumentException.class); .withCauseInstanceOf(IllegalArgumentException.class);
} }
@Test @Test
@ -170,8 +170,8 @@ class PropertySourceAnnotationTests {
@Test @Test
void withEmptyResourceLocations() { void withEmptyResourceLocations() {
assertThatExceptionOfType(BeanDefinitionStoreException.class) assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class)) .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithEmptyResourceLocations.class))
.withCauseInstanceOf(IllegalArgumentException.class); .withCauseInstanceOf(IllegalArgumentException.class);
} }
@Test @Test
@ -253,8 +253,8 @@ class PropertySourceAnnotationTests {
@Test @Test
void withMissingPropertySource() { void withMissingPropertySource() {
assertThatExceptionOfType(BeanDefinitionStoreException.class) assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) .isThrownBy(() -> new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class))
.withCauseInstanceOf(FileNotFoundException.class); .withCauseInstanceOf(FileNotFoundException.class);
} }
@Test @Test

10
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.getBean(String.class)).isSameAs(context.getBean("testBean"));
assertThat(context.getAutowireCapableBeanFactory().getBean(String.class)) assertThat(context.getAutowireCapableBeanFactory().getBean(String.class))
.isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean")); .isSameAs(context.getAutowireCapableBeanFactory().getBean("testBean"));
context.close(); context.close();
assertThatIllegalStateException() assertThatIllegalStateException()
.isThrownBy(() -> context.getBean(String.class)); .isThrownBy(() -> context.getBean(String.class));
assertThatIllegalStateException() assertThatIllegalStateException()
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class)); .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean(String.class));
assertThatIllegalStateException() assertThatIllegalStateException()
.isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean")); .isThrownBy(() -> context.getAutowireCapableBeanFactory().getBean("testBean"));
} }
@Test @Test

33
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" 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"> xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!--
Not yet in use: illustration of possible approach
-->
<bean id="overrideOneMethod" class="org.springframework.beans.factory.xml.OverrideOneMethod"> <bean id="overrideOneMethod" class="org.springframework.beans.factory.xml.OverrideOneMethod">
<lookup-method name="getPrototypeDependency" bean="jenny"/> <lookup-method name="getPrototypeDependency" bean="jenny"/>
@ -27,39 +24,34 @@
<lookup-method name="protectedOverrideSingleton" bean="david"/> <lookup-method name="protectedOverrideSingleton" bean="david"/>
<!-- <!-- This method is not overloaded, so we don't need to specify any arg types -->
This method is not overloaded, so we don't need to specify any arg types
-->
<replaced-method name="doSomething" replacer="doSomethingReplacer"/> <replaced-method name="doSomething" replacer="doSomethingReplacer"/>
</bean> </bean>
<bean id="replaceVoidMethod" parent="someParent" <bean id="replaceVoidMethod" parent="someParent" class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass"/>
class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass">
<bean id="replaceEchoMethod" class="org.springframework.beans.factory.xml.EchoService">
<!-- This method is not overloaded, so we don't need to specify any arg types -->
<replaced-method name="echo" replacer="reverseArrayReplacer" />
</bean> </bean>
<bean id="reverseReplacer" <bean id="reverseReplacer" class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>
class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>
<bean id="fixedReplacer" <bean id="reverseArrayReplacer" class="org.springframework.beans.factory.xml.ReverseArrayMethodReplacer"/>
class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>
<bean id="doSomethingReplacer" <bean id="fixedReplacer" class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>
class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>
<bean id="serializableReplacer" <bean id="doSomethingReplacer" class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>
class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
<bean id="serializableReplacer" class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
<!-- Arbitrary method replacer --> <!-- Arbitrary method replacer -->
<replaced-method name="replaceMe" replacer="reverseReplacer"> <replaced-method name="replaceMe" replacer="reverseReplacer">
<arg-type>String</arg-type> <arg-type>String</arg-type>
</replaced-method> </replaced-method>
</bean> </bean>
<bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean" <bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype">
scope="prototype">
<property name="name"><value>Jenny</value></property> <property name="name"><value>Jenny</value></property>
<property name="age"><value>30</value></property> <property name="age"><value>30</value></property>
<property name="spouse"> <property name="spouse">
@ -68,8 +60,7 @@
</property> </property>
</bean> </bean>
<bean id="david" class="org.springframework.beans.testfixture.beans.TestBean" <bean id="david" class="org.springframework.beans.testfixture.beans.TestBean" scope="singleton">
scope="singleton">
<description> <description>
Simple bean, without any collections. Simple bean, without any collections.
</description> </description>

2
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. * Return the source of the type, or {@code null} if not known.
* <p>The default implementations returns {@code null}. * <p>The default implementation returns {@code null}.
*/ */
@Nullable @Nullable
default Object getSource() { default Object getSource() {

40
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Initialize the database specific management of procedure column meta-data.
* This is only called for databases that are supported. This initialization * <p>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. * can be turned off by specifying that column meta-data should not be used.
* @param databaseMetaData used to retrieve database specific information * @param databaseMetaData used to retrieve database specific information
* @param catalogName name of catalog to use (or {@code null} if none) * @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, void initializeWithProcedureColumnMetaData(DatabaseMetaData databaseMetaData, @Nullable String catalogName,
@Nullable String schemaName, @Nullable String procedureName) throws SQLException; @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<CallParameterMetaData> getCallParameterMetaData();
/** /**
* Provide any modification of the procedure name passed in to match the meta-data currently used. * Provide any modification of the procedure name passed in to match the meta-data currently used.
* This could include altering the case. * <p>This could include altering the case.
*/ */
@Nullable @Nullable
String procedureNameToUse(@Nullable String procedureName); String procedureNameToUse(@Nullable String procedureName);
/** /**
* Provide any modification of the catalog name passed in to match the meta-data currently used. * Provide any modification of the catalog name passed in to match the meta-data currently used.
* This could include altering the case. * <p>This could include altering the case.
*/ */
@Nullable @Nullable
String catalogNameToUse(@Nullable String catalogName); String catalogNameToUse(@Nullable String catalogName);
/** /**
* Provide any modification of the schema name passed in to match the meta-data currently used. * Provide any modification of the schema name passed in to match the meta-data currently used.
* This could include altering the case. * <p>This could include altering the case.
*/ */
@Nullable @Nullable
String schemaNameToUse(@Nullable String schemaName); String schemaNameToUse(@Nullable String schemaName);
/** /**
* Provide any modification of the catalog name passed in to match the meta-data currently used. * 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 * <p>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. * used or providing a base catalog if none is provided.
*/ */
@Nullable @Nullable
@ -86,7 +92,7 @@ public interface CallMetaDataProvider {
/** /**
* Provide any modification of the schema name passed in to match the meta-data currently used. * 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 * <p>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. * used or providing a base schema if none is provided.
*/ */
@Nullable @Nullable
@ -94,7 +100,7 @@ public interface CallMetaDataProvider {
/** /**
* Provide any modification of the column name passed in to match the meta-data currently used. * Provide any modification of the column name passed in to match the meta-data currently used.
* This could include altering the case. * <p>This could include altering the case.
* @param parameterName name of the parameter of column * @param parameterName name of the parameter of column
*/ */
@Nullable @Nullable
@ -102,7 +108,7 @@ public interface CallMetaDataProvider {
/** /**
* Create a default out parameter based on the provided meta-data. * Create a default out parameter based on the provided meta-data.
* This is used when no explicit parameter declaration has been made. * <p>This is used when no explicit parameter declaration has been made.
* @param parameterName the name of the parameter * @param parameterName the name of the parameter
* @param meta meta-data used for this call * @param meta meta-data used for this call
* @return the configured SqlOutParameter * @return the configured SqlOutParameter
@ -111,7 +117,7 @@ public interface CallMetaDataProvider {
/** /**
* Create a default in/out parameter based on the provided meta-data. * Create a default in/out parameter based on the provided meta-data.
* This is used when no explicit parameter declaration has been made. * <p>This is used when no explicit parameter declaration has been made.
* @param parameterName the name of the parameter * @param parameterName the name of the parameter
* @param meta meta-data used for this call * @param meta meta-data used for this call
* @return the configured SqlInOutParameter * @return the configured SqlInOutParameter
@ -120,7 +126,7 @@ public interface CallMetaDataProvider {
/** /**
* Create a default in parameter based on the provided meta-data. * Create a default in parameter based on the provided meta-data.
* This is used when no explicit parameter declaration has been made. * <p>This is used when no explicit parameter declaration has been made.
* @param parameterName the name of the parameter * @param parameterName the name of the parameter
* @param meta meta-data used for this call * @param meta meta-data used for this call
* @return the configured SqlParameter * @return the configured SqlParameter
@ -142,7 +148,7 @@ public interface CallMetaDataProvider {
/** /**
* Does this database support returning ResultSets as ref cursors to be retrieved with * 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(); boolean isRefCursorSupported();
@ -158,18 +164,12 @@ public interface CallMetaDataProvider {
boolean isProcedureColumnMetaDataUsed(); boolean isProcedureColumnMetaDataUsed();
/** /**
* Should we bypass the return parameter with the specified name. * Should we bypass the return parameter with the specified name?
* This allows the database specific implementation to skip the processing * <p>This allows the database specific implementation to skip the processing
* for specific results returned by the database call. * for specific results returned by the database call.
*/ */
boolean byPassReturnParameter(String parameterName); boolean byPassReturnParameter(String parameterName);
/**
* Get the call parameter meta-data that is currently used.
* @return a List of {@link CallParameterMetaData}
*/
List<CallParameterMetaData> getCallParameterMetaData();
/** /**
* Does the database support the use of catalog name in procedure calls? * Does the database support the use of catalog name in procedure calls?
*/ */

10
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java

@ -168,11 +168,6 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
return identifierNameToUse(parameterName); return identifierNameToUse(parameterName);
} }
@Override
public boolean byPassReturnParameter(String parameterName) {
return false;
}
@Override @Override
public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) { public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) {
return new SqlOutParameter(parameterName, meta.getSqlType()); return new SqlOutParameter(parameterName, meta.getSqlType());
@ -213,6 +208,11 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
return this.procedureColumnMetaDataUsed; return this.procedureColumnMetaDataUsed;
} }
@Override
public boolean byPassReturnParameter(String parameterName) {
return false;
}
/** /**
* Specify whether the database supports the use of catalog name in procedure calls. * Specify whether the database supports the use of catalog name in procedure calls.

20
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); throw new UnsupportedOperationException("setLogWriter");
} }
@Override
//--------------------------------------------------------------------- public Logger getParentLogger() {
// Implementation of JDBC 4.0's Wrapper interface return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
//--------------------------------------------------------------------- }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -95,14 +95,4 @@ public abstract class AbstractDataSource implements DataSource {
return iface.isInstance(this); return iface.isInstance(this);
} }
//---------------------------------------------------------------------
// Implementation of JDBC 4.1's getParentLogger method
//---------------------------------------------------------------------
@Override
public Logger getParentLogger() {
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
}
} }

36
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 @Override
public PrintWriter getLogWriter() throws SQLException { public int getLoginTimeout() throws SQLException {
return obtainTargetDataSource().getLogWriter(); return obtainTargetDataSource().getLoginTimeout();
} }
@Override @Override
public void setLogWriter(PrintWriter out) throws SQLException { public void setLoginTimeout(int seconds) throws SQLException {
obtainTargetDataSource().setLogWriter(out); obtainTargetDataSource().setLoginTimeout(seconds);
} }
@Override @Override
public int getLoginTimeout() throws SQLException { public PrintWriter getLogWriter() throws SQLException {
return obtainTargetDataSource().getLoginTimeout(); return obtainTargetDataSource().getLogWriter();
} }
@Override @Override
public void setLoginTimeout(int seconds) throws SQLException { public void setLogWriter(PrintWriter out) throws SQLException {
obtainTargetDataSource().setLoginTimeout(seconds); obtainTargetDataSource().setLogWriter(out);
} }
@Override
//--------------------------------------------------------------------- public Logger getParentLogger() {
// Implementation of JDBC 4.0's Wrapper interface return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
//--------------------------------------------------------------------- }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -143,14 +143,4 @@ public class DelegatingDataSource implements DataSource, InitializingBean {
return (iface.isInstance(this) || obtainTargetDataSource().isWrapperFor(iface)); 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);
}
} }

5
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Specify the map of target DataSources, with the lookup key as key.
* The mapped value can either be a corresponding {@link javax.sql.DataSource} * <p>The mapped value can either be a corresponding {@link javax.sql.DataSource}
* instance or a data source name String (to be resolved via a * instance or a data source name String (to be resolved via a
* {@link #setDataSourceLookup DataSourceLookup}). * {@link #setDataSourceLookup DataSourceLookup}).
* <p>The key can be of arbitrary type; this class implements the * <p>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)); return (iface.isInstance(this) || determineTargetDataSource().isWrapperFor(iface));
} }
/** /**
* Retrieve the current target DataSource. Determines the * Retrieve the current target DataSource. Determines the
* {@link #determineCurrentLookupKey() current lookup key}, performs * {@link #determineCurrentLookupKey() current lookup key}, performs

6
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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()); (isSuspendingFunction ? (hasSuspendingFlowReturnType ? Flux.class : Mono.class) : method.getReturnType());
ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(reactiveType); ReactiveAdapter adapter = this.reactiveAdapterRegistry.getAdapter(reactiveType);
if (adapter == null) { if (adapter == null) {
throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type: " + throw new IllegalStateException("Cannot apply reactive transaction to non-reactive return type [" +
method.getReturnType()); method.getReturnType() + "] with specified transaction manager: " + tm);
} }
return new ReactiveTransactionSupport(adapter); return new ReactiveTransactionSupport(adapter);
}); });

12
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -115,13 +115,11 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@Override @Override
public void onComplete(AsyncEvent event) throws IOException { public void onStartAsync(AsyncEvent event) throws IOException {
this.asyncContext = null;
this.asyncCompleted.set(true);
} }
@Override @Override
public void onStartAsync(AsyncEvent event) throws IOException { public void onTimeout(AsyncEvent event) throws IOException {
} }
@Override @Override
@ -129,7 +127,9 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
} }
@Override @Override
public void onTimeout(AsyncEvent event) throws IOException { public void onComplete(AsyncEvent event) throws IOException {
this.asyncContext = null;
this.asyncCompleted.set(true);
} }
} }

12
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; this.logPrefix = logPrefix;
} }
@Override
public void onStartAsync(AsyncEvent event) {
// no-op
}
@Override @Override
public void onTimeout(AsyncEvent event) { public void onTimeout(AsyncEvent event) {
// Should never happen since we call asyncContext.setTimeout(-1) // 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
}
} }

12
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 @Override
public void dispatch() { 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(); this.asyncContext.dispatch();
} }
@ -142,13 +142,13 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
} }
@Override @Override
public void onError(AsyncEvent event) throws IOException { public void onTimeout(AsyncEvent event) throws IOException {
this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable())); this.timeoutHandlers.forEach(Runnable::run);
} }
@Override @Override
public void onTimeout(AsyncEvent event) throws IOException { public void onError(AsyncEvent event) throws IOException {
this.timeoutHandlers.forEach(Runnable::run); this.exceptionHandlers.forEach(consumer -> consumer.accept(event.getThrowable()));
} }
@Override @Override

7
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { public class SimpleClientHttpRequestFactoryTests {
@Test // SPR-13225
@Test // SPR-13225
public void headerWithNullValue() { public void headerWithNullValue() {
HttpURLConnection urlConnection = mock(HttpURLConnection.class); HttpURLConnection urlConnection = mock(HttpURLConnection.class);
given(urlConnection.getRequestMethod()).willReturn("GET"); given(urlConnection.getRequestMethod()).willReturn("GET");
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("foo", null); headers.set("foo", null);
SimpleBufferingClientHttpRequest.addHeaders(urlConnection, headers); SimpleBufferingClientHttpRequest.addHeaders(urlConnection, headers);
verify(urlConnection, times(1)).addRequestProperty("foo", ""); verify(urlConnection, times(1)).addRequestProperty("foo", "");
} }

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ReactiveHttpOutputMessage; 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.assertThat;
import static org.assertj.core.api.Assertions.fail; import static org.assertj.core.api.Assertions.fail;
@ -173,7 +172,6 @@ public class ClientHttpConnectorTests {
.verify(); .verify();
} }
@NonNull
private Buffer randomBody(int size) { private Buffer randomBody(int size) {
Buffer responseBody = new Buffer(); Buffer responseBody = new Buffer();
Random rnd = new Random(); Random rnd = new Random();

Loading…
Cancel
Save