This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.7.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.7.x by this push:
     new 6cb3654  CAMEL-16034: Using MDC would take up too much memory. Thanks 
to Benjamin Graf for the test case.
6cb3654 is described below

commit 6cb3654ed92b22175c5f047d74ae4c565ed3ca6f
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Feb 3 11:29:13 2021 +0100

    CAMEL-16034: Using MDC would take up too much memory. Thanks to Benjamin 
Graf for the test case.
---
 .../camel/impl/engine/CamelInternalProcessor.java  |  6 +--
 .../impl/engine/SharedCamelInternalProcessor.java  |  6 +--
 .../issues/MDCUnitLoggingOutOfMemoryTest.java      | 53 ++++++++++++++++++++++
 3 files changed, 57 insertions(+), 8 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index ac2014b..8fba8fe 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -316,10 +316,8 @@ public class CamelInternalProcessor extends 
DelegateAsyncProcessor implements In
 
             // optimize to only do after uow processing if really needed
             if (beforeAndAfter) {
-                reactiveExecutor.schedule(() -> {
-                    // execute any after processor work (in current thread, 
not in the callback)
-                    uow.afterProcess(processor, exchange, callback, false);
-                });
+                // execute any after processor work (in current thread, not in 
the callback)
+                uow.afterProcess(processor, exchange, callback, false);
             }
 
             if (LOG.isTraceEnabled()) {
diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SharedCamelInternalProcessor.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SharedCamelInternalProcessor.java
index 61e7faf..449c1ac 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SharedCamelInternalProcessor.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SharedCamelInternalProcessor.java
@@ -222,10 +222,8 @@ public class SharedCamelInternalProcessor implements 
SharedInternalProcessor {
 
             // optimize to only do after uow processing if really needed
             if (beforeAndAfter) {
-                reactiveExecutor.schedule(() -> {
-                    // execute any after processor work (in current thread, 
not in the callback)
-                    uow.afterProcess(processor, exchange, callback, sync);
-                });
+                // execute any after processor work (in current thread, not in 
the callback)
+                uow.afterProcess(processor, exchange, callback, sync);
             }
 
             if (LOG.isTraceEnabled()) {
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/issues/MDCUnitLoggingOutOfMemoryTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/issues/MDCUnitLoggingOutOfMemoryTest.java
new file mode 100644
index 0000000..8664f66
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/issues/MDCUnitLoggingOutOfMemoryTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.issues;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+@Disabled("CAMEL-16034: Manual test")
+public class MDCUnitLoggingOutOfMemoryTest extends ContextTestSupport {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                context.setUseMDCLogging(true);
+
+                from("direct:foo")
+                        .split().body().streaming()
+                        .log("Hello split index ${headers.CamelSplitIndex}");
+            }
+        };
+    }
+
+    @Test
+    public void testMDCLogging() throws Exception {
+        List<String> list = new ArrayList<>();
+        for (int i = 0; i < 1_000_000; i++) {
+            list.add("test");
+        }
+
+        template.sendBody("direct:foo", list);
+    }
+}

Reply via email to