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

   # Description
   
   [CAMEL-25304](https://issues.apache.org/jira/browse/CAMEL-25304)
   
   `BarcodeDataFormat.readImage` converted the input stream with 
`typeConverter.mandatoryConvertTo(BufferedInputStream.class, stream)`. The 
stream is a `BufferedInputStream` only for a file body; there is no converter 
from a `ByteArrayInputStream` or a stream cache. So unmarshal failed with 
`NoTypeConversionAvailableException` for a `byte[]` body, an `InputStream` body 
(for example an HTTP upload), and for `.marshal(barcode).unmarshal(barcode)` in 
one route. The existing tests only read files.
   
   This change passes the stream to `ImageIO.read`, which reads any input 
stream. File bodies are read as before. The stream is closed by the caller as 
before (`UnmarshalProcessor`, or `DataFormat.unmarshal(Exchange, Object)` for a 
converted body); `ImageIO.read(InputStream)` does not close it.
   
   Tests: new `BarcodeUnmarshalStreamTest` (byte array, input stream, marshal 
then unmarshal in one route): all three fail without the change and pass with 
it; the existing file-based tests are the control; module: 29 tests pass.
   
   Found while checking the round trip `unmarshal(marshal(text)) = text` of the 
data format (Lean 4 model in CAMEL-25303): the round trip could not be run in a 
route.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the affected module, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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