diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java index dc5353f9d3..4a2b61c21c 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -59,6 +59,7 @@ import org.springframework.util.ObjectUtils; * @author Oleg Zhurakousky * @author Gary Russell * @author Artem Bilan + * * @since 2.0 */ public abstract class AbstractInboundFileSynchronizer @@ -289,8 +290,11 @@ public abstract class AbstractInboundFileSynchronizer return; } + + long modified = getModified(remoteFile); + File localFile = new File(localDirectory, localFileName); - if (!localFile.exists()) { + if (!localFile.exists() || (this.preserveTimestamp && modified != localFile.lastModified())) { String tempFileName = localFile.getAbsolutePath() + this.temporaryFileSuffix; File tempFile = new File(tempFileName); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(tempFile)); @@ -322,7 +326,7 @@ public abstract class AbstractInboundFileSynchronizer } } if (this.preserveTimestamp) { - localFile.setLastModified(getModified(remoteFile)); + localFile.setLastModified(modified); } } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java index 7133da1136..18efadebb7 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -30,7 +30,9 @@ import org.springframework.integration.file.FileReadingMessageSource; import org.springframework.integration.file.filters.AcceptOnceFileListFilter; import org.springframework.integration.file.filters.CompositeFileListFilter; import org.springframework.integration.file.filters.FileListFilter; +import org.springframework.integration.file.filters.FileSystemPersistentAcceptOnceFileListFilter; import org.springframework.integration.file.filters.RegexPatternFileListFilter; +import org.springframework.integration.metadata.SimpleMetadataStore; import org.springframework.messaging.Message; import org.springframework.util.Assert; @@ -55,6 +57,7 @@ import org.springframework.util.Assert; * @author Josh Long * @author Oleg Zhurakousky * @author Gary Russell + * @author Artem Bilan */ public abstract class AbstractInboundFileSynchronizingMessageSource extends AbstractMessageSource implements Lifecycle { @@ -82,7 +85,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource */ private final FileReadingMessageSource fileSource; - private volatile FileListFilter localFileListFilter = new AcceptOnceFileListFilter(); + private volatile FileListFilter localFileListFilter; public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer synchronizer) { @@ -142,6 +145,10 @@ public abstract class AbstractInboundFileSynchronizingMessageSource } } this.fileSource.setDirectory(this.localDirectory); + if (this.localFileListFilter == null) { + this.localFileListFilter = new FileSystemPersistentAcceptOnceFileListFilter( + new SimpleMetadataStore(), getComponentName()); + } this.fileSource.setFilter(this.buildFilter()); if (this.getBeanFactory() != null) { this.fileSource.setBeanFactory(this.getBeanFactory()); diff --git a/spring-integration-ftp/src/test/resources/log4j.properties b/spring-integration-ftp/src/test/resources/log4j.properties index f336d51bbf..5405a7cfd3 100644 --- a/spring-integration-ftp/src/test/resources/log4j.properties +++ b/spring-integration-ftp/src/test/resources/log4j.properties @@ -5,5 +5,5 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n log4j.category.org.springframework=WARN -log4j.category.org.springframework.integration=DEBUG -log4j.category.org.springframework.integration.file=DEBUG +log4j.category.org.springframework.integration=WARN +log4j.category.org.springframework.integration.file=WARN diff --git a/src/reference/asciidoc/ftp.adoc b/src/reference/asciidoc/ftp.adoc index baea9a2949..9fe9216ba2 100644 --- a/src/reference/asciidoc/ftp.adoc +++ b/src/reference/asciidoc/ftp.adoc @@ -215,8 +215,9 @@ Unless your application removes files after processing, the adapter will re-proc Also, if you configure the `filter` to use a `FtpPersistentAcceptOnceFileListFilter`, and the remote file timestamp changes (causing it to be re-fetched), the default local filter will not allow this new file to be processed. Use the `local-filter` attribute to configure the behavior of the local file system filter. -To solve these particular use cases, you can use a `FileSystemPersistentAcceptOnceFileListFilter` as a local filter instead. -This filter also stores the accepted file names and modified timestamp in an instance of the`MetadataStore` strategy (<>), and will detect the change in the local file modified time. +Starting with _verion 4.3.8_, a `FileSystemPersistentAcceptOnceFileListFilter` is configured by default. +This filter stores the accepted file names and modified timestamp in an instance of the `MetadataStore` strategy (<>), and will detect changes to the local file modified time. +The default `MetadataStore` is a `SimpleMetadataStore` which stores state in memory. Since __version 4.1.5__, these filters have a new property `flushOnUpdate` which will cause them to flush the metadata store on every update (if the store implements `Flushable`). diff --git a/src/reference/asciidoc/sftp.adoc b/src/reference/asciidoc/sftp.adoc index 70b1ca1096..0455625dc3 100644 --- a/src/reference/asciidoc/sftp.adoc +++ b/src/reference/asciidoc/sftp.adoc @@ -347,8 +347,9 @@ Unless your application removes files after processing, the adapter will re-proc Also, if you configure the `filter` to use a `FtpPersistentAcceptOnceFileListFilter`, and the remote file timestamp changes (causing it to be re-fetched), the default local filter will not allow this new file to be processed. Use the `local-filter` attribute to configure the behavior of the local file system filter. -To solve these particular use cases, you can use a `FileSystemPersistentAcceptOnceFileListFilter` as a local filter instead. -This filter also stores the accepted file names and modified timestamp in an instance of the`MetadataStore` strategy (<>), and will detect the change in the local file modified time. +Starting with _verion 4.3.8_, a `FileSystemPersistentAcceptOnceFileListFilter` is configured by default. +This filter stores the accepted file names and modified timestamp in an instance of the `MetadataStore` strategy (<>), and will detect changes to the local file modified time. +The default `MetadataStore` is a `SimpleMetadataStore` which stores state in memory. Since __version 4.1.5__, these filters have a new property `flushOnUpdate` which will cause them to flush the metadata store on every update (if the store implements `Flushable`). diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index 7e87d31128..c4f866937b 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -227,6 +227,11 @@ See <> for more information. A new factory bean is provided to simplify the configuration of Jsch proxies for SFTP. See <> for more information. +===== Inbound Channel Adapter + +The inbound channel adapter is now configured with a `FileSystemPersistentAcceptOnceFileListFilter` in the `local-filter` by default. +See <> for more information. + ===== chmod The SFTP outbound gateway (for `put` and `mput` commands) and the SFTP outbound channel adapter now support the @@ -243,6 +248,11 @@ With that the `FtpOutboundGateway` can now be configured without `remoteDirector And the `` can be configured without `remote-directory`/`remote-directory-expression`. See <> for more information. +===== Inbound Channel Adapter + +The inbound channel adapter is now configured with a `FileSystemPersistentAcceptOnceFileListFilter` in the `local-filter` by default. +See <> for more information. + ==== Router Changes The `ErrorMessageExceptionTypeRouter` supports now the `Exception` superclass mappings to avoid duplication