diff --git a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
index 697165c571..238aeaaf92 100644
--- a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
+++ b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import java.util.concurrent.PriorityBlockingQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.core.io.Resource;
import org.springframework.integration.aggregator.Resequencer;
import org.springframework.integration.core.Message;
@@ -58,6 +59,7 @@ import org.springframework.util.Assert;
* receive() invocations and message delivery callbacks.
*
* @author Iwein Fuld
+ * @author Mark Fisher
*/
public class FileReadingMessageSource implements MessageSource {
@@ -69,8 +71,8 @@ public class FileReadingMessageSource implements MessageSource {
/**
* {@link PriorityBlockingQueue#iterator()} throws
- * {@link ConcurrentModificationException} in Java 5. There is no locking
- * around the queue, so there is also no iteration.
+ * {@link java.util.ConcurrentModificationException} in Java 5.
+ * There is no locking around the queue, so there is also no iteration.
*/
private final Queue toBeReceived;
@@ -78,6 +80,7 @@ public class FileReadingMessageSource implements MessageSource {
private boolean scanEachPoll = false;
+
/**
* Creates a FileReadingMessageSource with a naturally ordered queue.
*/
@@ -113,7 +116,7 @@ public class FileReadingMessageSource implements MessageSource {
* {@link AcceptOnceFileListFilter} with no bounds is used. In most cases a
* customized {@link FileListFilter} will be needed to deal with
* modification and duplication concerns. If multiple filters are required a
- * {@link CompositeFileListFilter} can be used to group them together
+ * {@link CompositeFileListFilter} can be used to group them together.
*
* The supplied filter must be thread safe..
*/
@@ -151,7 +154,12 @@ public class FileReadingMessageSource implements MessageSource {
}
private void scanInputDirectory() {
- List filteredFiles = filter.filterFiles((inputDirectory.listFiles()));
+ File[] fileArray = inputDirectory.listFiles();
+ if (fileArray == null) {
+ throw new MessagingException("Either the path [" + this.inputDirectory
+ + "] does not denote a directory, or an I/O error has occured.");
+ }
+ List filteredFiles = this.filter.filterFiles(fileArray);
Set freshFiles = new HashSet(filteredFiles);
if (!freshFiles.isEmpty()) {
toBeReceived.addAll(freshFiles);
@@ -180,4 +188,5 @@ public class FileReadingMessageSource implements MessageSource {
logger.debug("Sent: " + sentMessage);
}
}
+
}