From a835a63aad71be67fc33adeef61b494668b07285 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 19 Aug 2019 13:34:12 -0400 Subject: [PATCH] Apply changes from 5.1 for StandardRotationPolicy Related to https://github.com/spring-projects/spring-integration/issues/3027 * Remove `Assert.isTrue()` from the `onRotation()` to make the behavior as void in case of non-standard `MessageSource` provided * Add JavaDocs into `onRotation()` to describe the behavior and possibility to override --- .../remote/aop/StandardRotationPolicy.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/StandardRotationPolicy.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/StandardRotationPolicy.java index bcaf674956..de4c9fdde7 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/StandardRotationPolicy.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/StandardRotationPolicy.java @@ -133,18 +133,21 @@ public class StandardRotationPolicy implements RotationPolicy { onRotation(source); } + /** + * Update the state of the {@link MessageSource} after the server is rotated, if necessary. + * The default implementation updates the remote directory for known MessageSource implementations that require it, + * specifically, instances of {@link AbstractRemoteFileStreamingMessageSource}, and + * {@link AbstractInboundFileSynchronizingMessageSource}, and does nothing otherwise. + * Subclasses may override this method to support other MessageSource types. + * @param source the MessageSource. + */ protected void onRotation(MessageSource source) { - Assert.isTrue(source instanceof AbstractInboundFileSynchronizingMessageSource - || source instanceof AbstractRemoteFileStreamingMessageSource, - "source must be an AbstractInboundFileSynchronizingMessageSource or a " - + "AbstractRemoteFileStreamingMessageSource"); - if (source instanceof AbstractRemoteFileStreamingMessageSource) { - ((AbstractRemoteFileStreamingMessageSource) source).setRemoteDirectory(getCurrent().getDirectory()); + ((AbstractRemoteFileStreamingMessageSource) source).setRemoteDirectory(this.current.getDirectory()); } - else { + else if (source instanceof AbstractInboundFileSynchronizingMessageSource) { ((AbstractInboundFileSynchronizingMessageSource) source).getSynchronizer() - .setRemoteDirectory(getCurrent().getDirectory()); + .setRemoteDirectory(this.current.getDirectory()); } }