Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-1857

File Adapter: FileReadingMessageSource - Sorted order of list of files in a FileListFilter not preserved by Spring Integration

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.0.4
    • Component/s: Core, File Support
    • Labels:
      None

      Description

      I have a filter (implements FileListFilter) that implements a custom sorting algorithm for a given list of files.
      This filter is defined as follows:

      <file:inbound-channel-adapter channel="filesIn"  filter="customFilterBean"
      	                              directory="file:${java.io.tmpdir}/spring-integration-samples/input">
      	    <integration:poller id="poller" fixed-delay="5000"/>
      	</file:inbound-channel-adapter>
      

      The filter then sorts the list of files. The filter implementation returns a list of sorted files. However, the sorted list of files is ignored by the FileReadingMessageSource

      Looking at the implementation (also have a test case to prove it) of FileReadingMessageSource, it appears to convert the 'sorted list' into a 'set' - thereby ignoring
      the sort in the FileListFilter

      private void scanInputDirectory() {
      		List<File> filteredFiles = scanner.listFiles(directory);  --> This list is sorted
      		Set<File> freshFiles = new HashSet<File>(filteredFiles);  --> Converted to a SET losing the sort order
      		if (!freshFiles.isEmpty()) {
      			toBeReceived.addAll(freshFiles);
      			if (logger.isDebugEnabled()) {
      				logger.debug("Added to queue: " + freshFiles);
      			}
      		}
      	}
      

      Our use case calls for processing the incoming files in a specific order.

        Attachments

          Activity

            People

            • Assignee:
              mark.fisher Mark Fisher
              Reporter:
              adkathuria Anuj Kathuria
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: