Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-21318

camel-platform-http-starter executed on multiple async threads

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      The actual implementation of camel-platform-http-starter is not working as expected, in particular, when using undertow for example, after a couple of request the following exception is thrown:

      2024-10-03T15:13:32.116+02:00  WARN 981444 --- [onPool-worker-1] c.c.p.h.s.SpringBootPlatformHttpConsumer : Error handling request due to: Invalid parameter, expected to be a pair but was hello
      
      java.lang.IllegalArgumentException: Invalid parameter, expected to be a pair but was hello
      	at org.apache.camel.http.common.DefaultHttpBinding.readFormUrlEncodedBody(DefaultHttpBinding.java:294) ~[camel-http-common-4.8.0.redhat-00004.jar!/:4.8.0.redhat-00004]
      	at org.apache.camel.http.common.DefaultHttpBinding.readRequest(DefaultHttpBinding.java:129) ~[camel-http-common-4.8.0.redhat-00004.jar!/:4.8.0.redhat-00004]
      	at org.apache.camel.component.platform.http.springboot.PlatformHttpMessage.init(PlatformHttpMessage.java:64) ~[camel-platform-http-starter-4.8.0.redhat-00010.jar!/:4.8.0.redhat-00010]
      	at org.apache.camel.component.platform.http.springboot.PlatformHttpMessage.<init>(PlatformHttpMessage.java:39) ~[camel-platform-http-starter-4.8.0.redhat-00010.jar!/:4.8.0.redhat-00010]
      	at org.apache.camel.component.platform.http.springboot.SpringBootPlatformHttpConsumer.handleService(SpringBootPlatformHttpConsumer.java:91) ~[camel-platform-http-starter-4.8.0.redhat-00010.jar!/:4.8.0.redhat-00010]
      	at org.apache.camel.component.platform.http.springboot.SpringBootPlatformHttpConsumer.lambda$service$0(SpringBootPlatformHttpConsumer.java:66) ~[camel-platform-http-starter-4.8.0.redhat-00010.jar!/:4.8.0.redhat-00010]
      	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[na:na]
      	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[na:na]
      	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[na:na]
      	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[na:na]
      	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[na:na]
      	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[na:na]
      	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[na:na]
      

      The route to reproduce this issue is the following, a really trivial one:

      rest().post("/message").consumes("text/plain").to("direct:route");
              from("direct:route").log("${body}");
      

      Analyzing the stacktrace you can notice that we are mixing Async execution via CompletableFuture and non-Async Spring Boot code, therefore a single request is executed on multiple threads not handled by the underlying server or spring boot, that causes the concurrent modification exception.

      Attachments

        Issue Links

          Activity

            People

              Federico Mariani Federico Mariani
              Federico Mariani Federico Mariani
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: