提交 d9eaa5f3 编写于 作者: S Sam Brannen

Use Map.computeIfAbsent() in SpringClassRule

Replace manual synchronization block in SpringClassRule with Java 8's
Map.computeIfAbsent().

Issue: SPR-12421
上级 1cf503f9
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册