Skip to content

Commit a1f6098

Browse files
committed
Merge branch '6.1.x'
2 parents 9e3371e + 022fdcd commit a1f6098

File tree

6 files changed

+71
-13
lines changed

6 files changed

+71
-13
lines changed

Diff for: framework-docs/modules/ROOT/pages/appendix.adoc

+9-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ The following table lists all currently supported Spring properties.
2323
|===
2424
| Name | Description
2525

26+
| `spring.aop.ajc.ignore`
27+
| Instructs Spring to ignore ajc-compiled aspects for Spring AOP proxying, restoring traditional
28+
Spring behavior for scenarios where both weaving and AspectJ auto-proxying are enabled. See
29+
{spring-framework-api}++/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.html#IGNORE_AJC_PROPERTY_NAME++[`AbstractAspectJAdvisorFactory`]
30+
for details.
31+
2632
| `spring.aot.enabled`
2733
| Indicates the application should run with AOT generated artifacts. See
2834
xref:core/aot.adoc[Ahead of Time Optimizations] and
@@ -32,7 +38,7 @@ for details.
3238
| `spring.beaninfo.ignore`
3339
| Instructs Spring to use the `Introspector.IGNORE_ALL_BEANINFO` mode when calling the
3440
JavaBeans `Introspector`. See
35-
{spring-framework-api}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`CachedIntrospectionResults`]
41+
{spring-framework-api}++/beans/StandardBeanInfoFactory.html#IGNORE_BEANINFO_PROPERTY_NAME++[`StandardBeanInfoFactory`]
3642
for details.
3743

3844
| `spring.cache.reactivestreams.ignore`
@@ -49,15 +55,13 @@ for details.
4955

5056
| `spring.context.checkpoint`
5157
| Property that specifies a common context checkpoint. See
52-
xref:integration/checkpoint-restore.adoc#_automatic_checkpointrestore_at_startup[Automatic
53-
checkpoint/restore at startup] and
58+
xref:integration/checkpoint-restore.adoc#_automatic_checkpointrestore_at_startup[Automatic checkpoint/restore at startup] and
5459
{spring-framework-api}++/context/support/DefaultLifecycleProcessor.html#CHECKPOINT_PROPERTY_NAME++[`DefaultLifecycleProcessor`]
5560
for details.
5661

5762
| `spring.context.exit`
5863
| Property for terminating the JVM when the context reaches a specific phase. See
59-
xref:integration/checkpoint-restore.adoc#_automatic_checkpointrestore_at_startup[Automatic
60-
checkpoint/restore at startup] and
64+
xref:integration/checkpoint-restore.adoc#_automatic_checkpointrestore_at_startup[Automatic checkpoint/restore at startup] and
6165
{spring-framework-api}++/context/support/DefaultLifecycleProcessor.html#EXIT_PROPERTY_NAME++[`DefaultLifecycleProcessor`]
6266
for details.
6367

Diff for: framework-platform/framework-platform.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ dependencies {
100100
api("org.apache.derby:derby:10.16.1.1")
101101
api("org.apache.derby:derbyclient:10.16.1.1")
102102
api("org.apache.derby:derbytools:10.16.1.1")
103-
api("org.apache.httpcomponents.client5:httpclient5:5.4")
104-
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3")
103+
api("org.apache.httpcomponents.client5:httpclient5:5.4.1")
104+
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3.1")
105105
api("org.apache.poi:poi-ooxml:5.2.5")
106106
api("org.apache.tomcat.embed:tomcat-embed-core:10.1.28")
107107
api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.28")

Diff for: spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.Constructor;
21+
import java.lang.reflect.Field;
2122
import java.lang.reflect.Method;
2223
import java.util.Map;
2324
import java.util.StringTokenizer;
@@ -37,6 +38,7 @@
3738

3839
import org.springframework.aop.framework.AopConfigException;
3940
import org.springframework.core.ParameterNameDiscoverer;
41+
import org.springframework.core.SpringProperties;
4042
import org.springframework.core.annotation.AnnotationUtils;
4143
import org.springframework.lang.Nullable;
4244

@@ -58,6 +60,23 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
5860
private static final Class<?>[] ASPECTJ_ANNOTATION_CLASSES = new Class<?>[] {
5961
Pointcut.class, Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class};
6062

63+
private static final String AJC_MAGIC = "ajc$";
64+
65+
/**
66+
* System property that instructs Spring to ignore ajc-compiled aspects
67+
* for Spring AOP proxying, restoring traditional Spring behavior for
68+
* scenarios where both weaving and AspectJ auto-proxying are enabled.
69+
* <p>The default is "false". Consider switching this to "true" if you
70+
* encounter double execution of your aspects in a given build setup.
71+
* Note that we recommend restructuring your AspectJ configuration to
72+
* avoid such double exposure of an AspectJ aspect to begin with.
73+
* @since 6.1.15
74+
*/
75+
public static final String IGNORE_AJC_PROPERTY_NAME = "spring.aop.ajc.ignore";
76+
77+
private static final boolean shouldIgnoreAjcCompiledAspects =
78+
SpringProperties.getFlag(IGNORE_AJC_PROPERTY_NAME);
79+
6180

6281
/** Logger available to subclasses. */
6382
protected final Log logger = LogFactory.getLog(getClass());
@@ -67,7 +86,8 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
6786

6887
@Override
6988
public boolean isAspect(Class<?> clazz) {
70-
return (AnnotationUtils.findAnnotation(clazz, Aspect.class) != null);
89+
return (AnnotationUtils.findAnnotation(clazz, Aspect.class) != null &&
90+
(!shouldIgnoreAjcCompiledAspects || !compiledByAjc(clazz)));
7191
}
7292

7393
@Override
@@ -114,6 +134,16 @@ private static AspectJAnnotation findAnnotation(Method method, Class<? extends A
114134
}
115135
}
116136

137+
private static boolean compiledByAjc(Class<?> clazz) {
138+
for (Field field : clazz.getDeclaredFields()) {
139+
System.out.println(clazz + ": " + field.getName());
140+
if (field.getName().startsWith(AJC_MAGIC)) {
141+
return true;
142+
}
143+
}
144+
return false;
145+
}
146+
117147

118148
/**
119149
* Enum for AspectJ annotation types.

Diff for: spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -303,6 +303,17 @@ public void registerCustomCache(String name, AsyncCache<Object, Object> cache) {
303303
this.cacheMap.put(name, adaptCaffeineCache(name, cache));
304304
}
305305

306+
/**
307+
* Remove the specified cache from this cache manager, applying to
308+
* custom caches as well as dynamically registered caches at runtime.
309+
* @param name the name of the cache
310+
* @since 6.1.15
311+
*/
312+
public void removeCache(String name) {
313+
this.customCacheNames.remove(name);
314+
this.cacheMap.remove(name);
315+
}
316+
306317
/**
307318
* Adapt the given new native Caffeine Cache instance to Spring's {@link Cache}
308319
* abstraction for the specified cache name.

Diff for: spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 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.
@@ -175,6 +175,15 @@ public Cache getCache(String name) {
175175
return cache;
176176
}
177177

178+
/**
179+
* Remove the specified cache from this cache manager.
180+
* @param name the name of the cache
181+
* @since 6.1.15
182+
*/
183+
public void removeCache(String name) {
184+
this.cacheMap.remove(name);
185+
}
186+
178187
private void recreateCaches() {
179188
for (Map.Entry<String, Cache> entry : this.cacheMap.entrySet()) {
180189
entry.setValue(createConcurrentMapCache(entry.getKey()));

Diff for: spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void setHttpContextFactory(BiFunction<HttpMethod, URI, HttpContext> httpC
237237

238238

239239
@Override
240-
@SuppressWarnings("deprecation")
240+
@SuppressWarnings("deprecation") // HttpClientContext.REQUEST_CONFIG
241241
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
242242
HttpClient client = getHttpClient();
243243

@@ -249,16 +249,20 @@ public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IO
249249
}
250250

251251
// Request configuration not set in the context
252-
if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
253-
// Use request configuration given by the user, when available
252+
if (!(context instanceof HttpClientContext clientContext && clientContext.getRequestConfig() != null) &&
253+
context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
254254
RequestConfig config = null;
255+
// Use request configuration given by the user, when available
255256
if (httpRequest instanceof Configurable configurable) {
256257
config = configurable.getConfig();
257258
}
258259
if (config == null) {
259260
config = createRequestConfig(client);
260261
}
261262
if (config != null) {
263+
if (context instanceof HttpClientContext clientContext) {
264+
clientContext.setRequestConfig(config);
265+
}
262266
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
263267
}
264268
}

0 commit comments

Comments
 (0)