Use Map.computeIfAbsent() in SpringClassRule
Replace manual synchronization block in SpringClassRule with Java 8's Map.computeIfAbsent(). Issue: SPR-12421
This commit is contained in:
@@ -210,14 +210,7 @@ public class SpringClassRule implements TestRule {
|
||||
*/
|
||||
static TestContextManager getTestContextManager(Class<?> testClass) {
|
||||
Assert.notNull(testClass, "testClass must not be null");
|
||||
synchronized (testContextManagerCache) {
|
||||
TestContextManager testContextManager = testContextManagerCache.get(testClass);
|
||||
if (testContextManager == null) {
|
||||
testContextManager = new TestContextManager(testClass);
|
||||
testContextManagerCache.put(testClass, testContextManager);
|
||||
}
|
||||
return testContextManager;
|
||||
}
|
||||
return testContextManagerCache.computeIfAbsent(testClass, TestContextManager::new);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user