You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2019/12/24 16:34:18 UTC
[logging-log4j2] branch master updated: Use computeIfAbsent
This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 96a3a94 Use computeIfAbsent
96a3a94 is described below
commit 96a3a9491def70a4a15721259afa4783fc1b5f61
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Tue Dec 24 10:34:03 2019 -0600
Use computeIfAbsent
Signed-off-by: Matt Sicker <bo...@gmail.com>
---
.../org/apache/logging/log4j/plugins/processor/PluginService.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/processor/PluginService.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/processor/PluginService.java
index ae9d094..1884ff6 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/processor/PluginService.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/processor/PluginService.java
@@ -31,12 +31,9 @@ public abstract class PluginService {
PluginEntry[] entries = getEntries();
for (PluginEntry entry : entries) {
String category = entry.getCategory().toLowerCase();
- if (!categories.containsKey(category)) {
- categories.put(category, new LinkedList<>());
- }
try {
Class<?> clazz = this.getClass().getClassLoader().loadClass(entry.getClassName());
- List<PluginType<?>> list = categories.get(category);
+ List<PluginType<?>> list = categories.computeIfAbsent(category, ignored -> new LinkedList<>());
PluginType<?> type = new PluginType<>(entry, clazz, entry.getName());
list.add(type);
} catch (ClassNotFoundException ex) {