[ https://issues.apache.org/jira/browse/CAMEL-21926?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marco Bungart updated CAMEL-21926: ---------------------------------- Description: Since camel {{4.10.1}}, the following code: {code:java} public class MyTimerRoute extends RouteBuilder { @Override public void configure() { // @formatter:off from( timer("my-timer") .fixedRate(true) .period(Duration.ofSeconds(1).toMillis())) .process(exchange -> { AttachmentMessage message = exchange.getMessage(AttachmentMessage.class); Path filePath = Files.createTempFile("attachment", "tmp"); message.addAttachment("foo", new DataHandler(new FileDataSource(filePath.toFile()))); }) .process(exchange -> { AttachmentMessage message = exchange.getMessage(AttachmentMessage.class); message.removeAttachment("foo"); boolean hasAttachments = message.hasAttachments(); exchange.setProperty("hasAttachments", hasAttachments); exchange.setProperty("numAttachments", message.getAttachments().size()); }) .log("hasAttachment: ${exchangeProperty.hasAttachments}") .log("# attachments: ${exchangeProperty.numAttachments}"); // @formatter:on } } {code} produces the following, inconsistent output: {code} ... [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true ... {code} --- Reproducer: 1. Clone https://github.com/turing85/camel-attachment-bug: {code:bash} $ git clone https://github.com/turing85/camel-attachment-bug.git \ && camel-attachment-bug {code} 2. Notice that the camel version is set to {{4.10.1}}: {code:bash} $ grep -i '<camel.version>' pom.xml <camel.version>4.10.1</camel.version> {code} 3. build and start the application: {code:bash} $ mvn clean package && java -jar target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar {code} 4. Notice the inconsistent output: {code} ... [ main] MainSupport INFO Apache Camel (Main) 4.10.1 is starting [ main] BaseMainSupport INFO Classpath scanning enabled from base package: de.turing85.camel.attachment.bug [ main] AbstractCamelContext INFO Apache Camel 4.10.1 (camel-1) is starting [ main] AbstractCamelContext INFO Routes startup (total:1) [ main] AbstractCamelContext INFO Started route1 (timer://my-timer) [ main] AbstractCamelContext INFO Apache Camel 4.10.1 (camel-1) started in 8ms (build:0ms init:0ms start:8ms boot:376ms) [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 ... {code} 5. Downgrade camel to {{4.10.0}}: {code:bash} $ sed -i 's@<camel\.version>.*@<camel.version>4.10.0</camel.version>@g' pom.xml \ && grep -i '<camel.version>' pom.xml <camel.version>4.10.0</camel.version> {code} 6. Re-build and re-run the application: {code:bash} $ mvn clean package && java -jar target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar {code} 7. Notice that the output shows consistent information {code} ... [ main] MainSupport INFO Apache Camel (Main) 4.10.0 is starting [ main] BaseMainSupport INFO Classpath scanning enabled from base package: de.turing85.camel.attachment.bug [ main] AbstractCamelContext INFO Apache Camel 4.10.0 (camel-1) is starting [ main] AbstractCamelContext INFO Routes startup (total:1) [ main] AbstractCamelContext INFO Started route1 (timer://my-timer) [ main] AbstractCamelContext INFO Apache Camel 4.10.0 (camel-1) started in 9ms (build:0ms init:0ms start:9ms boot:380ms) [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 ... {code} --- FTR: https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel.204.2E10.2E1.20and.20attachments was: Since camel {{4.10.1}}, the following code: {code:java} public class MyTimerRoute extends RouteBuilder { @Override public void configure() { // @formatter:off from( timer("my-timer") .fixedRate(true) .period(Duration.ofSeconds(1).toMillis())) .process(exchange -> { AttachmentMessage message = exchange.getMessage(AttachmentMessage.class); Path filePath = Files.createTempFile("attachment", "tmp"); message.addAttachment("foo", new DataHandler(new FileDataSource(filePath.toFile()))); }) .process(exchange -> { AttachmentMessage message = exchange.getMessage(AttachmentMessage.class); message.removeAttachment("foo"); boolean hasAttachments = message.hasAttachments(); exchange.setProperty("hasAttachments", hasAttachments); exchange.setProperty("numAttachments", message.getAttachments().size()); }) .log("hasAttachment: ${exchangeProperty.hasAttachments}") .log("# attachments: ${exchangeProperty.numAttachments}"); // @formatter:on } } {code} produces the following, inconsistent output: {code} ... [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: true ... {code} --- Reproducer: 1. Clone https://github.com/turing85/camel-attachment-bug: {code:bash} $ git clone https://github.com/turing85/camel-attachment-bug.git \ && camel-attachment-bug {code} 2. Notice that the camel version is set to {{4.10.1}}: {code:bash} $ grep -i '<camel.version>' pom.xml <camel.version>4.10.1</camel.version> {code} 3. build and start the application: {code:bash} $ mvn clean package && java -jar target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar {code} 4. Notice the inconsistent output: {code} ... [ main] MainSupport INFO Apache Camel (Main) 4.10.1 is starting [ main] BaseMainSupport INFO Classpath scanning enabled from base package: de.turing85.camel.attachment.bug [ main] AbstractCamelContext INFO Apache Camel 4.10.1 (camel-1) is starting [ main] AbstractCamelContext INFO Routes startup (total:1) [ main] AbstractCamelContext INFO Started my-timer (timer://my-timer) [ main] AbstractCamelContext INFO Apache Camel 4.10.1 (camel-1) started in 10ms (build:0ms init:0ms start:10ms boot:408ms) [) thread #2 - timer://my-timer] my-timer INFO hasAttachment: true [) thread #2 - timer://my-timer] my-timer INFO # attachments: 0 [) thread #2 - timer://my-timer] my-timer INFO hasAttachment: true [) thread #2 - timer://my-timer] my-timer INFO # attachments: 0 [) thread #2 - timer://my-timer] my-timer INFO hasAttachment: true [) thread #2 - timer://my-timer] my-timer INFO # attachments: 0 ... {code} 5. Downgrade camel to {{4.10.0}}: {code:bash} $ sed -i 's@<camel\.version>.*@<camel.version>4.10.0</camel.version>@g' pom.xml \ && grep -i '<camel.version>' pom.xml <camel.version>4.10.0</camel.version> {code} 6. Re-build and re-run the application: {code:bash} $ mvn clean package && java -jar target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar {code} 7. Notice that the output shows consistent information {code} ... [ main] MainSupport INFO Apache Camel (Main) 4.10.0 is starting [ main] BaseMainSupport INFO Classpath scanning enabled from base package: de.turing85.camel.attachment.bug [ main] AbstractCamelContext INFO Apache Camel 4.10.0 (camel-1) is starting [ main] AbstractCamelContext INFO Routes startup (total:1) [ main] AbstractCamelContext INFO Started route1 (timer://my-timer) [ main] AbstractCamelContext INFO Apache Camel 4.10.0 (camel-1) started in 9ms (build:0ms init:0ms start:9ms boot:380ms) [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 [) thread #2 - timer://my-timer] route1 INFO hasAttachment: false [) thread #2 - timer://my-timer] route1 INFO # attachments: 0 ... {code} --- FTR: https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel.204.2E10.2E1.20and.20attachments > camel-attachment: inconsistent behaviour > ---------------------------------------- > > Key: CAMEL-21926 > URL: https://issues.apache.org/jira/browse/CAMEL-21926 > Project: Camel > Issue Type: Bug > Components: camel-attachments > Affects Versions: 4.10.1, 4.10.2, 4.10.3 > Reporter: Marco Bungart > Priority: Major > > Since camel {{4.10.1}}, the following code: > {code:java} > public class MyTimerRoute extends RouteBuilder { > @Override > public void configure() { > // @formatter:off > from( > timer("my-timer") > .fixedRate(true) > .period(Duration.ofSeconds(1).toMillis())) > .process(exchange -> { > AttachmentMessage message = > exchange.getMessage(AttachmentMessage.class); > Path filePath = Files.createTempFile("attachment", "tmp"); > message.addAttachment("foo", new DataHandler(new > FileDataSource(filePath.toFile()))); > }) > .process(exchange -> { > AttachmentMessage message = > exchange.getMessage(AttachmentMessage.class); > message.removeAttachment("foo"); > boolean hasAttachments = message.hasAttachments(); > exchange.setProperty("hasAttachments", hasAttachments); > exchange.setProperty("numAttachments", > message.getAttachments().size()); > }) > .log("hasAttachment: ${exchangeProperty.hasAttachments}") > .log("# attachments: ${exchangeProperty.numAttachments}"); > // @formatter:on > } > } > {code} > produces the following, inconsistent output: > {code} > ... > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > ... > {code} > --- > Reproducer: > 1. Clone https://github.com/turing85/camel-attachment-bug: > {code:bash} > $ git clone https://github.com/turing85/camel-attachment-bug.git \ > && camel-attachment-bug > {code} > 2. Notice that the camel version is set to {{4.10.1}}: > {code:bash} > $ grep -i '<camel.version>' pom.xml > <camel.version>4.10.1</camel.version> > {code} > 3. build and start the application: > {code:bash} > $ mvn clean package && java -jar > target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar > {code} > 4. Notice the inconsistent output: > {code} > ... > [ main] MainSupport INFO Apache > Camel (Main) 4.10.1 is starting > [ main] BaseMainSupport INFO > Classpath scanning enabled from base package: de.turing85.camel.attachment.bug > [ main] AbstractCamelContext INFO Apache > Camel 4.10.1 (camel-1) is starting > [ main] AbstractCamelContext INFO Routes > startup (total:1) > [ main] AbstractCamelContext INFO > Started route1 (timer://my-timer) > [ main] AbstractCamelContext INFO Apache > Camel 4.10.1 (camel-1) started in 8ms (build:0ms init:0ms start:8ms > boot:376ms) > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: true > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > ... > {code} > 5. Downgrade camel to {{4.10.0}}: > {code:bash} > $ sed -i 's@<camel\.version>.*@<camel.version>4.10.0</camel.version>@g' > pom.xml \ > && grep -i '<camel.version>' pom.xml > <camel.version>4.10.0</camel.version> > {code} > 6. Re-build and re-run the application: > {code:bash} > $ mvn clean package && java -jar > target/camel-attachment-bug-999-SNAPSHOT-executable-jar.jar > {code} > 7. Notice that the output shows consistent information > {code} > ... > [ main] MainSupport INFO Apache > Camel (Main) 4.10.0 is starting > [ main] BaseMainSupport INFO > Classpath scanning enabled from base package: de.turing85.camel.attachment.bug > [ main] AbstractCamelContext INFO Apache > Camel 4.10.0 (camel-1) is starting > [ main] AbstractCamelContext INFO Routes > startup (total:1) > [ main] AbstractCamelContext INFO > Started route1 (timer://my-timer) > [ main] AbstractCamelContext INFO Apache > Camel 4.10.0 (camel-1) started in 9ms (build:0ms init:0ms start:9ms > boot:380ms) > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: false > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: false > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > [) thread #2 - timer://my-timer] route1 INFO > hasAttachment: false > [) thread #2 - timer://my-timer] route1 INFO # > attachments: 0 > ... > {code} > --- > FTR: > https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/camel.204.2E10.2E1.20and.20attachments -- This message was sent by Atlassian Jira (v8.20.10#820010)