Polishing

This commit is contained in:
Juergen Hoeller 2019-09-25 12:14:48 +02:00
parent 0519a2ff3c
commit bb6f9bb6d4
12 changed files with 33 additions and 35 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -327,10 +327,11 @@ class CglibAopProxy implements AopProxy, Serializable {
// TODO: small memory optimization here (can skip creation for methods with no advice) // TODO: small memory optimization here (can skip creation for methods with no advice)
for (int x = 0; x < methods.length; x++) { for (int x = 0; x < methods.length; x++) {
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(methods[x], rootClass); Method method = methods[x];
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, rootClass);
fixedCallbacks[x] = new FixedChainStaticTargetInterceptor( fixedCallbacks[x] = new FixedChainStaticTargetInterceptor(
chain, this.advised.getTargetSource().getTarget(), this.advised.getTargetClass()); chain, this.advised.getTargetSource().getTarget(), this.advised.getTargetClass());
this.fixedInterceptorMap.put(methods[x].toString(), x); this.fixedInterceptorMap.put(methods.toString(), x);
} }
// Now copy both the callbacks from mainCallbacks // Now copy both the callbacks from mainCallbacks
@ -633,8 +634,8 @@ class CglibAopProxy implements AopProxy, Serializable {
@Override @Override
@Nullable @Nullable
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args, MethodInvocation invocation = new CglibMethodInvocation(
this.targetClass, this.adviceChain, methodProxy); proxy, this.target, method, args, this.targetClass, this.adviceChain, methodProxy);
// If we get here, we need to create a MethodInvocation. // If we get here, we need to create a MethodInvocation.
Object retVal = invocation.proceed(); Object retVal = invocation.proceed();
retVal = processReturnType(proxy, this.target, method, retVal); retVal = processReturnType(proxy, this.target, method, retVal);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -68,7 +68,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
protected final Method method; protected final Method method;
protected Object[] arguments = new Object[0]; protected Object[] arguments;
@Nullable @Nullable
private final Class<?> targetClass; private final Class<?> targetClass;

View File

@ -39,7 +39,7 @@ import org.springframework.util.ClassUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 11.11.2003 * @since 11.11.2003
*/ */
@SuppressWarnings({"serial" }) @SuppressWarnings("serial")
public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable { public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable {
private final Advice advice; private final Advice advice;

View File

@ -26,6 +26,7 @@ import org.springframework.util.PatternMatchUtils;
/** /**
* Pointcut bean for simple method name matches, as an alternative to regexp patterns. * Pointcut bean for simple method name matches, as an alternative to regexp patterns.
*
* <p>Does not handle overloaded methods: all methods with a given name will be eligible. * <p>Does not handle overloaded methods: all methods with a given name will be eligible.
* *
* @author Juergen Hoeller * @author Juergen Hoeller

View File

@ -26,6 +26,7 @@ import org.springframework.util.Assert;
/** /**
* Pointcut constants for matching getters and setters, * Pointcut constants for matching getters and setters,
* and static methods useful for manipulating and evaluating pointcuts. * and static methods useful for manipulating and evaluating pointcuts.
*
* <p>These methods are particularly useful for composing pointcuts * <p>These methods are particularly useful for composing pointcuts
* using the union and intersection methods. * using the union and intersection methods.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -139,9 +139,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
/** /**
* Create a new AutowiredAnnotationBeanPostProcessor * Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's
* for Spring's standard {@link Autowired} annotation. * standard {@link Autowired @Autowired} annotation.
* <p>Also supports JSR-330's {@link javax.inject.Inject} annotation, if available. * <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation,
* if available.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public AutowiredAnnotationBeanPostProcessor() { public AutowiredAnnotationBeanPostProcessor() {
@ -242,7 +243,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final String beanName) public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final String beanName)
throws BeanCreationException { throws BeanCreationException {
// Let's check for lookup methods here.. // Let's check for lookup methods here...
if (!this.lookupMethodsChecked.contains(beanName)) { if (!this.lookupMethodsChecked.contains(beanName)) {
try { try {
ReflectionUtils.doWithMethods(beanClass, method -> { ReflectionUtils.doWithMethods(beanClass, method -> {
@ -251,7 +252,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
Assert.state(this.beanFactory != null, "No BeanFactory available"); Assert.state(this.beanFactory != null, "No BeanFactory available");
LookupOverride override = new LookupOverride(method, lookup.value()); LookupOverride override = new LookupOverride(method, lookup.value());
try { try {
RootBeanDefinition mbd = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(beanName); RootBeanDefinition mbd = (RootBeanDefinition)
this.beanFactory.getMergedBeanDefinition(beanName);
mbd.getMethodOverrides().addOverride(override); mbd.getMethodOverrides().addOverride(override);
} }
catch (NoSuchBeanDefinitionException ex) { catch (NoSuchBeanDefinitionException ex) {

View File

@ -249,7 +249,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
public int accept(Method method) { public int accept(Method method) {
MethodOverride methodOverride = getBeanDefinition().getMethodOverrides().getOverride(method); MethodOverride methodOverride = getBeanDefinition().getMethodOverrides().getOverride(method);
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("Override for '" + method.getName() + "' is [" + methodOverride + "]"); logger.trace("MethodOverride for " + method + ": " + methodOverride);
} }
if (methodOverride == null) { if (methodOverride == null) {
return PASSTHROUGH; return PASSTHROUGH;

View File

@ -322,7 +322,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading; this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
this.dependencyComparator = otherListableFactory.dependencyComparator; this.dependencyComparator = otherListableFactory.dependencyComparator;
// A clone of the AutowireCandidateResolver since it is potentially BeanFactoryAware... // A clone of the AutowireCandidateResolver since it is potentially BeanFactoryAware...
setAutowireCandidateResolver(BeanUtils.instantiateClass(otherListableFactory.getAutowireCandidateResolver().getClass())); setAutowireCandidateResolver(
BeanUtils.instantiateClass(otherListableFactory.getAutowireCandidateResolver().getClass()));
// Make resolvable dependencies (e.g. ResourceLoader) available here as well... // Make resolvable dependencies (e.g. ResourceLoader) available here as well...
this.resolvableDependencies.putAll(otherListableFactory.resolvableDependencies); this.resolvableDependencies.putAll(otherListableFactory.resolvableDependencies);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@ -18,7 +18,7 @@ package org.springframework.asm;
/** /**
* Utility class exposing constants related to Spring's internal repackaging * Utility class exposing constants related to Spring's internal repackaging
* of the ASM bytecode library: currently based on ASM 7.0 plus minor patches. * of the ASM bytecode library: currently based on ASM 7.x plus minor patches.
* *
* <p>See <a href="package-summary.html">package-level javadocs</a> for more * <p>See <a href="package-summary.html">package-level javadocs</a> for more
* information on {@code org.springframework.asm}. * information on {@code org.springframework.asm}.

View File

@ -829,7 +829,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
/** /**
* Allows a task access to {@link Segment} entries. * Allows a task access to {@link ConcurrentReferenceHashMap.Segment} entries.
*/ */
private abstract class Entries { private abstract class Entries {
@ -980,8 +980,8 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
/** /**
* Strategy class used to manage {@link Reference References}. This class can be overridden if * Strategy class used to manage {@link Reference References}.
* alternative reference types need to be supported. * This class can be overridden if alternative reference types need to be supported.
*/ */
protected class ReferenceManager { protected class ReferenceManager {

View File

@ -155,7 +155,7 @@ public class ExchangeResult {
/** /**
* Return the status of the executed request. * Return the HTTP status code as an {@link HttpStatus} enum value.
*/ */
public HttpStatus getStatus() { public HttpStatus getStatus() {
return this.response.getStatusCode(); return this.response.getStatusCode();
@ -219,16 +219,12 @@ public class ExchangeResult {
"\n" + "\n" +
formatBody(getRequestHeaders().getContentType(), this.requestBody) + "\n" + formatBody(getRequestHeaders().getContentType(), this.requestBody) + "\n" +
"\n" + "\n" +
"< " + getStatus() + " " + getStatusReason() + "\n" + "< " + getStatus() + " " + getStatus().getReasonPhrase() + "\n" +
"< " + formatHeaders(getResponseHeaders(), "\n< ") + "\n" + "< " + formatHeaders(getResponseHeaders(), "\n< ") + "\n" +
"\n" + "\n" +
formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n"; formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n";
} }
private String getStatusReason() {
return getStatus().getReasonPhrase();
}
private String formatHeaders(HttpHeaders headers, String delimiter) { private String formatHeaders(HttpHeaders headers, String delimiter) {
return headers.entrySet().stream() return headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue()) .map(entry -> entry.getKey() + ": " + entry.getValue())

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2019 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.
@ -41,7 +41,7 @@ public class SseEmitter extends ResponseBodyEmitter {
static final MediaType TEXT_PLAIN = new MediaType("text", "plain", StandardCharsets.UTF_8); static final MediaType TEXT_PLAIN = new MediaType("text", "plain", StandardCharsets.UTF_8);
static final MediaType UTF8_TEXT_EVENTSTREAM = new MediaType("text", "event-stream", StandardCharsets.UTF_8); static final MediaType TEXT_EVENTSTREAM = new MediaType("text", "event-stream", StandardCharsets.UTF_8);
/** /**
@ -70,7 +70,7 @@ public class SseEmitter extends ResponseBodyEmitter {
HttpHeaders headers = outputMessage.getHeaders(); HttpHeaders headers = outputMessage.getHeaders();
if (headers.getContentType() == null) { if (headers.getContentType() == null) {
headers.setContentType(UTF8_TEXT_EVENTSTREAM); headers.setContentType(TEXT_EVENTSTREAM);
} }
} }
@ -82,10 +82,8 @@ public class SseEmitter extends ResponseBodyEmitter {
* SseEmitter emitter = new SseEmitter(); * SseEmitter emitter = new SseEmitter();
* emitter.send(event().data(myObject)); * emitter.send(event().data(myObject));
* </pre> * </pre>
*
* <p>Please, see {@link ResponseBodyEmitter#send(Object) parent Javadoc} * <p>Please, see {@link ResponseBodyEmitter#send(Object) parent Javadoc}
* for important notes on exception handling. * for important notes on exception handling.
*
* @param object the object to write * @param object the object to write
* @throws IOException raised when an I/O error occurs * @throws IOException raised when an I/O error occurs
* @throws java.lang.IllegalStateException wraps any other errors * @throws java.lang.IllegalStateException wraps any other errors
@ -103,10 +101,8 @@ public class SseEmitter extends ResponseBodyEmitter {
* SseEmitter emitter = new SseEmitter(); * SseEmitter emitter = new SseEmitter();
* emitter.send(event().data(myObject, MediaType.APPLICATION_JSON)); * emitter.send(event().data(myObject, MediaType.APPLICATION_JSON));
* </pre> * </pre>
*
* <p>Please, see {@link ResponseBodyEmitter#send(Object) parent Javadoc} * <p>Please, see {@link ResponseBodyEmitter#send(Object) parent Javadoc}
* for important notes on exception handling. * for important notes on exception handling.
*
* @param object the object to write * @param object the object to write
* @param mediaType a MediaType hint for selecting an HttpMessageConverter * @param mediaType a MediaType hint for selecting an HttpMessageConverter
* @throws IOException raised when an I/O error occurs * @throws IOException raised when an I/O error occurs