davsclaus commented on a change in pull request #6228:
URL: https://github.com/apache/camel/pull/6228#discussion_r725445346



##########
File path: 
components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
##########
@@ -83,25 +88,18 @@ protected boolean pollDirectory(String fileName, 
List<GenericFile<File>> fileLis
         if (LOG.isTraceEnabled()) {
             LOG.trace("Polling directory: {}, absolute path: {}", 
directory.getPath(), directory.getAbsolutePath());
         }
-        File[] dirFiles = directory.listFiles();
-        if (dirFiles == null || dirFiles.length == 0) {
-            // no files in this directory to poll
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("No files found in directory: {}", 
directory.getPath());
-            }
+        File[] files = listFiles(directory);
+        if (files != null && files.length == 0) {
             return true;
-        } else {
-            // we found some files
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("Found {} in directory: {}", dirFiles.length, 
directory.getPath());
-            }
         }
-        List<File> files = Arrays.asList(dirFiles);
+
         if (getEndpoint().isPreSort()) {
-            files.sort(Comparator.comparing(File::getAbsoluteFile));
+            Arrays.sort(files, Comparator.comparing(File::getAbsoluteFile));
         }
 
-        for (File file : dirFiles) {
+        List<File> filesArray = Arrays.asList(files);

Review comment:
       Ah okay, then you can look at this later if this is easier. It would be 
a good optimization to do




-- 
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-unsubscr...@camel.apache.org

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


Reply via email to