You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/06/12 00:37:02 UTC

[GitHub] [camel] bmarcj commented on a diff in pull request #7761: [CAMEL-17130] camel-file - Use NIO

bmarcj commented on code in PR #7761:
URL: https://github.com/apache/camel/pull/7761#discussion_r895082545


##########
components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java:
##########
@@ -423,38 +423,38 @@ private void keepLastModified(Exchange exchange, File file) {
                 last = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
             }
             if (last != null) {
-                boolean result = file.setLastModified(last);
+                boolean result = file.toFile().setLastModified(last);
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("Keeping last modified timestamp: {} on file: {} with result: {}", last, file, result);
                 }
             }
         }
     }
 
-    private boolean writeFileByLocalWorkPath(File source, File file) throws IOException {
+    private boolean writeFileByLocalWorkPath(Path source, Path file) throws IOException {
         LOG.trace("writeFileByFile using local work file being renamed from: {} to: {}", source, file);
         return FileUtil.renameFile(source, file, endpoint.isCopyAndDeleteOnRenameFail());
     }
 
-    private void writeFileByFile(File source, File target, Exchange exchange) throws IOException {
+    private void writeFileByFile(Path source, Path target, Exchange exchange) throws IOException {
         // in case we are using file locks as read-locks then we need to use
         // file channels for copying to support this
-        String path = source.getAbsolutePath();
+        String path = source.toAbsolutePath().toString();
         FileChannel channel
                 = exchange.getProperty(asExclusiveReadLockKey(path, Exchange.FILE_LOCK_CHANNEL_FILE), FileChannel.class);
         if (channel != null) {
-            try (FileChannel out = new FileOutputStream(target).getChannel()) {
+            try (FileChannel out = new FileOutputStream(target.toFile()).getChannel()) {

Review Comment:
   `FileChannel.open(target)`?



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org