mayurbm commented on PR #25555:
URL: https://github.com/apache/camel/pull/25555#issuecomment-5442052573
@davsclaus The previous fix (null check) was insufficient. Here is the real
root cause and the corrected fix:
**Root cause**: `documentTc.convertTo(Document.class, exchange, value)`
returns `Void.TYPE` (not `null`) when the `allowNull=true` prolog guard
short-circuits via the bulk loader. The cast to `Document` on the typed
assignment line throws `ClassCastException` *before* the null check even runs —
hence the test kept failing on all 3 reruns.
**Fix** (committed `f8408e0`): receive the result as `Object` and use an
`instanceof` pattern match to accept only a real `Document`, treating
`null`/`Void.TYPE` as a miss and falling through to the next candidate:
```java
Object result = documentTc.convertTo(Document.class, exchange, value);
if (result instanceof Document document) {
return (T) documentToCxfPayload(document, exchange);
}
```
This makes `testInvalidByteArrayToCxfPayload` return `null` as expected,
while valid XML byte arrays still convert to `CxfPayload` correctly.
--
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]