Skip to content

Commit 4f2372b

Browse files
Stexxenartembilan
authored andcommitted
FileReadingMS: Make an Assert message more clear
* Changed an Assert error message in the `FileReadingMessageSource` to make the requirements when using an external scanner clearer, and added some explanatory comments. * Removed use of 'local' to eliminate confusion. * Added javadoc addendum
1 parent b295fb8 commit 4f2372b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/FileReadingMessageSource.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
* a known suffix), composed with the default {@link AcceptOnceFileListFilter}
6868
* would allow for this.
6969
* <p>
70+
* If a external {@link DirectoryScanner} is used, then the {@link FileLocker}
71+
* and {@link FileListFilter} objects should be set on the external
72+
* {@link DirectoryScanner}, not the instance of FileReadingMessageSource. An
73+
* {@link IllegalStateException} will result otherwise.
74+
* <p>
7075
* A {@link Comparator} can be used to ensure internal ordering of the Files in
7176
* a {@link PriorityBlockingQueue}. This does not provide the same guarantees as
7277
* a {@link ResequencingMessageGroupProcessor}, but in cases where writing files
@@ -80,6 +85,7 @@
8085
* @author Oleg Zhurakousky
8186
* @author Gary Russell
8287
* @author Artem Bilan
88+
* @author Steven Pearce
8389
*/
8490
public class FileReadingMessageSource extends AbstractMessageSource<File>
8591
implements Lifecycle {
@@ -334,8 +340,10 @@ protected void onInit() {
334340
this.scanner = new WatchServiceDirectoryScanner();
335341
}
336342

343+
// Check that the filter and locker options are _NOT_ set if an external scanner has been set.
344+
// The external scanner is responsible for the filter and locker options in that case.
337345
Assert.state(!(this.scannerExplicitlySet && (this.filter != null || this.locker != null)),
338-
"The 'filter' and 'locker' options must be present on the provided external 'scanner': "
346+
"When using an external scanner the 'filter' and 'locker' options should not be used. Instead, set these options on the external DirectoryScanner: "
339347
+ this.scanner);
340348
if (this.filter != null) {
341349
this.scanner.setFilter(this.filter);

0 commit comments

Comments
 (0)