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



##########
File path: 
components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
##########
@@ -177,6 +150,56 @@ protected boolean pollDirectory(String fileName, 
List<GenericFile<File>> fileLis
         return true;
     }
 
+    private List<File> listFiles(File directory) {
+        final 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());
+            }
+            return Collections.emptyList();
+        } else {
+            // we found some files
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Found {} in directory: {}", dirFiles.length, 
directory.getPath());
+            }
+        }
+
+        FileResumeInfo resumeInfo = new 
FileResumeInfo(Arrays.asList(dirFiles));

Review comment:
       We should only do this if a resume strategy is set - eg that noop 
strategy should be removed. The reason is that this code creates a large array 
(eg if there are 10.000 files) that are not needed when you do noop.
   
   You could also consider resume strategy to be generic typed so its a File[], 
so you can pass in the File[] directly without having to create a List array.

##########
File path: 
components/camel-file/src/main/java/org/apache/camel/component/file/consumer/FileResumeInfo.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.file.consumer;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public final class FileResumeInfo {
+    private final List<File> inputFiles;
+    private List<File> outputFiles;
+
+    public FileResumeInfo(List<File> inputFiles) {

Review comment:
       Ah here you can use File[] so the list is not needed to be created




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