You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/04/18 06:50:47 UTC
[james-project] 10/11: [PERF] MDCBuilder: fully flatten its structure
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ea02a426c0f2eac98226baa298e882d5bedcabe8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Apr 11 15:36:00 2022 +0700
[PERF] MDCBuilder: fully flatten its structure
---
.../src/main/java/org/apache/james/util/MDCBuilder.java | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/server/container/util/src/main/java/org/apache/james/util/MDCBuilder.java b/server/container/util/src/main/java/org/apache/james/util/MDCBuilder.java
index bff52f2084..5d7c625f26 100644
--- a/server/container/util/src/main/java/org/apache/james/util/MDCBuilder.java
+++ b/server/container/util/src/main/java/org/apache/james/util/MDCBuilder.java
@@ -31,7 +31,6 @@ import org.slf4j.MDC;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
public class MDCBuilder {
@@ -92,7 +91,6 @@ public class MDCBuilder {
}
private final ImmutableMap.Builder<String, String> contextMap = ImmutableMap.builder();
- private final ImmutableList.Builder<MDCBuilder> nestedBuilder = ImmutableList.builder();
private MDCBuilder() {
@@ -107,7 +105,7 @@ public class MDCBuilder {
*/
@Deprecated
public MDCBuilder addContext(MDCBuilder nested) {
- this.nestedBuilder.add(nested);
+ this.contextMap.putAll(nested.contextMap.build());
return this;
}
@@ -128,7 +126,7 @@ public class MDCBuilder {
}
public MDCBuilder addToContext(MDCBuilder nested) {
- this.nestedBuilder.add(nested);
+ this.contextMap.putAll(nested.contextMap.build());
return this;
}
@@ -146,16 +144,7 @@ public class MDCBuilder {
@VisibleForTesting
Map<String, String> buildContextMap() {
- ImmutableList<MDCBuilder> nested = nestedBuilder.build();
- if (nested.isEmpty()) {
- return contextMap.build();
- }
-
- ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
- nested.forEach(mdcBuilder -> result.putAll(mdcBuilder.buildContextMap()));
- return result
- .putAll(contextMap.build())
- .build();
+ return contextMap.build();
}
public <T> T execute(Supplier<T> supplier) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org