Skip to content

Commit 8f96ca4

Browse files
committed
Merge branch '5.3.x'
# Conflicts: # spring-context/spring-context.gradle # spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
2 parents 774583d + 1f8c233 commit 8f96ca4

File tree

7 files changed

+35
-22
lines changed

7 files changed

+35
-22
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -237,7 +237,7 @@ protected Enhancer createEnhancer() {
237237
* validates it if not.
238238
*/
239239
private void validateClassIfNecessary(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader) {
240-
if (logger.isWarnEnabled()) {
240+
if (!this.advised.isOptimize() && logger.isInfoEnabled()) {
241241
synchronized (validatedClasses) {
242242
if (!validatedClasses.containsKey(proxySuperClass)) {
243243
doValidateClass(proxySuperClass, proxyClassLoader,

spring-aop/src/main/java/org/springframework/aop/framework/ProxyConfig.java

+4-6
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-2021 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.
@@ -73,11 +73,9 @@ public boolean isProxyTargetClass() {
7373
* The exact meaning of "aggressive optimizations" will differ
7474
* between proxies, but there is usually some tradeoff.
7575
* Default is "false".
76-
* <p>For example, optimization will usually mean that advice changes won't
77-
* take effect after a proxy has been created. For this reason, optimization
78-
* is disabled by default. An optimize value of "true" may be ignored
79-
* if other settings preclude optimization: for example, if "exposeProxy"
80-
* is set to "true" and that's not compatible with the optimization.
76+
* <p>With Spring's current proxy options, this flag effectively
77+
* enforces CGLIB proxies (similar to {@link #setProxyTargetClass})
78+
* but without any class validation checks (for final methods etc).
8179
*/
8280
public void setOptimize(boolean optimize) {
8381
this.optimize = optimize;

spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 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.
@@ -24,6 +24,7 @@
2424
import org.springframework.beans.factory.config.BeanExpressionContext;
2525
import org.springframework.beans.factory.config.BeanExpressionResolver;
2626
import org.springframework.core.convert.ConversionService;
27+
import org.springframework.core.convert.support.DefaultConversionService;
2728
import org.springframework.expression.Expression;
2829
import org.springframework.expression.ExpressionParser;
2930
import org.springframework.expression.ParserContext;
@@ -156,10 +157,10 @@ public Object evaluate(@Nullable String value, BeanExpressionContext evalContext
156157
sec.addPropertyAccessor(new EnvironmentAccessor());
157158
sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory()));
158159
sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader()));
159-
ConversionService conversionService = evalContext.getBeanFactory().getConversionService();
160-
if (conversionService != null) {
161-
sec.setTypeConverter(new StandardTypeConverter(conversionService));
162-
}
160+
sec.setTypeConverter(new StandardTypeConverter(() -> {
161+
ConversionService cs = evalContext.getBeanFactory().getConversionService();
162+
return (cs != null ? cs : DefaultConversionService.getSharedInstance());
163+
}));
163164
customizeEvaluationContext(sec);
164165
this.evaluationCache.put(evalContext, sec);
165166
}

spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java

+2-3
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-2021 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.
@@ -24,7 +24,6 @@
2424

2525
import static org.assertj.core.api.Assertions.assertThat;
2626

27-
2827
/**
2928
* Tests cornering the issue reported in SPR-8080. If the product of a @Bean method
3029
* was @Autowired into a configuration class while at the same time the declaring
@@ -33,7 +32,7 @@
3332
* 'currently in creation' status of the autowired bean and result in creating multiple
3433
* instances of the given @Bean, violating container scoping / singleton semantics.
3534
*
36-
* This is resolved through no longer relying on 'currently in creation' status, but
35+
* <p>This is resolved through no longer relying on 'currently in creation' status, but
3736
* rather on a thread local that informs the enhanced bean method implementation whether
3837
* the factory is the caller or not.
3938
*

spring-core/src/main/java/org/springframework/asm/ClassReader.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ private static byte[] readStream(final InputStream inputStream, final boolean cl
324324
}
325325
outputStream.flush();
326326
if (readCount == 1) {
327-
return data;
327+
// SPRING PATCH: some misbehaving InputStreams return -1 but still write to buffer (gh-27429)
328+
// return data;
329+
// END OF PATCH
328330
}
329331
return outputStream.toByteArray();
330332
} finally {

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ void registerAdapters(ReactiveAdapterRegistry registry) {
275275
}
276276
}
277277

278+
278279
private static class RxJava3Registrar {
279280

280281
void registerAdapters(ReactiveAdapterRegistry registry) {

spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java

+17-5
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-2021 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.
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.expression.spel.support;
1818

19+
import java.util.function.Supplier;
20+
1921
import org.springframework.core.convert.ConversionException;
2022
import org.springframework.core.convert.ConversionService;
2123
import org.springframework.core.convert.TypeDescriptor;
@@ -37,15 +39,15 @@
3739
*/
3840
public class StandardTypeConverter implements TypeConverter {
3941

40-
private final ConversionService conversionService;
42+
private final Supplier<ConversionService> conversionService;
4143

4244

4345
/**
4446
* Create a StandardTypeConverter for the default ConversionService.
4547
* @see DefaultConversionService#getSharedInstance()
4648
*/
4749
public StandardTypeConverter() {
48-
this.conversionService = DefaultConversionService.getSharedInstance();
50+
this.conversionService = DefaultConversionService::getSharedInstance;
4951
}
5052

5153
/**
@@ -54,20 +56,30 @@ public StandardTypeConverter() {
5456
*/
5557
public StandardTypeConverter(ConversionService conversionService) {
5658
Assert.notNull(conversionService, "ConversionService must not be null");
59+
this.conversionService = () -> conversionService;
60+
}
61+
62+
/**
63+
* Create a StandardTypeConverter for the given ConversionService.
64+
* @param conversionService a Supplier for the ConversionService to delegate to
65+
* @since 5.3.11
66+
*/
67+
public StandardTypeConverter(Supplier<ConversionService> conversionService) {
68+
Assert.notNull(conversionService, "Supplier must not be null");
5769
this.conversionService = conversionService;
5870
}
5971

6072

6173
@Override
6274
public boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) {
63-
return this.conversionService.canConvert(sourceType, targetType);
75+
return this.conversionService.get().canConvert(sourceType, targetType);
6476
}
6577

6678
@Override
6779
@Nullable
6880
public Object convertValue(@Nullable Object value, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType) {
6981
try {
70-
return this.conversionService.convert(value, sourceType, targetType);
82+
return this.conversionService.get().convert(value, sourceType, targetType);
7183
}
7284
catch (ConversionException ex) {
7385
throw new SpelEvaluationException(ex, SpelMessage.TYPE_CONVERSION_ERROR,

0 commit comments

Comments
 (0)