Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camel-quarkus 3.19.1: problem with UnmarshalProcessor #7088

Open
turing85 opened this issue Mar 4, 2025 · 5 comments
Open

camel-quarkus 3.19.1: problem with UnmarshalProcessor #7088

turing85 opened this issue Mar 4, 2025 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@turing85
Copy link
Contributor

turing85 commented Mar 4, 2025

Bug description

Given the following processor (source (github.com)):

public class MyUnmarshalProcessor implements Processor {
  @Override
  public void process(Exchange exchange) throws Exception {
    exchange.setProperty(Exchange.CONTENT_TYPE, "text/plain");

    unmarshal(exchange);
    // exchange.setIn(exchange.getOut());
    AttachmentMessage msg = exchange.getIn(AttachmentMessage.class);
  }

  private void unmarshal(Exchange exchange) throws Exception {
    try (MimeMultipartDataFormat dataFormat = new MimeMultipartDataFormat()) {
      new UnmarshalProcessor(dataFormat).process(exchange);
    }
  }
}

and the following test (source (github.com)):

class MyUnmarshalProcessorTest extends CamelTestSupport {
  @Test
  void test() throws Exception {
    // GIVEN
    String expectedMessage = "Hello, world!";
    String body = """
        ------=_divider
        Content-Type: text/plain; charset=ISO-8859-15
        Content-Transfer-Encoding: 8bit

        %s
        ------=_divider
        Content-Type: application/octet-stream
        Content-Transfer-Encoding: base64
        Content-Disposition: attachment; filename=JMS_Normalized_Message_Properties
        Content-ID: JMS_Normalized_Message_Properties

        SGVsbG8sIHdvcmxkCg==
        ------=_divider--
        """.formatted(expectedMessage);
    Exchange exchange = ExchangeBuilder.anExchange(context())
        .withHeader(Exchange.CONTENT_TYPE,
            "multipart/related; type=\"text/plain\";boundary=\"----=_divider\"")
        .withBody(body).build();

    // when
    new MyUnmarshalProcessor().process(exchange);

    // then
    String actualMessage = exchange.getMessage().getBody(String.class);
    System.out.println(actualMessage);
    Truth.assertThat(actualMessage).isEqualTo(expectedMessage);
  }
}

This test succeeds with quarkus 3.18.4 (camel-quarkus 3.18.0, camel 4.9.0), but with quarkus 3.19.1 (camel-quarkus 3.19.0, camel 4.10.0):

$ ./mvnw clean test
...
[ERROR] Failures: 
[ERROR]   MyUnmarshalProcessorTest.test:40 expected:
    Hello, world!
but was:
    ------=_divider
    Content-Type: text/plain; charset=ISO-8859-15
    Content-Transfer-Encoding: 8bit
    
    Hello, world!
    ------=_divider
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=JMS_Normalized_Message_Properties
    Content-ID: JMS_Normalized_Message_Properties
    
    SGVsbG8sIHdvcmxkCg==
    ------=_divider--
...

Expected Behaviour

The test should succeed in quarkus 3.19.1.

Observed Behaviour

The test fails with the above error.

Reproducer

  1. clone https://github.com/turing85/camel-quarkus-unmarshal-processor
$ git clone https://github.com/turing85/camel-quarkus-unmarshal-processor.git && \
  cd camel-quarkus-unmarshal-processor
  1. Notice that the application is configured to run with quarkus 3.18.4:
$ cat pom.xml|grep -i "<quarkus.platform.version>"
        <quarkus.platform.version>3.19.1</quarkus.platform.version>
  1. Run the tests, observe that the tests succeed:
$ ./mvnw clean test
...
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.250 s -- in de.turing85.quarkus.camel.unmarshal.processor.MyUnmarshalProcessorTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
...
  1. Change to quarkus 3.19.1 by applying the follwing patch:
Subject: [PATCH] Change to quarkus 3.19.1
---
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pom.xml b/pom.xml
--- a/pom.xml        (revision 5716ae9e4cef2b696a1268cc3f785286e73e3c1e)
+++ b/pom.xml        (date 1741104327754)
@@ -35,7 +35,7 @@
         <!-- Quarkus versions -->
         <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
         <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
-        <quarkus.platform.version>3.18.4</quarkus.platform.version>
+        <quarkus.platform.version>3.19.1</quarkus.platform.version>

         <!-- Camel Quarkus -->
         <camel-quarkus-platform.group-id>io.quarkus.platform</camel-quarkus-platform.group-id>
  1. Re-run the test, notice that it fails:
$ ./mvnw clean test
...
[ERROR] Failures: 
[ERROR]   MyUnmarshalProcessorTest.test:40 expected:
    Hello, world!
but was:
    ------=_divider
    Content-Type: text/plain; charset=ISO-8859-15
    Content-Transfer-Encoding: 8bit
    
    Hello, world!
    ------=_divider
    Content-Type: application/octet-stream
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=JMS_Normalized_Message_Properties
    Content-ID: JMS_Normalized_Message_Properties
    
    SGVsbG8sIHdvcmxkCg==
    ------=_divider-- 
...
  1. Un-comment this line (github.com) by applying the following patch:
Subject: [PATCH] Change to quarkus 3.19.1, prevent the issue
---
Index: src/main/java/de/turing85/quarkus/camel/unmarshal/processor/MyUnmarshalProcessor.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/de/turing85/quarkus/camel/unmarshal/processor/MyUnmarshalProcessor.java b/src/main/java/de/turing85/quarkus/camel/unmarshal/processor/MyUnmarshalProcessor.java
--- a/src/main/java/de/turing85/quarkus/camel/unmarshal/processor/MyUnmarshalProcessor.java        (revision af1ac2437160d83609923a1c76f498dc72eb73fb)
+++ b/src/main/java/de/turing85/quarkus/camel/unmarshal/processor/MyUnmarshalProcessor.java        (date 1741104613664)
@@ -16,7 +16,7 @@
     exchange.setProperty(Exchange.CONTENT_TYPE, "text/plain");

     unmarshal(exchange);
-    // exchange.setIn(exchange.getOut());
+    exchange.setIn(exchange.getOut());
     AttachmentMessage msg = exchange.getIn(AttachmentMessage.class);
     for (Map.Entry<String, DataHandler> attachment : msg.getAttachments().entrySet()) {
       exchange.setProperty(attachment.getKey(), attachment.getValue().getContent());
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pom.xml b/pom.xml
--- a/pom.xml        (revision af1ac2437160d83609923a1c76f498dc72eb73fb)
+++ b/pom.xml        (date 1741104609285)
@@ -35,7 +35,7 @@
         <!-- Quarkus versions -->
         <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
         <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
-        <quarkus.platform.version>3.18.4</quarkus.platform.version>
+        <quarkus.platform.version>3.19.1</quarkus.platform.version>

         <!-- Camel Quarkus -->
         <camel-quarkus-platform.group-id>io.quarkus.platform</camel-quarkus-platform.group-id>
  1. Re-run the test, notice that it succeeds again:
$ ./mvnw clean test
...
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.250 s -- in de.turing85.quarkus.camel.unmarshal.processor.MyUnmarshalProcessorTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
...

Furhter inforomation

  • I was not able to reproduce the bug with pure camel, only with camel-quarkus
  • The change in behaviour seems to only affect camel-quarkus in version 3.19.0 / camel 4.10.0, since it worked fine with camel-quarkus 3.18.0 / camel 4.9.0
@turing85 turing85 added the bug Something isn't working label Mar 4, 2025
@turing85
Copy link
Contributor Author

turing85 commented Mar 4, 2025

/cc @jamesnetherton

@zhfeng
Copy link
Contributor

zhfeng commented Mar 5, 2025

Hmm, it smells like an issue with camel since I just override the camel-attachments with 4.9.0, and the test is back to work. cc @davsclaus

@zhfeng
Copy link
Contributor

zhfeng commented Mar 5, 2025

I think it could be fixed by apache/camel@3e95409#diff-dc0d15613b3fdef9a2071f6a29e6ef033b1e607e89032d83977c3a921a196e1a and it is with 4.10.1

@zhfeng
Copy link
Contributor

zhfeng commented Mar 5, 2025

So @turing85 can you check with the SNAPSHOT build of camel-quarkus?

@jamesnetherton
Copy link
Contributor

So @turing85 can you check with the SNAPSHOT build of camel-quarkus?

I checked and it is indeed fixed in Camel 4.10.1. So it'll be available when we release CQ 3.20.0 later this month.

@jamesnetherton jamesnetherton added this to the 3.20.0 milestone Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants