gnodet-bot commented on code in PR #28896:
URL: https://github.com/apache/camel/pull/28896#discussion_r4447198341
##########
components/camel-camunda/src/main/java/org/apache/camel/component/camunda/processor/ProcessProcessor.java:
##########
@@ -32,23 +31,20 @@ public ProcessProcessor(CamundaEndpoint endpoint) {
public void process(Exchange exchange) throws Exception {
ProcessRequest message = null;
- if (exchange.getMessage().getBody() instanceof ProcessRequest) {
- message = exchange.getMessage().getBody(ProcessRequest.class);
- } else if (exchange.getMessage().getBody() instanceof ProcessResponse)
{
+ Object body = exchange.getMessage().getBody();
+ if (body instanceof ProcessRequest) {
+ message = (ProcessRequest) body;
+ } else if (body instanceof ProcessResponse) {
+ ProcessResponse response = (ProcessResponse) body;
message = new ProcessRequest();
- message.setProcessInstanceKey(((ProcessResponse)
exchange.getMessage().getBody()).getProcessInstanceKey());
- message.setProcessId(((ProcessResponse)
exchange.getMessage().getBody()).getProcessId());
- message.setProcessVersion(((ProcessResponse)
exchange.getMessage().getBody()).getProcessVersion());
- message.setProcessKey(((ProcessResponse)
exchange.getMessage().getBody()).getProcessKey());
- } else if (exchange.getMessage().getBody() instanceof String) {
- try {
- String bodyString =
exchange.getMessage().getBody(String.class);
-
- message = objectMapper.readValue(bodyString,
ProcessRequest.class);
- } catch (JsonProcessingException jsonProcessingException) {
- throw new IllegalArgumentException("Cannot convert body to
ProcessMessage", jsonProcessingException);
- }
- } else {
+ message.setProcessInstanceKey(response.getProcessInstanceKey());
+ message.setProcessId(response.getProcessId());
+ message.setProcessVersion(response.getProcessVersion());
+ message.setProcessKey(response.getProcessKey());
+ } else if (body != null) {
+ message = readJson(exchange, ProcessRequest.class, "Cannot convert
body to ProcessMessage");
Review Comment:
💬 **Nit: error message says `ProcessMessage` but the class is
`ProcessRequest`**
The string `"Cannot convert body to ProcessMessage"` was carried over from
the old code, but `ProcessRequest` is what the deserialization targets (and
what the method's `type` argument says). All other processors are consistent —
`"Cannot convert body to JobRequest"`, `"Cannot convert body to
MessageRequest"`. Consider fixing to `"Cannot convert body to ProcessRequest"`
to avoid confusion when this exception surfaces in logs.
```suggestion
message = readJson(exchange, ProcessRequest.class, "Cannot
convert body to ProcessRequest");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]