Skip to content

Commit e4e54b3

Browse files
committed
Merge branch '5.2.x'
2 parents 4f2aaa4 + 43e315f commit e4e54b3

File tree

5 files changed

+76
-39
lines changed

5 files changed

+76
-39
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi
593593
// Register exception, in case the bean was accidentally unresolvable.
594594
onSuppressedException(ex);
595595
}
596+
catch (NoSuchBeanDefinitionException ex) {
597+
// Bean definition got removed while we were iterating -> ignore.
598+
}
596599
}
597600
}
598601

@@ -684,7 +687,7 @@ public <T> Map<String, T> getBeansOfType(
684687
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
685688
List<String> result = new ArrayList<>();
686689
for (String beanName : this.beanDefinitionNames) {
687-
BeanDefinition beanDefinition = getBeanDefinition(beanName);
690+
BeanDefinition beanDefinition = this.beanDefinitionMap.get(beanName);
688691
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
689692
result.add(beanName);
690693
}
@@ -1754,18 +1757,23 @@ private void raiseNoMatchingBeanFound(
17541757
*/
17551758
private void checkBeanNotOfRequiredType(Class<?> type, DependencyDescriptor descriptor) {
17561759
for (String beanName : this.beanDefinitionNames) {
1757-
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
1758-
Class<?> targetType = mbd.getTargetType();
1759-
if (targetType != null && type.isAssignableFrom(targetType) &&
1760-
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
1761-
// Probably a proxy interfering with target type match -> throw meaningful exception.
1762-
Object beanInstance = getSingleton(beanName, false);
1763-
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
1764-
beanInstance.getClass() : predictBeanType(beanName, mbd));
1765-
if (beanType != null && !type.isAssignableFrom(beanType)) {
1766-
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
1760+
try {
1761+
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
1762+
Class<?> targetType = mbd.getTargetType();
1763+
if (targetType != null && type.isAssignableFrom(targetType) &&
1764+
isAutowireCandidate(beanName, mbd, descriptor, getAutowireCandidateResolver())) {
1765+
// Probably a proxy interfering with target type match -> throw meaningful exception.
1766+
Object beanInstance = getSingleton(beanName, false);
1767+
Class<?> beanType = (beanInstance != null && beanInstance.getClass() != NullBean.class ?
1768+
beanInstance.getClass() : predictBeanType(beanName, mbd));
1769+
if (beanType != null && !type.isAssignableFrom(beanType)) {
1770+
throw new BeanNotOfRequiredTypeException(beanName, type, beanType);
1771+
}
17671772
}
17681773
}
1774+
catch (NoSuchBeanDefinitionException ex) {
1775+
// Bean definition got removed while we were iterating -> ignore.
1776+
}
17691777
}
17701778

17711779
BeanFactory parent = getParentBeanFactory();

spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -256,7 +256,10 @@ private void finishRegistration() {
256256
this.registrar.setTaskScheduler(resolveSchedulerBean(this.beanFactory, TaskScheduler.class, false));
257257
}
258258
catch (NoUniqueBeanDefinitionException ex) {
259-
logger.trace("Could not find unique TaskScheduler bean", ex);
259+
if (logger.isTraceEnabled()) {
260+
logger.trace("Could not find unique TaskScheduler bean - attempting to resolve by name: " +
261+
ex.getMessage());
262+
}
260263
try {
261264
this.registrar.setTaskScheduler(resolveSchedulerBean(this.beanFactory, TaskScheduler.class, true));
262265
}
@@ -271,13 +274,19 @@ private void finishRegistration() {
271274
}
272275
}
273276
catch (NoSuchBeanDefinitionException ex) {
274-
logger.trace("Could not find default TaskScheduler bean", ex);
277+
if (logger.isTraceEnabled()) {
278+
logger.trace("Could not find default TaskScheduler bean - attempting to find ScheduledExecutorService: " +
279+
ex.getMessage());
280+
}
275281
// Search for ScheduledExecutorService bean next...
276282
try {
277283
this.registrar.setScheduler(resolveSchedulerBean(this.beanFactory, ScheduledExecutorService.class, false));
278284
}
279285
catch (NoUniqueBeanDefinitionException ex2) {
280-
logger.trace("Could not find unique ScheduledExecutorService bean", ex2);
286+
if (logger.isTraceEnabled()) {
287+
logger.trace("Could not find unique ScheduledExecutorService bean - attempting to resolve by name: " +
288+
ex2.getMessage());
289+
}
281290
try {
282291
this.registrar.setScheduler(resolveSchedulerBean(this.beanFactory, ScheduledExecutorService.class, true));
283292
}
@@ -292,7 +301,10 @@ private void finishRegistration() {
292301
}
293302
}
294303
catch (NoSuchBeanDefinitionException ex2) {
295-
logger.trace("Could not find default ScheduledExecutorService bean", ex2);
304+
if (logger.isTraceEnabled()) {
305+
logger.trace("Could not find default ScheduledExecutorService bean - falling back to default: " +
306+
ex2.getMessage());
307+
}
296308
// Giving up -> falling back to default scheduler within the registrar...
297309
logger.info("No TaskScheduler/ScheduledExecutorService bean found for scheduled processing");
298310
}

spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -312,7 +312,6 @@ else if ((sqlType == Types.CLOB || sqlType == Types.NCLOB) && isStringValue(inVa
312312
else {
313313
ps.setClob(paramIndex, new StringReader(strVal), strVal.length());
314314
}
315-
return;
316315
}
317316
else {
318317
// Fallback: setString or setNString binding
@@ -460,12 +459,17 @@ public static void cleanupParameters(@Nullable Object... paramValues) {
460459
public static void cleanupParameters(@Nullable Collection<?> paramValues) {
461460
if (paramValues != null) {
462461
for (Object inValue : paramValues) {
463-
if (inValue instanceof DisposableSqlTypeValue) {
464-
((DisposableSqlTypeValue) inValue).cleanup();
462+
// Unwrap SqlParameterValue first...
463+
if (inValue instanceof SqlParameterValue) {
464+
inValue = ((SqlParameterValue) inValue).getValue();
465465
}
466-
else if (inValue instanceof SqlValue) {
466+
// Check for disposable value types
467+
if (inValue instanceof SqlValue) {
467468
((SqlValue) inValue).cleanup();
468469
}
470+
else if (inValue instanceof DisposableSqlTypeValue) {
471+
((DisposableSqlTypeValue) inValue).cleanup();
472+
}
469473
}
470474
}
471475
}

spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerContainerFactory.java

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.jms.config;
1818

1919
import javax.jms.ConnectionFactory;
20+
import javax.jms.ExceptionListener;
2021

2122
import org.apache.commons.logging.Log;
2223
import org.apache.commons.logging.LogFactory;
@@ -48,10 +49,13 @@ public abstract class AbstractJmsListenerContainerFactory<C extends AbstractMess
4849
private DestinationResolver destinationResolver;
4950

5051
@Nullable
51-
private ErrorHandler errorHandler;
52+
private MessageConverter messageConverter;
5253

5354
@Nullable
54-
private MessageConverter messageConverter;
55+
private ExceptionListener exceptionListener;
56+
57+
@Nullable
58+
private ErrorHandler errorHandler;
5559

5660
@Nullable
5761
private Boolean sessionTransacted;
@@ -99,17 +103,25 @@ public void setDestinationResolver(DestinationResolver destinationResolver) {
99103
}
100104

101105
/**
102-
* @see AbstractMessageListenerContainer#setErrorHandler(ErrorHandler)
106+
* @see AbstractMessageListenerContainer#setMessageConverter(MessageConverter)
103107
*/
104-
public void setErrorHandler(ErrorHandler errorHandler) {
105-
this.errorHandler = errorHandler;
108+
public void setMessageConverter(MessageConverter messageConverter) {
109+
this.messageConverter = messageConverter;
106110
}
107111

108112
/**
109-
* @see AbstractMessageListenerContainer#setMessageConverter(MessageConverter)
113+
* @since 5.2.8
114+
* @see AbstractMessageListenerContainer#setExceptionListener(ExceptionListener)
110115
*/
111-
public void setMessageConverter(MessageConverter messageConverter) {
112-
this.messageConverter = messageConverter;
116+
public void setExceptionListener(ExceptionListener exceptionListener) {
117+
this.exceptionListener = exceptionListener;
118+
}
119+
120+
/**
121+
* @see AbstractMessageListenerContainer#setErrorHandler(ErrorHandler)
122+
*/
123+
public void setErrorHandler(ErrorHandler errorHandler) {
124+
this.errorHandler = errorHandler;
113125
}
114126

115127
/**
@@ -182,6 +194,7 @@ public void setAutoStartup(boolean autoStartup) {
182194
this.autoStartup = autoStartup;
183195
}
184196

197+
185198
@Override
186199
public C createListenerContainer(JmsListenerEndpoint endpoint) {
187200
C instance = createContainerInstance();
@@ -192,12 +205,15 @@ public C createListenerContainer(JmsListenerEndpoint endpoint) {
192205
if (this.destinationResolver != null) {
193206
instance.setDestinationResolver(this.destinationResolver);
194207
}
195-
if (this.errorHandler != null) {
196-
instance.setErrorHandler(this.errorHandler);
197-
}
198208
if (this.messageConverter != null) {
199209
instance.setMessageConverter(this.messageConverter);
200210
}
211+
if (this.exceptionListener != null) {
212+
instance.setExceptionListener(this.exceptionListener);
213+
}
214+
if (this.errorHandler != null) {
215+
instance.setErrorHandler(this.errorHandler);
216+
}
201217
if (this.sessionTransacted != null) {
202218
instance.setSessionTransacted(this.sessionTransacted);
203219
}

spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
9999
throws ServletException, IOException {
100100

101101
HttpServletResponse responseToUse = response;
102-
if (!isAsyncDispatch(request) && !(response instanceof ContentCachingResponseWrapper)) {
102+
if (!isAsyncDispatch(request) && !(response instanceof ConditionalContentCachingResponseWrapper)) {
103103
responseToUse = new ConditionalContentCachingResponseWrapper(response, request);
104104
}
105105

@@ -111,10 +111,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
111111
}
112112

113113
private void updateResponse(HttpServletRequest request, HttpServletResponse response) throws IOException {
114-
115-
ContentCachingResponseWrapper wrapper =
116-
WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
117-
114+
ConditionalContentCachingResponseWrapper wrapper =
115+
WebUtils.getNativeResponse(response, ConditionalContentCachingResponseWrapper.class);
118116
Assert.notNull(wrapper, "ContentCachingResponseWrapper not found");
119117
HttpServletResponse rawResponse = (HttpServletResponse) wrapper.getResponse();
120118

@@ -209,7 +207,6 @@ private static class ConditionalContentCachingResponseWrapper extends ContentCac
209207

210208
private final HttpServletRequest request;
211209

212-
213210
ConditionalContentCachingResponseWrapper(HttpServletResponse response, HttpServletRequest request) {
214211
super(response);
215212
this.request = request;

0 commit comments

Comments
 (0)