Merge branch '5.2.x'
This commit is contained in:
@@ -593,6 +593,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
// Register exception, in case the bean was accidentally unresolvable.
|
||||
onSuppressedException(ex);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Bean definition got removed while we were iterating -> ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,7 +687,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String beanName : this.beanDefinitionNames) {
|
||||
BeanDefinition beanDefinition = getBeanDefinition(beanName);
|
||||
BeanDefinition beanDefinition = this.beanDefinitionMap.get(beanName);
|
||||
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
|
||||
result.add(beanName);
|
||||
}
|
||||
@@ -1754,18 +1757,23 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
*/
|
||||
private void checkBeanNotOfRequiredType(Class<?> type, DependencyDescriptor descriptor) {
|
||||
for (String beanName : this.beanDefinitionNames) {
|
||||
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
|
||||
Class<?> targetType = mbd.getTargetType();
|
||||
if (targetType != null && type.isAssignableFrom(targetType) &&
|
||||
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
|
||||
// Probably a proxy interfering with target type match -> throw meaningful exception.
|
||||
Object beanInstance = getSingleton(beanName, false);
|
||||
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
|
||||
beanInstance.getClass() : predictBeanType(beanName, mbd));
|
||||
if (beanType != null && !type.isAssignableFrom(beanType)) {
|
||||
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
|
||||
try {
|
||||
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
|
||||
Class<?> targetType = mbd.getTargetType();
|
||||
if (targetType != null && type.isAssignableFrom(targetType) &&
|
||||
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
|
||||
// Probably a proxy interfering with target type match -> throw meaningful exception.
|
||||
Object beanInstance = getSingleton(beanName, false);
|
||||
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
|
||||
beanInstance.getClass() : predictBeanType(beanName, mbd));
|
||||
if (beanType != null && !type.isAssignableFrom(beanType)) {
|
||||
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Bean definition got removed while we were iterating -> ignore.
|
||||
}
|
||||
}
|
||||
|
||||
BeanFactory parent = getParentBeanFactory();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -256,7 +256,10 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
this.registrar.setTaskScheduler(resolveSchedulerBean(this.beanFactory, TaskScheduler.class, false));
|
||||
}
|
||||
catch (NoUniqueBeanDefinitionException ex) {
|
||||
logger.trace("Could not find unique TaskScheduler bean", ex);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not find unique TaskScheduler bean - attempting to resolve by name: " +
|
||||
ex.getMessage());
|
||||
}
|
||||
try {
|
||||
this.registrar.setTaskScheduler(resolveSchedulerBean(this.beanFactory, TaskScheduler.class, true));
|
||||
}
|
||||
@@ -271,13 +274,19 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
logger.trace("Could not find default TaskScheduler bean", ex);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not find default TaskScheduler bean - attempting to find ScheduledExecutorService: " +
|
||||
ex.getMessage());
|
||||
}
|
||||
// Search for ScheduledExecutorService bean next...
|
||||
try {
|
||||
this.registrar.setScheduler(resolveSchedulerBean(this.beanFactory, ScheduledExecutorService.class, false));
|
||||
}
|
||||
catch (NoUniqueBeanDefinitionException ex2) {
|
||||
logger.trace("Could not find unique ScheduledExecutorService bean", ex2);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not find unique ScheduledExecutorService bean - attempting to resolve by name: " +
|
||||
ex2.getMessage());
|
||||
}
|
||||
try {
|
||||
this.registrar.setScheduler(resolveSchedulerBean(this.beanFactory, ScheduledExecutorService.class, true));
|
||||
}
|
||||
@@ -292,7 +301,10 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex2) {
|
||||
logger.trace("Could not find default ScheduledExecutorService bean", ex2);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Could not find default ScheduledExecutorService bean - falling back to default: " +
|
||||
ex2.getMessage());
|
||||
}
|
||||
// Giving up -> falling back to default scheduler within the registrar...
|
||||
logger.info("No TaskScheduler/ScheduledExecutorService bean found for scheduled processing");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -312,7 +312,6 @@ public abstract class StatementCreatorUtils {
|
||||
else {
|
||||
ps.setClob(paramIndex, new StringReader(strVal), strVal.length());
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// Fallback: setString or setNString binding
|
||||
@@ -460,12 +459,17 @@ public abstract class StatementCreatorUtils {
|
||||
public static void cleanupParameters(@Nullable Collection<?> paramValues) {
|
||||
if (paramValues != null) {
|
||||
for (Object inValue : paramValues) {
|
||||
if (inValue instanceof DisposableSqlTypeValue) {
|
||||
((DisposableSqlTypeValue) inValue).cleanup();
|
||||
// Unwrap SqlParameterValue first...
|
||||
if (inValue instanceof SqlParameterValue) {
|
||||
inValue = ((SqlParameterValue) inValue).getValue();
|
||||
}
|
||||
else if (inValue instanceof SqlValue) {
|
||||
// Check for disposable value types
|
||||
if (inValue instanceof SqlValue) {
|
||||
((SqlValue) inValue).cleanup();
|
||||
}
|
||||
else if (inValue instanceof DisposableSqlTypeValue) {
|
||||
((DisposableSqlTypeValue) inValue).cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.jms.config;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.ExceptionListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -48,10 +49,13 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
|
||||
private DestinationResolver destinationResolver;
|
||||
|
||||
@Nullable
|
||||
private ErrorHandler errorHandler;
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
@Nullable
|
||||
private MessageConverter messageConverter;
|
||||
private ExceptionListener exceptionListener;
|
||||
|
||||
@Nullable
|
||||
private ErrorHandler errorHandler;
|
||||
|
||||
@Nullable
|
||||
private Boolean sessionTransacted;
|
||||
@@ -98,13 +102,6 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
|
||||
this.destinationResolver = destinationResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractMessageListenerContainer#setErrorHandler(ErrorHandler)
|
||||
*/
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractMessageListenerContainer#setMessageConverter(MessageConverter)
|
||||
*/
|
||||
@@ -112,6 +109,21 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
|
||||
this.messageConverter = messageConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.2.8
|
||||
* @see AbstractMessageListenerContainer#setExceptionListener(ExceptionListener)
|
||||
*/
|
||||
public void setExceptionListener(ExceptionListener exceptionListener) {
|
||||
this.exceptionListener = exceptionListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractMessageListenerContainer#setErrorHandler(ErrorHandler)
|
||||
*/
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractMessageListenerContainer#setSessionTransacted(boolean)
|
||||
*/
|
||||
@@ -182,6 +194,7 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
|
||||
this.autoStartup = autoStartup;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public C createListenerContainer(JmsListenerEndpoint endpoint) {
|
||||
C instance = createContainerInstance();
|
||||
@@ -192,12 +205,15 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
|
||||
if (this.destinationResolver != null) {
|
||||
instance.setDestinationResolver(this.destinationResolver);
|
||||
}
|
||||
if (this.errorHandler != null) {
|
||||
instance.setErrorHandler(this.errorHandler);
|
||||
}
|
||||
if (this.messageConverter != null) {
|
||||
instance.setMessageConverter(this.messageConverter);
|
||||
}
|
||||
if (this.exceptionListener != null) {
|
||||
instance.setExceptionListener(this.exceptionListener);
|
||||
}
|
||||
if (this.errorHandler != null) {
|
||||
instance.setErrorHandler(this.errorHandler);
|
||||
}
|
||||
if (this.sessionTransacted != null) {
|
||||
instance.setSessionTransacted(this.sessionTransacted);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
|
||||
throws ServletException, IOException {
|
||||
|
||||
HttpServletResponse responseToUse = response;
|
||||
if (!isAsyncDispatch(request) && !(response instanceof ContentCachingResponseWrapper)) {
|
||||
if (!isAsyncDispatch(request) && !(response instanceof ConditionalContentCachingResponseWrapper)) {
|
||||
responseToUse = new ConditionalContentCachingResponseWrapper(response, request);
|
||||
}
|
||||
|
||||
@@ -111,10 +111,8 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
|
||||
}
|
||||
|
||||
private void updateResponse(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
ContentCachingResponseWrapper wrapper =
|
||||
WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
|
||||
|
||||
ConditionalContentCachingResponseWrapper wrapper =
|
||||
WebUtils.getNativeResponse(response, ConditionalContentCachingResponseWrapper.class);
|
||||
Assert.notNull(wrapper, "ContentCachingResponseWrapper not found");
|
||||
HttpServletResponse rawResponse = (HttpServletResponse) wrapper.getResponse();
|
||||
|
||||
@@ -209,7 +207,6 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
|
||||
ConditionalContentCachingResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
|
||||
super(response);
|
||||
this.request = request;
|
||||
|
||||
Reference in New Issue
Block a user