gnodet-bot commented on code in PR #28031:
URL: https://github.com/apache/camel/pull/28031#discussion_r4305107729


##########
components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java:
##########
@@ -331,11 +337,36 @@ private void addEntryToZip(File zipFile, String 
entryName, byte[] buffer, String
             Path parent = dest.getParent();
             if (parent != null) {
                 Files.createDirectories(parent);
+                dest = freeEntryName(dest);
                 Files.write(dest, buffer, StandardOpenOption.CREATE, 
StandardOpenOption.TRUNCATE_EXISTING);

Review Comment:
   💡 Same observation as `addFileToZip`: `freeEntryName(dest)` guarantees 
`dest` does not exist, so `TRUNCATE_EXISTING` will never fire. `CREATE` alone 
is sufficient here. Consider simplifying to `Files.write(dest, buffer, 
StandardOpenOption.CREATE)` or leaving a comment clarifying why 
`TRUNCATE_EXISTING` is retained.



##########
components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java:
##########
@@ -316,6 +321,7 @@ private void addFileToZip(File zipFile, File file, String 
fileName) throws IOExc
             Path parent = dest.getParent();
             if (parent != null) {
                 Files.createDirectories(parent);
+                dest = freeEntryName(dest);
                 Files.copy(file.toPath(), dest, 
StandardCopyOption.REPLACE_EXISTING);

Review Comment:
   💡 After `freeEntryName(dest)` returns, `dest` is guaranteed not to exist 
(`Files.notExists(dest)` is the exit condition). `REPLACE_EXISTING` is 
therefore semantically dead code — it will never trigger. Keeping it is 
harmless, but consider removing it or adding a comment (`// defensive: kept for 
future refactors`) to avoid misleading future readers about the invariant.



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