Browse Source

Polishing

pull/30123/head
Sam Brannen 2 years ago
parent
commit
b617e16d8d
  1. 3
      spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java
  2. 2
      spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java
  3. 5
      spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java
  4. 32
      spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java
  5. 1
      spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java
  6. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  7. 2
      spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java
  8. 5
      spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java
  9. 2
      spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java
  10. 2
      spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java

3
spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java

@ -61,8 +61,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
private ConfigurableBeanFactory beanFactory; private ConfigurableBeanFactory beanFactory;
/** Internally used DefaultListableBeanFactory instances, keyed by bean name. */ /** Internally used DefaultListableBeanFactory instances, keyed by bean name. */
private final Map<String, DefaultListableBeanFactory> internalBeanFactories = private final Map<String, DefaultListableBeanFactory> internalBeanFactories = new HashMap<>();
new HashMap<>();
@Override @Override

2
spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java

@ -181,7 +181,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
} }
/** /**
* Set whether the call should bock when the pool is exhausted. * Set whether the call should block when the pool is exhausted.
*/ */
public void setBlockWhenExhausted(boolean blockWhenExhausted) { public void setBlockWhenExhausted(boolean blockWhenExhausted) {
this.blockWhenExhausted = blockWhenExhausted; this.blockWhenExhausted = blockWhenExhausted;

5
spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java vendored

@ -17,8 +17,8 @@
package org.springframework.cache.aspectj; package org.springframework.cache.aspectj;
/** /**
* Utility to trick the compiler to throw a valid checked * Utility to trick the compiler to throw valid checked exceptions masked as
* exceptions within the interceptor. * runtime exceptions within the interceptor.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@ -36,4 +36,5 @@ final class AnyThrow {
private static <E extends Throwable> void throwAny(Throwable e) throws E { private static <E extends Throwable> void throwAny(Throwable e) throws E {
throw (E) e; throw (E) e;
} }
} }

32
spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java

@ -16,9 +16,9 @@
package org.springframework.beans.factory.groovy; package org.springframework.beans.factory.groovy;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
import groovy.lang.GroovyObjectSupport; import groovy.lang.GroovyObjectSupport;
@ -51,18 +51,8 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
private static final String DESTROY_METHOD = "destroyMethod"; private static final String DESTROY_METHOD = "destroyMethod";
private static final String SINGLETON = "singleton"; private static final String SINGLETON = "singleton";
private static final List<String> dynamicProperties = new ArrayList<>(8); private static final Set<String> dynamicProperties = Set.of(PARENT, AUTOWIRE, CONSTRUCTOR_ARGS,
FACTORY_BEAN, FACTORY_METHOD, INIT_METHOD, DESTROY_METHOD, SINGLETON);
static {
dynamicProperties.add(PARENT);
dynamicProperties.add(AUTOWIRE);
dynamicProperties.add(CONSTRUCTOR_ARGS);
dynamicProperties.add(FACTORY_BEAN);
dynamicProperties.add(FACTORY_METHOD);
dynamicProperties.add(INIT_METHOD);
dynamicProperties.add(DESTROY_METHOD);
dynamicProperties.add(SINGLETON);
}
private String beanName; private String beanName;
@ -98,11 +88,11 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
return this.beanName; return this.beanName;
} }
public void setBeanDefinition(AbstractBeanDefinition definition) { void setBeanDefinition(AbstractBeanDefinition definition) {
this.definition = definition; this.definition = definition;
} }
public AbstractBeanDefinition getBeanDefinition() { AbstractBeanDefinition getBeanDefinition() {
if (this.definition == null) { if (this.definition == null) {
this.definition = createBeanDefinition(); this.definition = createBeanDefinition();
} }
@ -126,19 +116,17 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
return bd; return bd;
} }
public void setBeanDefinitionHolder(BeanDefinitionHolder holder) { void setBeanDefinitionHolder(BeanDefinitionHolder holder) {
this.definition = (AbstractBeanDefinition) holder.getBeanDefinition(); this.definition = (AbstractBeanDefinition) holder.getBeanDefinition();
this.beanName = holder.getBeanName(); this.beanName = holder.getBeanName();
} }
public BeanDefinitionHolder getBeanDefinitionHolder() { BeanDefinitionHolder getBeanDefinitionHolder() {
return new BeanDefinitionHolder(getBeanDefinition(), getBeanName()); return new BeanDefinitionHolder(getBeanDefinition(), getBeanName());
} }
public void setParent(Object obj) { void setParent(Object obj) {
if (obj == null) { Assert.notNull(obj, "Parent bean cannot be set to a null runtime bean reference.");
throw new IllegalArgumentException("Parent bean cannot be set to a null runtime bean reference!");
}
if (obj instanceof String name) { if (obj instanceof String name) {
this.parentName = name; this.parentName = name;
} }
@ -152,7 +140,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
getBeanDefinition().setAbstract(false); getBeanDefinition().setAbstract(false);
} }
public GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) { GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) {
if (propertyValue instanceof GroovyBeanDefinitionWrapper wrapper) { if (propertyValue instanceof GroovyBeanDefinitionWrapper wrapper) {
propertyValue = wrapper.getBeanDefinition(); propertyValue = wrapper.getBeanDefinition();
} }

1
spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java

@ -88,6 +88,7 @@ class GroovyDynamicElementReader extends GroovyObjectSupport {
String myNamespace = this.rootNamespace; String myNamespace = this.rootNamespace;
Map<String, String> myNamespaces = this.xmlNamespaces; Map<String, String> myNamespaces = this.xmlNamespaces;
@SuppressWarnings("serial")
Closure<Object> callable = new Closure<>(this) { Closure<Object> callable = new Closure<>(this) {
@Override @Override
public Object call(Object... arguments) { public Object call(Object... arguments) {

2
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

@ -1732,7 +1732,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (beanInstance != null) { if (beanInstance != null) {
Integer candidatePriority = getPriority(beanInstance); Integer candidatePriority = getPriority(beanInstance);
if (candidatePriority != null) { if (candidatePriority != null) {
if (highestPriorityBeanName != null) { if (highestPriority != null) {
if (candidatePriority.equals(highestPriority)) { if (candidatePriority.equals(highestPriority)) {
throw new NoUniqueBeanDefinitionException(requiredType, candidates.size(), throw new NoUniqueBeanDefinitionException(requiredType, candidates.size(),
"Multiple beans found with the same priority ('" + highestPriority + "Multiple beans found with the same priority ('" + highestPriority +

2
spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java

@ -61,7 +61,7 @@ public class SimpleTimeZoneAwareLocaleContext extends SimpleLocaleContext implem
@Override @Override
public String toString() { public String toString() {
return super.toString() + " " + (this.timeZone != null ? this.timeZone.toString() : "-"); return super.toString() + " " + (this.timeZone != null ? this.timeZone : "-");
} }
} }

5
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java

@ -80,7 +80,7 @@ public class DeferredResult<T> {
* Create a DeferredResult. * Create a DeferredResult.
*/ */
public DeferredResult() { public DeferredResult() {
this(null, () -> RESULT_NONE); this(null);
} }
/** /**
@ -101,8 +101,7 @@ public class DeferredResult<T> {
* @param timeoutResult the result to use * @param timeoutResult the result to use
*/ */
public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) { public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) {
this.timeoutValue = timeoutValue; this(timeoutValue, () -> timeoutResult);
this.timeoutResult = () -> timeoutResult;
} }
/** /**

2
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java

@ -78,7 +78,7 @@ public interface DeferredResultProcessingInterceptor {
* timeout result. * timeout result.
* @param request the current request * @param request the current request
* @param deferredResult the DeferredResult for the current request * @param deferredResult the DeferredResult for the current request
* @param concurrentResult the result to which the {@code DeferredResult} * @param concurrentResult the concurrent result
* @throws Exception in case of errors * @throws Exception in case of errors
*/ */
default <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, default <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult,

2
spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java

@ -57,7 +57,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
private final List<ProduceMediaTypeExpression> mediaTypeAllList = private final List<ProduceMediaTypeExpression> mediaTypeAllList =
Collections.singletonList(new ProduceMediaTypeExpression(MediaType.ALL_VALUE)); List.of(new ProduceMediaTypeExpression(MediaType.ALL_VALUE));
private final List<ProduceMediaTypeExpression> expressions; private final List<ProduceMediaTypeExpression> expressions;

Loading…
Cancel
Save