Browse Source

Polishing

pull/1359/head
Juergen Hoeller 9 years ago
parent
commit
c2a1a41eb6
  1. 5
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java
  2. 7
      spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java
  3. 5
      spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java
  4. 9
      spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java
  5. 57
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  6. 48
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
  7. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java
  8. 154
      spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java
  9. 2
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java
  10. 9
      spring-web/src/main/java/org/springframework/http/client/AbstractAsyncClientHttpRequest.java
  11. 30
      spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java
  12. 37
      spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java

5
spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@ -141,8 +141,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP @@ -141,8 +141,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP
@Override
public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
throws BeansException {
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
if (!this.validatedBeanNames.contains(beanName)) {
if (!shouldSkip(this.beanFactory, beanName)) {

7
spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@ -96,14 +96,13 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { @@ -96,14 +96,13 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
* dependency types - which the factory handles specifically - already filtered out)
* @param bean the bean instance created, but whose properties have not yet been set
* @param beanName the name of the bean
* @return the actual property values to apply to to the given bean
* @return the actual property values to apply to the given bean
* (can be the passed-in PropertyValues instance), or {@code null}
* to skip property population
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.MutablePropertyValues
*/
PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
throws BeansException;
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException;
}

5
spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@ -66,8 +66,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar @@ -66,8 +66,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
@Override
public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
throws BeansException {
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
return pvs;
}

9
spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@ -68,6 +68,7 @@ public interface Scope { @@ -68,6 +68,7 @@ public interface Scope {
* @param objectFactory the {@link ObjectFactory} to use to create the scoped
* object if it is not present in the underlying storage mechanism
* @return the desired object (never {@code null})
* @throws IllegalStateException if the underlying scope is not currently active
*/
Object get(String name, ObjectFactory<?> objectFactory);
@ -84,6 +85,7 @@ public interface Scope { @@ -84,6 +85,7 @@ public interface Scope {
* removing an object.
* @param name the name of the object to remove
* @return the removed object, or {@code null} if no object was present
* @throws IllegalStateException if the underlying scope is not currently active
* @see #registerDestructionCallback
*/
Object remove(String name);
@ -100,7 +102,7 @@ public interface Scope { @@ -100,7 +102,7 @@ public interface Scope {
* at the appropriate time. If such a callback is not supported by the
* underlying runtime environment at all, the callback <i>must be
* ignored and a corresponding warning should be logged</i>.
* <p>Note that 'destruction' refers to to automatic destruction of
* <p>Note that 'destruction' refers to automatic destruction of
* the object as part of the scope's own lifecycle, not to the individual
* scoped object having been explicitly removed by the application.
* If a scoped object gets removed via this facade's {@link #remove(String)}
@ -112,6 +114,7 @@ public interface Scope { @@ -112,6 +114,7 @@ public interface Scope {
* so it can safely be executed without an enclosing try-catch block.
* Furthermore, the Runnable will usually be serializable, provided
* that its target object is serializable as well.
* @throws IllegalStateException if the underlying scope is not currently active
* @see org.springframework.beans.factory.DisposableBean
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getDestroyMethodName()
* @see DestructionAwareBeanPostProcessor
@ -123,6 +126,7 @@ public interface Scope { @@ -123,6 +126,7 @@ public interface Scope {
* E.g. the HttpServletRequest object for key "request".
* @param key the contextual key
* @return the corresponding object, or {@code null} if none found
* @throws IllegalStateException if the underlying scope is not currently active
*/
Object resolveContextualObject(String key);
@ -139,6 +143,7 @@ public interface Scope { @@ -139,6 +143,7 @@ public interface Scope {
* underlying storage mechanism has no obvious candidate for such an ID.
* @return the conversation ID, or {@code null} if there is no
* conversation ID for the current scope
* @throws IllegalStateException if the underlying scope is not currently active
*/
String getConversationId();

57
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

@ -500,7 +500,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -500,7 +500,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #instantiateUsingFactoryMethod
* @see #autowireConstructor
*/
protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final Object[] args) {
protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final Object[] args)
throws BeanCreationException {
// Instantiate the bean.
BeanWrapper instanceWrapper = null;
if (mbd.isSingleton()) {
@ -515,7 +517,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -515,7 +517,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Allow post-processors to modify the merged bean definition.
synchronized (mbd.postProcessingLock) {
if (!mbd.postProcessed) {
applyMergedBeanDefinitionPostProcessors(mbd, beanType, beanName);
try {
applyMergedBeanDefinitionPostProcessors(mbd, beanType, beanName);
}
catch (Throwable ex) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Post-processing of merged bean definition failed", ex);
}
mbd.postProcessed = true;
}
}
@ -550,7 +558,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -550,7 +558,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
throw (BeanCreationException) ex;
}
else {
throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Initialization of bean failed", ex);
throw new BeanCreationException(
mbd.getResourceDescription(), beanName, "Initialization of bean failed", ex);
}
}
@ -586,7 +595,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -586,7 +595,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
registerDisposableBeanIfNecessary(beanName, bean, mbd);
}
catch (BeanDefinitionValidationException ex) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Invalid destruction signature", ex);
throw new BeanCreationException(
mbd.getResourceDescription(), beanName, "Invalid destruction signature", ex);
}
return exposedObject;
@ -624,7 +634,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -624,7 +634,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
protected Class<?> determineTargetType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
Class<?> targetType = mbd.getTargetType();
if (targetType == null) {
targetType = (mbd.getFactoryMethodName() != null ? getTypeForFactoryMethod(beanName, mbd, typesToMatch) :
targetType = (mbd.getFactoryMethodName() != null ?
getTypeForFactoryMethod(beanName, mbd, typesToMatch) :
resolveBeanClass(mbd, beanName, typesToMatch));
if (ObjectUtils.isEmpty(typesToMatch) || getTempClassLoader() == null) {
mbd.setTargetType(targetType);
@ -772,10 +783,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -772,10 +783,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
ReflectionUtils.doWithMethods(fbClass,
new ReflectionUtils.MethodCallback() {
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
public void doWith(Method method) {
if (method.getName().equals(factoryMethodName) &&
FactoryBean.class.isAssignableFrom(method.getReturnType())) {
objectType.value = GenericTypeResolver.resolveReturnTypeArgument(method, FactoryBean.class);
objectType.value = GenericTypeResolver.resolveReturnTypeArgument(
method, FactoryBean.class);
}
}
});
@ -926,24 +938,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -926,24 +938,15 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param mbd the merged bean definition for the bean
* @param beanType the actual type of the managed bean instance
* @param beanName the name of the bean
* @throws BeansException if any post-processing failed
* @see MergedBeanDefinitionPostProcessor#postProcessMergedBeanDefinition
*/
protected void applyMergedBeanDefinitionPostProcessors(RootBeanDefinition mbd, Class<?> beanType, String beanName)
throws BeansException {
try {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof MergedBeanDefinitionPostProcessor) {
MergedBeanDefinitionPostProcessor bdp = (MergedBeanDefinitionPostProcessor) bp;
bdp.postProcessMergedBeanDefinition(mbd, beanType, beanName);
}
protected void applyMergedBeanDefinitionPostProcessors(RootBeanDefinition mbd, Class<?> beanType, String beanName) {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof MergedBeanDefinitionPostProcessor) {
MergedBeanDefinitionPostProcessor bdp = (MergedBeanDefinitionPostProcessor) bp;
bdp.postProcessMergedBeanDefinition(mbd, beanType, beanName);
}
}
catch (Exception ex) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Post-processing failed of bean type [" + beanType + "] failed", ex);
}
}
/**
@ -980,12 +983,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -980,12 +983,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @param beanClass the class of the bean to be instantiated
* @param beanName the name of the bean
* @return the bean object to use instead of a default instance of the target bean, or {@code null}
* @throws BeansException if any post-processing failed
* @see InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation
*/
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName)
throws BeansException {
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName) {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof InstantiationAwareBeanPostProcessor) {
InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
@ -1106,7 +1106,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1106,7 +1106,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return bw;
}
catch (Throwable ex) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName, "Instantiation of bean failed", ex);
throw new BeanCreationException(
mbd.getResourceDescription(), beanName, "Instantiation of bean failed", ex);
}
}
@ -1658,7 +1659,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1658,7 +1659,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* methods with arguments.
* @see #invokeInitMethods
*/
protected void invokeCustomInitMethod(String beanName, final Object bean, RootBeanDefinition mbd) throws Throwable {
protected void invokeCustomInitMethod(String beanName, final Object bean, RootBeanDefinition mbd)
throws Throwable {
String initMethodName = mbd.getInitMethodName();
final Method initMethod = (mbd.isNonPublicAccessAllowed() ?
BeanUtils.findMethod(bean.getClass(), initMethodName) :

48
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

@ -287,13 +287,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -287,13 +287,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
// Guarantee initialization of beans that the current bean depends on.
String[] dependsOn = mbd.getDependsOn();
if (dependsOn != null) {
for (String dependsOnBean : dependsOn) {
if (isDependent(beanName, dependsOnBean)) {
for (String dep : dependsOn) {
if (isDependent(beanName, dep)) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Circular depends-on relationship between '" + beanName + "' and '" + dependsOnBean + "'");
"Circular depends-on relationship between '" + beanName + "' and '" + dep + "'");
}
registerDependentBean(dependsOnBean, beanName);
getBean(dependsOnBean);
registerDependentBean(dep, beanName);
getBean(dep);
}
}
@ -460,19 +460,19 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -460,19 +460,19 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
return false;
}
if (isFactoryBean(beanName, mbd)) {
final FactoryBean<?> factoryBean = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
final FactoryBean<?> fb = (FactoryBean<?>) getBean(FACTORY_BEAN_PREFIX + beanName);
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
!factoryBean.isSingleton());
return ((fb instanceof SmartFactoryBean && ((SmartFactoryBean<?>) fb).isPrototype()) ||
!fb.isSingleton());
}
}, getAccessControlContext());
}
else {
return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean<?>) factoryBean).isPrototype()) ||
!factoryBean.isSingleton());
return ((fb instanceof SmartFactoryBean && ((SmartFactoryBean<?>) fb).isPrototype()) ||
!fb.isSingleton());
}
}
else {
@ -800,12 +800,15 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -800,12 +800,15 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@Override
public String resolveEmbeddedValue(String value) {
if (value == null) {
return null;
}
String result = value;
for (StringValueResolver resolver : this.embeddedValueResolvers) {
result = resolver.resolveStringValue(result);
if (result == null) {
return null;
}
result = resolver.resolveStringValue(result);
}
return result;
}
@ -1045,11 +1048,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1045,11 +1048,11 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
* Destroy the given bean instance (usually a prototype instance
* obtained from this factory) according to the given bean definition.
* @param beanName the name of the bean definition
* @param beanInstance the bean instance to destroy
* @param bean the bean instance to destroy
* @param mbd the merged bean definition
*/
protected void destroyBean(String beanName, Object beanInstance, RootBeanDefinition mbd) {
new DisposableBeanAdapter(beanInstance, beanName, mbd, getBeanPostProcessors(), getAccessControlContext()).destroy();
protected void destroyBean(String beanName, Object bean, RootBeanDefinition mbd) {
new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors(), getAccessControlContext()).destroy();
}
@Override
@ -1230,12 +1233,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1230,12 +1233,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
pbd = getMergedBeanDefinition(parentBeanName);
}
else {
if (getParentBeanFactory() instanceof ConfigurableBeanFactory) {
pbd = ((ConfigurableBeanFactory) getParentBeanFactory()).getMergedBeanDefinition(parentBeanName);
BeanFactory parent = getParentBeanFactory();
if (parent instanceof ConfigurableBeanFactory) {
pbd = ((ConfigurableBeanFactory) parent).getMergedBeanDefinition(parentBeanName);
}
else {
throw new NoSuchBeanDefinitionException(bd.getParentName(),
"Parent name '" + bd.getParentName() + "' is equal to bean name '" + beanName +
throw new NoSuchBeanDefinitionException(parentBeanName,
"Parent name '" + parentBeanName + "' is equal to bean name '" + beanName +
"': cannot be resolved without an AbstractBeanFactory parent");
}
}
@ -1351,12 +1355,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @@ -1351,12 +1355,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
catch (ClassNotFoundException ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
}
catch (LinkageError err) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);
catch (LinkageError ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
}
}
private Class<?> doResolveBeanClass(RootBeanDefinition mbd, Class<?>... typesToMatch) throws ClassNotFoundException {
private Class<?> doResolveBeanClass(RootBeanDefinition mbd, Class<?>... typesToMatch)
throws ClassNotFoundException {
ClassLoader beanClassLoader = getBeanClassLoader();
ClassLoader classLoaderToUse = beanClassLoader;
if (!ObjectUtils.isEmpty(typesToMatch)) {

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

@ -214,7 +214,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements @@ -214,7 +214,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
if (singletonObject == null) {
if (this.singletonsCurrentlyInDestruction) {
throw new BeanCreationNotAllowedException(beanName,
"Singleton bean creation not allowed while the singletons of this factory are in destruction " +
"Singleton bean creation not allowed while singletons of this factory are in destruction " +
"(Do not request a bean from a BeanFactory in a destroy method implementation!)");
}
if (logger.isDebugEnabled()) {

154
spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@ -50,52 +50,48 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -50,52 +50,48 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
private final ApplicationContext context = mock(ApplicationContext.class);
@Test
public void rawListener() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleRaw", ApplicationEvent.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class);
supportsEventType(true, method, getGenericApplicationEventType("applicationEvent"));
}
@Test
public void rawListenerWithGenericEvent() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleRaw", ApplicationEvent.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class);
supportsEventType(true, method, getGenericApplicationEventType("stringEvent"));
}
@Test
public void genericListener() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
supportsEventType(true, method, getGenericApplicationEventType("stringEvent"));
}
@Test
public void genericListenerWrongParameterizedType() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
supportsEventType(false, method, getGenericApplicationEventType("longEvent"));
}
@Test
public void listenerWithPayloadAndGenericInformation() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
supportsEventType(true, method, createGenericEventType(String.class));
}
@Test
public void listenerWithInvalidPayloadAndGenericInformation() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
supportsEventType(false, method, createGenericEventType(Integer.class));
}
@Test
public void listenerWithPayloadTypeErasure() { // Always accept such event when the type is unknown
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
public void listenerWithPayloadTypeErasure() { // Always accept such event when the type is unknown
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
supportsEventType(true, method, ResolvableType.forClass(PayloadApplicationEvent.class));
}
@ -108,36 +104,32 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -108,36 +104,32 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void listenerWithSubTypeSeveralGenericsResolved() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
supportsEventType(true, method, ResolvableType.forClass(PayloadStringTestEvent.class));
}
@Test
public void listenerWithAnnotationValue() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringAnnotationValue");
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationValue");
supportsEventType(true, method, createGenericEventType(String.class));
}
@Test
public void listenerWithAnnotationClasses() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringAnnotationClasses");
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses");
supportsEventType(true, method, createGenericEventType(String.class));
}
@Test
public void listenerWithAnnotationValueAndParameter() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringAnnotationValueAndParameter", String.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class);
supportsEventType(true, method, createGenericEventType(String.class));
}
@Test
public void listenerWithSeveralTypes() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringOrInteger");
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger");
supportsEventType(true, method, createGenericEventType(String.class));
supportsEventType(true, method, createGenericEventType(Integer.class));
supportsEventType(false, method, createGenericEventType(Double.class));
@ -145,51 +137,47 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -145,51 +137,47 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void listenerWithTooManyParameters() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"tooManyParameters", String.class, String.class);
thrown.expect(IllegalStateException.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "tooManyParameters", String.class, String.class);
this.thrown.expect(IllegalStateException.class);
createTestInstance(method);
}
@Test
public void listenerWithNoParameter() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"noParameter");
thrown.expect(IllegalStateException.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "noParameter");
this.thrown.expect(IllegalStateException.class);
createTestInstance(method);
}
@Test
public void listenerWithMoreThanOneParameter() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"moreThanOneParameter", String.class, Integer.class);
thrown.expect(IllegalStateException.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "moreThanOneParameter", String.class, Integer.class);
this.thrown.expect(IllegalStateException.class);
createTestInstance(method);
}
@Test
public void defaultOrder() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
ApplicationListenerMethodAdapter adapter = createTestInstance(method);
assertEquals(0, adapter.getOrder());
}
@Test
public void specifiedOrder() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleRaw", ApplicationEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleRaw", ApplicationEvent.class);
ApplicationListenerMethodAdapter adapter = createTestInstance(method);
assertEquals(42, adapter.getOrder());
}
@Test
public void invokeListener() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
GenericTestEvent<String> event = createGenericTestEvent("test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleGenericString(event);
@ -197,8 +185,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -197,8 +185,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithGenericEvent() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
GenericTestEvent<String> event = new SmartGenericTestEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleGenericString(event);
@ -206,8 +194,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -206,8 +194,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithGenericPayload() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericStringPayload", EntityWrapper.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericStringPayload", EntityWrapper.class);
EntityWrapper<String> payload = new EntityWrapper<>("test");
invokeListener(method, new PayloadApplicationEvent<>(this, payload));
verify(this.sampleEvents, times(1)).handleGenericStringPayload(payload);
@ -215,8 +203,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -215,8 +203,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithWrongGenericPayload() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericStringPayload", EntityWrapper.class);
Method method = ReflectionUtils.findMethod
(SampleEvents.class, "handleGenericStringPayload", EntityWrapper.class);
EntityWrapper<Integer> payload = new EntityWrapper<>(123);
invokeListener(method, new PayloadApplicationEvent<>(this, payload));
verify(this.sampleEvents, times(0)).handleGenericStringPayload(any());
@ -224,8 +212,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -224,8 +212,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithAnyGenericPayload() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericAnyPayload", EntityWrapper.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericAnyPayload", EntityWrapper.class);
EntityWrapper<String> payload = new EntityWrapper<>("test");
invokeListener(method, new PayloadApplicationEvent<>(this, payload));
verify(this.sampleEvents, times(1)).handleGenericAnyPayload(payload);
@ -233,24 +221,24 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -233,24 +221,24 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerRuntimeException() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"generateRuntimeException", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "generateRuntimeException", GenericTestEvent.class);
GenericTestEvent<String> event = createGenericTestEvent("fail");
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Test exception");
thrown.expectCause(is(isNull(Throwable.class)));
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Test exception");
this.thrown.expectCause(is((Throwable) isNull()));
invokeListener(method, event);
}
@Test
public void invokeListenerCheckedException() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"generateCheckedException", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "generateCheckedException", GenericTestEvent.class);
GenericTestEvent<String> event = createGenericTestEvent("fail");
thrown.expect(UndeclaredThrowableException.class);
thrown.expectCause(is(instanceOf(IOException.class)));
this.thrown.expect(UndeclaredThrowableException.class);
this.thrown.expectCause(is(instanceOf(IOException.class)));
invokeListener(method, event);
}
@ -262,18 +250,18 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -262,18 +250,18 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
proxyFactory.addInterface(SimpleService.class);
Object bean = proxyFactory.getProxy(getClass().getClassLoader());
Method method = ReflectionUtils.findMethod(InvalidProxyTestBean.class, "handleIt2", ApplicationEvent.class);
Method method = ReflectionUtils.findMethod(
InvalidProxyTestBean.class, "handleIt2", ApplicationEvent.class);
StaticApplicationListenerMethodAdapter listener =
new StaticApplicationListenerMethodAdapter(method, bean);
thrown.expect(IllegalStateException.class);
thrown.expectMessage("handleIt2");
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("handleIt2");
listener.onApplicationEvent(createGenericTestEvent("test"));
}
@Test
public void invokeListenerWithPayload() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleString("test");
@ -281,8 +269,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -281,8 +269,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithPayloadWrongType() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleString", String.class);
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class);
PayloadApplicationEvent<Long> event = new PayloadApplicationEvent<>(this, 123L);
invokeListener(method, event);
verify(this.sampleEvents, never()).handleString(anyString());
@ -290,8 +277,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -290,8 +277,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithAnnotationValue() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringAnnotationClasses");
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses");
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringAnnotationClasses();
@ -299,8 +285,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -299,8 +285,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithAnnotationValueAndParameter() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringAnnotationValueAndParameter", String.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class);
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringAnnotationValueAndParameter("test");
@ -308,8 +294,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -308,8 +294,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Test
public void invokeListenerWithSeveralTypes() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleStringOrInteger");
Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger");
PayloadApplicationEvent<String> event = new PayloadApplicationEvent<>(this, "test");
invokeListener(method, event);
verify(this.sampleEvents, times(1)).handleStringOrInteger();
@ -321,11 +306,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -321,11 +306,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
verify(this.sampleEvents, times(2)).handleStringOrInteger();
}
@Test
public void beanInstanceRetrievedAtEveryInvocation() {
Method method = ReflectionUtils.findMethod(SampleEvents.class,
"handleGenericString", GenericTestEvent.class);
Method method = ReflectionUtils.findMethod(
SampleEvents.class, "handleGenericString", GenericTestEvent.class);
when(this.context.getBean("testBean")).thenReturn(this.sampleEvents);
ApplicationListenerMethodAdapter listener = new ApplicationListenerMethodAdapter(
"testBean", GenericTestEvent.class, method);
@ -342,6 +326,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -342,6 +326,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
verify(this.context, times(2)).getBean("testBean");
}
private void supportsEventType(boolean match, Method method, ResolvableType eventType) {
ApplicationListenerMethodAdapter adapter = createTestInstance(method);
assertEquals("Wrong match for event '" + eventType + "' on " + method,
@ -361,8 +346,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -361,8 +346,8 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType);
}
private static class StaticApplicationListenerMethodAdapter
extends ApplicationListenerMethodAdapter {
private static class StaticApplicationListenerMethodAdapter extends ApplicationListenerMethodAdapter {
private final Object targetBean;
@ -373,14 +358,13 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -373,14 +358,13 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@Override
public Object getTargetBean() {
return targetBean;
return this.targetBean;
}
}
private static class SampleEvents {
@EventListener
@Order(42)
public void handleRaw(ApplicationEvent event) {
@ -449,13 +433,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -449,13 +433,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
}
}
interface SimpleService {
void handleIt(ApplicationEvent event);
}
private static class EntityWrapper<T> implements ResolvableTypeProvider {
private final T entity;
public EntityWrapper(T entity) {
@ -468,6 +454,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -468,6 +454,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
}
}
static class InvalidProxyTestBean implements SimpleService {
@Override
@ -479,6 +466,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -479,6 +466,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
}
}
@SuppressWarnings({"unused", "serial"})
static class PayloadTestEvent<V, T> extends PayloadApplicationEvent<T> {
@ -490,8 +478,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @@ -490,8 +478,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
}
}
@SuppressWarnings({ "serial" })
static class PayloadStringTestEvent extends PayloadTestEvent<Long, String> {
public PayloadStringTestEvent(Object source, String payload, Long something) {
super(source, payload, something);
}

2
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -607,6 +607,7 @@ public abstract class ReflectionUtils { @@ -607,6 +607,7 @@ public abstract class ReflectionUtils {
* @see Class#getDeclaredMethods()
*/
private static Method[] getDeclaredMethods(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
Method[] result = declaredMethodsCache.get(clazz);
if (result == null) {
Method[] declaredMethods = clazz.getDeclaredMethods();
@ -708,6 +709,7 @@ public abstract class ReflectionUtils { @@ -708,6 +709,7 @@ public abstract class ReflectionUtils {
* @see Class#getDeclaredFields()
*/
private static Field[] getDeclaredFields(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
Field[] result = declaredFieldsCache.get(clazz);
if (result == null) {
result = clazz.getDeclaredFields();

9
spring-web/src/main/java/org/springframework/http/client/AbstractAsyncClientHttpRequest.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@ -73,12 +73,11 @@ abstract class AbstractAsyncClientHttpRequest implements AsyncClientHttpRequest @@ -73,12 +73,11 @@ abstract class AbstractAsyncClientHttpRequest implements AsyncClientHttpRequest
protected abstract OutputStream getBodyInternal(HttpHeaders headers) throws IOException;
/**
* Abstract template method that writes the given headers and content to the HTTP
* request.
* Abstract template method that writes the given headers and content to the HTTP request.
* @param headers the HTTP headers
* @return the response object for the executed request
*/
protected abstract ListenableFuture<ClientHttpResponse> executeInternal(
HttpHeaders headers) throws IOException;
protected abstract ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers)
throws IOException;
}

30
spring-web/src/main/java/org/springframework/web/client/HttpClientErrorException.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@ -34,8 +34,8 @@ public class HttpClientErrorException extends HttpStatusCodeException { @@ -34,8 +34,8 @@ public class HttpClientErrorException extends HttpStatusCodeException {
/**
* Construct a new instance of {@code HttpClientErrorException} based on an
* {@link HttpStatus}.
* Construct a new instance of {@code HttpClientErrorException} based on
* an {@link HttpStatus}.
* @param statusCode the status code
*/
public HttpClientErrorException(HttpStatus statusCode) {
@ -43,8 +43,8 @@ public class HttpClientErrorException extends HttpStatusCodeException { @@ -43,8 +43,8 @@ public class HttpClientErrorException extends HttpStatusCodeException {
}
/**
* Construct a new instance of {@code HttpClientErrorException} based on an
* {@link HttpStatus} and status text.
* Construct a new instance of {@code HttpClientErrorException} based on
* an {@link HttpStatus} and status text.
* @param statusCode the status code
* @param statusText the status text
*/
@ -53,30 +53,32 @@ public class HttpClientErrorException extends HttpStatusCodeException { @@ -53,30 +53,32 @@ public class HttpClientErrorException extends HttpStatusCodeException {
}
/**
* Construct a new instance of {@code HttpClientErrorException} based on an
* {@link HttpStatus}, status text, and response body content.
* Construct a new instance of {@code HttpClientErrorException} based on
* an {@link HttpStatus}, status text, and response body content.
* @param statusCode the status code
* @param statusText the status text
* @param responseBody the response body content, may be {@code null}
* @param responseCharset the response body charset, may be {@code null}
* @param responseBody the response body content (may be {@code null})
* @param responseCharset the response body charset (may be {@code null})
*/
public HttpClientErrorException(HttpStatus statusCode, String statusText,
byte[] responseBody, Charset responseCharset) {
super(statusCode, statusText, responseBody, responseCharset);
}
/**
* Construct a new instance of {@code HttpClientErrorException} based on an
* {@link HttpStatus}, status text, and response body content.
* Construct a new instance of {@code HttpClientErrorException} based on
* an {@link HttpStatus}, status text, and response body content.
* @param statusCode the status code
* @param statusText the status text
* @param responseHeaders the response headers, may be {@code null}
* @param responseBody the response body content, may be {@code null}
* @param responseCharset the response body charset, may be {@code null}
* @param responseHeaders the response headers (may be {@code null})
* @param responseBody the response body content (may be {@code null})
* @param responseCharset the response body charset (may be {@code null})
* @since 3.1.2
*/
public HttpClientErrorException(HttpStatus statusCode, String statusText,
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
}

37
spring-web/src/main/java/org/springframework/web/client/HttpServerErrorException.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@ -25,8 +25,8 @@ import org.springframework.http.HttpStatus; @@ -25,8 +25,8 @@ import org.springframework.http.HttpStatus;
* Exception thrown when an HTTP 5xx is received.
*
* @author Arjen Poutsma
* @see DefaultResponseErrorHandler
* @since 3.0
* @see DefaultResponseErrorHandler
*/
public class HttpServerErrorException extends HttpStatusCodeException {
@ -34,8 +34,8 @@ public class HttpServerErrorException extends HttpStatusCodeException { @@ -34,8 +34,8 @@ public class HttpServerErrorException extends HttpStatusCodeException {
/**
* Construct a new instance of {@code HttpServerErrorException} based on an
* {@link HttpStatus}.
* Construct a new instance of {@code HttpServerErrorException} based on
* an {@link HttpStatus}.
* @param statusCode the status code
*/
public HttpServerErrorException(HttpStatus statusCode) {
@ -43,8 +43,8 @@ public class HttpServerErrorException extends HttpStatusCodeException { @@ -43,8 +43,8 @@ public class HttpServerErrorException extends HttpStatusCodeException {
}
/**
* Construct a new instance of {@code HttpServerErrorException} based on an
* {@link HttpStatus} and status text.
* Construct a new instance of {@code HttpServerErrorException} based on
* an {@link HttpStatus} and status text.
* @param statusCode the status code
* @param statusText the status text
*/
@ -53,31 +53,34 @@ public class HttpServerErrorException extends HttpStatusCodeException { @@ -53,31 +53,34 @@ public class HttpServerErrorException extends HttpStatusCodeException {
}
/**
* Construct a new instance of {@code HttpServerErrorException} based on an
* {@link HttpStatus}, status text, and response body content.
* @param statusCode the status code
* @param statusText the status text
* @param responseBody the response body content, may be {@code null}
* @param responseCharset the response body charset, may be {@code null}
* Construct a new instance of {@code HttpServerErrorException} based on
* an {@link HttpStatus}, status text, and response body content.
* @param statusCode the status code
* @param statusText the status text
* @param responseBody the response body content (may be {@code null})
* @param responseCharset the response body charset (may be {@code null})
* @since 3.0.5
*/
public HttpServerErrorException(HttpStatus statusCode, String statusText,
byte[] responseBody, Charset responseCharset) {
super(statusCode, statusText, responseBody, responseCharset);
}
/**
* Construct a new instance of {@code HttpServerErrorException} based on a
* {@link HttpStatus}, status text, and response body content.
* Construct a new instance of {@code HttpServerErrorException} based on
* an {@link HttpStatus}, status text, and response body content.
* @param statusCode the status code
* @param statusText the status text
* @param responseHeaders the response headers, may be {@code null}
* @param responseBody the response body content, may be {@code null}
* @param responseCharset the response body charset, may be {@code null}
* @param responseHeaders the response headers (may be {@code null})
* @param responseBody the response body content (may be {@code null})
* @param responseCharset the response body charset (may be {@code null})
* @since 3.1.2
*/
public HttpServerErrorException(HttpStatus statusCode, String statusText,
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
}
}

Loading…
Cancel
Save