File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
spring-aop/src/main/java/org/springframework/aop/aspectj/annotation Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -160,23 +160,12 @@ private MetadataAwareAspectInstanceFactory createAspectInstanceFactory(
160
160
}
161
161
162
162
/**
163
- * Get the singleton aspect instance for the supplied aspect type. An instance
164
- * is created if one cannot be found in the instance cache.
163
+ * Get the singleton aspect instance for the supplied aspect type.
164
+ * An instance is created if one cannot be found in the instance cache.
165
165
*/
166
166
private Object getSingletonAspectInstance (Class <?> aspectClass ) {
167
- // Quick check without a lock...
168
- Object instance = aspectCache .get (aspectClass );
169
- if (instance == null ) {
170
- synchronized (aspectCache ) {
171
- // To be safe, check within full lock now...
172
- instance = aspectCache .get (aspectClass );
173
- if (instance == null ) {
174
- instance = new SimpleAspectInstanceFactory (aspectClass ).getAspectInstance ();
175
- aspectCache .put (aspectClass , instance );
176
- }
177
- }
178
- }
179
- return instance ;
167
+ return aspectCache .computeIfAbsent (aspectClass ,
168
+ clazz -> new SimpleAspectInstanceFactory (clazz ).getAspectInstance ());
180
169
}
181
170
182
171
You can’t perform that action at this time.
0 commit comments