File tree Expand file tree Collapse file tree 2 files changed +6
-14
lines changed
spring-context-support/src/main/java/org/springframework/cache/caffeine
spring-context/src/main/java/org/springframework/cache/concurrent Expand file tree Collapse file tree 2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -189,13 +189,11 @@ public Collection<String> getCacheNames() {
189
189
@ Override
190
190
@ Nullable
191
191
public Cache getCache (String name ) {
192
- if (this .dynamic ) {
193
- Cache cache = this .cacheMap .get (name );
194
- return (cache != null ) ? cache : this .cacheMap .computeIfAbsent (name , this ::createCaffeineCache );
195
- }
196
- else {
197
- return this .cacheMap .get (name );
192
+ Cache cache = this .cacheMap .get (name );
193
+ if (cache == null && this .dynamic ) {
194
+ cache = this .cacheMap .computeIfAbsent (name , this ::createCaffeineCache );
198
195
}
196
+ return cache ;
199
197
}
200
198
201
199
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2023 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.
@@ -166,13 +166,7 @@ public Collection<String> getCacheNames() {
166
166
public Cache getCache (String name ) {
167
167
Cache cache = this .cacheMap .get (name );
168
168
if (cache == null && this .dynamic ) {
169
- synchronized (this .cacheMap ) {
170
- cache = this .cacheMap .get (name );
171
- if (cache == null ) {
172
- cache = createConcurrentMapCache (name );
173
- this .cacheMap .put (name , cache );
174
- }
175
- }
169
+ cache = this .cacheMap .computeIfAbsent (name , this ::createConcurrentMapCache );
176
170
}
177
171
return cache ;
178
172
}
You can’t perform that action at this time.
0 commit comments