Polishing

Closes gh-24543
This commit is contained in:
ZhangT 2020-02-18 00:33:39 +08:00 committed by GitHub
parent 9e7ab4d308
commit 6add7b4dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 23 deletions

View File

@ -87,7 +87,7 @@ public class TrickyAspectJPointcutExpressionTests {
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl");
// Then try again with a different class loader on the target...
SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader());
SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(TestServiceImpl.class.getClassLoader());
// Make sure the interface is loaded from the parent class loader
loader.excludeClass(TestService.class.getName());
loader.excludeClass(TestException.class.getName());

View File

@ -70,11 +70,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
@Override
public void aliasRegistered(AliasDefinition aliasDefinition) {
List<AliasDefinition> aliases = this.aliasMap.get(aliasDefinition.getBeanName());
if (aliases == null) {
aliases = new ArrayList<>();
this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
}
List<AliasDefinition> aliases = this.aliasMap.computeIfAbsent(aliasDefinition.getBeanName(), k -> new ArrayList<>());
aliases.add(aliasDefinition);
}

View File

@ -113,11 +113,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
builder.setUnless(getAttributeValue(opElement, "unless", ""));
builder.setSync(Boolean.parseBoolean(getAttributeValue(opElement, "sync", "false")));
Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
if (col == null) {
col = new ArrayList<>(2);
cacheOpMap.put(nameHolder, col);
}
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
col.add(builder.build());
}
@ -140,11 +136,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
builder.setBeforeInvocation(Boolean.parseBoolean(after.trim()));
}
Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
if (col == null) {
col = new ArrayList<>(2);
cacheOpMap.put(nameHolder, col);
}
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
col.add(builder.build());
}
@ -158,11 +150,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
parserContext.getReaderContext(), new CachePutOperation.Builder());
builder.setUnless(getAttributeValue(opElement, "unless", ""));
Collection<CacheOperation> col = cacheOpMap.get(nameHolder);
if (col == null) {
col = new ArrayList<>(2);
cacheOpMap.put(nameHolder, col);
}
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
col.add(builder.build());
}

View File

@ -85,8 +85,7 @@ public class ConcurrentMapCacheTests
assertThat(serializeCache.isStoreByValue()).isTrue();
Object key = createRandomKey();
List<String> content = new ArrayList<>();
content.addAll(Arrays.asList("one", "two", "three"));
List<String> content = new ArrayList<>(Arrays.asList("one", "two", "three"));
serializeCache.put(key, content);
content.remove(0);
List<String> entry = (List<String>) serializeCache.get(key).get();