Avoid multiple volatile reads/writes in a row where only one is enough

This commit is contained in:
Сергей Цыпанов
2020-10-09 16:11:00 +03:00
committed by Juergen Hoeller
parent f2f84bfa7a
commit e1f51b4bf8
3 changed files with 9 additions and 10 deletions

View File

@@ -155,8 +155,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
* @param name the name of the cache to be added
*/
private void updateCacheNames(String name) {
Set<String> cacheNames = new LinkedHashSet<>(this.cacheNames.size() + 1);
cacheNames.addAll(this.cacheNames);
Set<String> cacheNames = new LinkedHashSet<>(this.cacheNames);
cacheNames.add(name);
this.cacheNames = Collections.unmodifiableSet(cacheNames);
}