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

   [CAMEL-26654](https://issues.apache.org/jira/browse/CAMEL-26654)
   
   ### What was wrong
   
   `DataLakeFileOperations.getFile` chose between "download into the body" and 
"return an `InputStream`" with `message.getBody(OutputStream.class)`. That is a 
type conversion, not a type check: a `java.io.File`, a `java.nio.file.Path`, or 
the `GenericFile` set by a `file:` consumer converts to a stream that truncates 
the file. The remote file was then downloaded into it. So 
`from("file:in?noop=true").to("azure-storage-datalake:...?operation=getFile")` 
emptied the consumed local file and wrote the remote content into it, instead 
of returning the remote file as an `InputStream`.
   
   CAMEL-25933 (#28372) fixed the same defect in camel-azure-storage-blob 
`getBlob`, but did not touch datalake.
   
   ### What changed
   
   - `getFile` writes into the body only when the body **is** an `OutputStream` 
(`message.getBody() instanceof OutputStream os`). This is the same one-line 
change CAMEL-25933 made in `BlobOperations.getBlob`. Any other body, and no 
body, gets the `InputStream` from `openInputStream`, as before.
   - Not affected: the consumer (its exchange body is empty when it calls 
`getFile`) and an explicit `OutputStream` body.
   
   ### Tests
   
   `DataLakeFileOperationTest` uses a mocked `DataLakeFileClientWrapper` and 
has 5 new tests: `File`, `Path` and `GenericFile` bodies (the local file stays 
unchanged and an `InputStream` of the remote file comes back), plus 2 controls 
(an `OutputStream` body is written to, and no body gives an `InputStream`).
   
   - On the main code, the 3 body tests fail with `expected: <local file 
content> but was: <remote file content>`. The 2 controls pass.
   - With the fix, all 16 tests in the class pass. The module has 32 unit tests 
and 10 ITs (Floci AZ container); all pass.
   - I also ran a throwaway route `file:dir?noop=true` -> `getFile` with a 
mocked `DataLakeServiceClient`. On main, the consumed file ends up empty. With 
the fix, it keeps its content and the body is the remote content.
   
   ### Docs and upgrade guide
   
   - `azure-storage-datalake-component.adoc` (and its catalog copy): the 
`getFile` row and the `getFile` example now say that only an `OutputStream` 
body is written to, and point to `downloadToFile` or a `file` endpoint to save 
a file locally. The same section said the `InputStream` path needs query 
acceleration to be registered. It does not: that applies to 
`openQueryInputStream` only. I dropped that clause.
   - 4.24 upgrade guide: new entry "camel-azure-storage-datalake - getFile 
writes only into an OutputStream body", worded like the existing getBlob entry.
   
   ### Backport
   
   This could be backported to camel-4.18.x and camel-4.22.x: the same line is 
in 4.18.5, 4.22.2 and 4.23.0. CAMEL-25933 (the getBlob fix) is on main only, so 
if this goes to the LTS branches, the getBlob change should probably go with it.
   
   _Claude Code on behalf of Federico Mariani_
   


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