diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java index 7af96d235e..5c8dc5d21b 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java @@ -68,6 +68,7 @@ import org.springframework.util.StringUtils; * * @author Gary Russell * @author Artem Bilan + * @author Mauro Molinari * * @since 2.1 */ @@ -1082,9 +1083,9 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply FileExistsMode existsMode = this.fileExistsMode; boolean appending = FileExistsMode.APPEND.equals(existsMode); boolean exists = localFile.exists(); - boolean replacing = FileExistsMode.REPLACE.equals(existsMode) - || (exists && FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode) - && localFile.lastModified() != getModified(fileInfo)); + boolean replacing = exists && (FileExistsMode.REPLACE.equals(existsMode) + || (FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode) + && localFile.lastModified() != getModified(fileInfo))); if (!exists || appending || replacing) { OutputStream outputStream; String tempFileName = localFile.getAbsolutePath() + this.remoteFileTemplate.getTemporaryFileSuffix();