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



##########
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:
       Thanks. 
   
   Absolutely and I can definitely clean it up. 
   
   Obs.: just to clarify why it's here ... this is how the [code is doing right 
now](https://github.com/apache/camel/blob/22c7af563c067fc34c141da3de1338d7e37c3525/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java#L99).
 So, I was leaving getting rid of these Lists after the initial code was in 
because fully removing them will require changes to camel-ftp as well. 




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