Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Information Provided
-
3.20.4
-
None
-
None
-
Moderate
Description
In Camel 2, when the form was submitted, the payload was able to be presented as a java.util.Map like this:
Map map = httpMessage.getBody(Map.class);
In Camel 3.20.4 this doesn't work.
I've created a little github project to demonstrate and reproduce the error. In the project's pom.xml file you can easily switch the Camel versions to see how version 2.24.0 behaves as expected in a true Camel manner, and 3.20.4 does not.
In essence, the code to check the behavior is like below. form.html is a simplest POST web form.
HttpMessage http = exchange.getIn(HttpMessage.class); HttpServletRequest request = http.getRequest(); String method = request.getMethod(); if ("POST".equals(method) || "PUT".equals(method)) { Map map = http.getBody(Map.class); String string = http.getBody(String.class); http.setHeader(Exchange.CONTENT_TYPE, "text/plain"); http.setBody("json: " + mapper.writeValueAsString(map) + ", and string:" + string); } else { http.setHeader(Exchange.CONTENT_TYPE, "text/html"); http.setBody(this.getClass().getResourceAsStream("form.html")); }
It should print the jsonified form POST payload, but doesn't for the Camel 3.