This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4877b9b8508e CAMEL-27909: camel-support - message dumps leave out the
CamelRestOpenAPI exchange property (#31169)
4877b9b8508e is described below
commit 4877b9b8508e64d0e81055e5c1d8ebea3bea53c8
Author: Serdar Gökay <[email protected]>
AuthorDate: Tue Dec 1 15:35:20 2026 +0300
CAMEL-27909: camel-support - message dumps leave out the CamelRestOpenAPI
exchange property (#31169)
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../org/apache/camel/util/MessageHelperTest.java | 27 ++++++++++++++++++++++
.../org/apache/camel/support/MessageHelper.java | 13 +++++++----
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/util/MessageHelperTest.java
b/core/camel-core/src/test/java/org/apache/camel/util/MessageHelperTest.java
index 83e1d0f4286d..04f58c833db3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/util/MessageHelperTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/util/MessageHelperTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.util;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
@@ -320,4 +321,30 @@ public class MessageHelperTest {
out = MessageHelper.dumpAsJSon(message, true);
assertTrue(out.contains("\"size\": 0"), "an empty text has a size of
0: " + out);
}
+
+ @Test
+ public void testDumpSkipsRestOpenApiProperty() {
+ // CAMEL-27909: the parsed contract is the same for every message, so
a dump does not render it
+ AtomicInteger rendered = new AtomicInteger();
+ Object contract = new Object() {
+ @Override
+ public String toString() {
+ rendered.incrementAndGet();
+ return "the whole contract";
+ }
+ };
+ Exchange exchange = new DefaultExchange(camelContext);
+ exchange.setProperty(Exchange.REST_OPENAPI, contract);
+ exchange.setProperty("order", "4711");
+ Message message = exchange.getIn();
+
+ String json = MessageHelper.dumpAsJSon(message, true, false, true, 2,
true, true, true, 0, true);
+ String xml = MessageHelper.dumpAsXml(message, true, false, true, 2,
true, true, true, 0);
+
+ assertTrue(json.contains("4711"), json);
+ assertTrue(xml.contains("4711"), xml);
+ assertFalse(json.contains(Exchange.REST_OPENAPI), json);
+ assertFalse(xml.contains(Exchange.REST_OPENAPI), xml);
+ assertEquals(0, rendered.get(), "the contract is never rendered");
+ }
}
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
index 681e72bfc833..f56575cb6552 100644
---
a/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
+++
b/core/camel-support/src/main/java/org/apache/camel/support/MessageHelper.java
@@ -58,6 +58,12 @@ public final class MessageHelper {
private static final String MESSAGE_HISTORY_HEADER = "%-40s %-30s %-50s
%-12s %-32s %-9s";
private static final String MESSAGE_HISTORY_OUTPUT = "%-40.40s %-30.30s
%-50.50s %12.12s %-32.32s %9.9s";
+ /**
+ * Exchange properties a message dump leaves out, as their values are too
big to render.
+ */
+ private static final Set<String> DUMP_SKIPPED_PROPERTIES = Set.of(
+ Exchange.MESSAGE_HISTORY, Exchange.GROUPED_EXCHANGE,
Exchange.FILE_EXCHANGE_FILE, Exchange.REST_OPENAPI);
+
/**
* Utility classes should not have a public constructor.
*/
@@ -551,9 +557,7 @@ public final class MessageHelper {
Map<String, Object> properties = new
TreeMap<>(message.getExchange().getAllProperties());
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String key = entry.getKey();
- // skip some special that are too big
- if (Exchange.MESSAGE_HISTORY.equals(key) ||
Exchange.GROUPED_EXCHANGE.equals(key)
- || Exchange.FILE_EXCHANGE_FILE.equals(key)) {
+ if (DUMP_SKIPPED_PROPERTIES.contains(key)) {
continue;
}
Object value = entry.getValue();
@@ -983,9 +987,8 @@ public final class MessageHelper {
// exchange properties
if (includeExchangeProperties) {
Map<String, Object> properties = new
TreeMap<>(message.getExchange().getAllProperties());
- Set<String> skipKeys = Set.of(Exchange.MESSAGE_HISTORY,
Exchange.GROUPED_EXCHANGE, Exchange.FILE_EXCHANGE_FILE);
JsonArray arr = serializeMapSection(properties, message,
allowCachedStreams, allowStreams, allowFiles, maxChars,
- true, skipKeys);
+ true, DUMP_SKIPPED_PROPERTIES);
if (!arr.isEmpty()) {
jo.put("exchangeProperties", arr);
}