Skip to content

Commit a835a63

Browse files
committed
Apply changes from 5.1 for StandardRotationPolicy
Related to spring-projects#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
1 parent 503d001 commit a835a63

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/StandardRotationPolicy.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,21 @@ protected void configureSource(MessageSource<?> source) {
133133
onRotation(source);
134134
}
135135

136+
/**
137+
* Update the state of the {@link MessageSource} after the server is rotated, if necessary.
138+
* The default implementation updates the remote directory for known MessageSource implementations that require it,
139+
* specifically, instances of {@link AbstractRemoteFileStreamingMessageSource}, and
140+
* {@link AbstractInboundFileSynchronizingMessageSource}, and does nothing otherwise.
141+
* Subclasses may override this method to support other MessageSource types.
142+
* @param source the MessageSource.
143+
*/
136144
protected void onRotation(MessageSource<?> source) {
137-
Assert.isTrue(source instanceof AbstractInboundFileSynchronizingMessageSource
138-
|| source instanceof AbstractRemoteFileStreamingMessageSource,
139-
"source must be an AbstractInboundFileSynchronizingMessageSource or a "
140-
+ "AbstractRemoteFileStreamingMessageSource");
141-
142145
if (source instanceof AbstractRemoteFileStreamingMessageSource) {
143-
((AbstractRemoteFileStreamingMessageSource<?>) source).setRemoteDirectory(getCurrent().getDirectory());
146+
((AbstractRemoteFileStreamingMessageSource<?>) source).setRemoteDirectory(this.current.getDirectory());
144147
}
145-
else {
148+
else if (source instanceof AbstractInboundFileSynchronizingMessageSource) {
146149
((AbstractInboundFileSynchronizingMessageSource<?>) source).getSynchronizer()
147-
.setRemoteDirectory(getCurrent().getDirectory());
150+
.setRemoteDirectory(this.current.getDirectory());
148151
}
149152
}
150153

0 commit comments

Comments
 (0)