oscerd opened a new pull request, #29217:
URL: https://github.com/apache/camel/pull/29217

   Fixes the camel-google-calendar part of 
[CAMEL-26300](https://issues.apache.org/jira/browse/CAMEL-26300), found by the 
runtime tests of the body types of the data type transformers (CAMEL-25928). 
CAMEL-26300 is fixed with one PR per component.
   
   Fixes the camel-google item of 
[CAMEL-26300](https://issues.apache.org/jira/browse/CAMEL-26300), found by the 
runtime tests of the body types of the data type transformers (CAMEL-25928).
   
   ## 1. google-calendar-stream:application-cloudevents throws a 
NullPointerException on a body that is not an Event
   
   **Was:** `GoogleCalendarStreamCloudEventDataTypeTransformer` read the 
CloudEvent subject with `message.getBody(Event.class).getEventType()`. A body 
that is not a Google Calendar `Event`, or no body, converted to `null`, so the 
transformer failed with a bare `NullPointerException`, after it had already set 
the CloudEvent id, version, type and source headers.
   
   **Now:** the transformer checks the body first. A body that is not an 
`Event` fails with a `CamelExecutionException` that says so and names the class 
of the body: "The body must be a Google Calendar Event, such as the body of the 
google-calendar-stream consumer, to read the CloudEvent subject from, but was: 
java.lang.String". The message names the class only, never the content of the 
body, and no CloudEvent header is set on a message that fails. An `Event` body 
works as before; the `google-calendar-stream` consumer always gives one, so 
routes that use the transformer after that consumer are not affected.
   
   ## Tests
   
   `GoogleCalendarStreamCloudEventDataTypeTransformerTest`: a String, a `Map` 
and a null body each fail with a `CamelExecutionException` with the message 
above. The message names the class of the body and not its content, and no 
CloudEvent header is set. `theBodyTypesSayTheBody` now expects the 
`CamelExecutionException` where it expected the `NullPointerException`. An 
`Event` body still gets its headers, as before.
   
   Revert check: with the change to `src/main` reverted, 2 of the 2 new or 
changed tests fail with the old `NullPointerException`.
   
   Module: camel-google-calendar 13 tests, 0 failures.
   
   ## Docs and generated files
   
   - The body types of the transformer already said that another body fails, so 
they and the generated `google-calendar-stream-application-cloudevents.json` 
are unchanged.
   - Upgrade guide entry for 4.24, as the exception type changes from 
`NullPointerException` to `CamelExecutionException`.
   
   ## Not changed
   
   - `CamelExecutionException` is used, as in the `google-mail` and 
`google-sheets` transformers, rather than the checked `InvalidPayloadException` 
of `getMandatoryBody`, which would add a checked exception to the signature of 
the public `transform` method.
   - The CloudEvent source is still built from the `CamelGoogleCalendarEventId` 
header; the issue covers only the failure on another body.
   
   Main only, as the other fixes of the CAMEL-24961 follow-ups.
   
   Main only, as the other fixes of the CAMEL-24961 follow-ups.
   
   _Claude Code on behalf of Andrea Cosentino (oscerd)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to