-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3554: Eval remote dir on each synchToLocal #3556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes spring-projects#3554 The `remoteDirectoryExpression` was introduced into an `AbstractInboundFileSynchronizer` to let end-user to evaluate a remote directory on each poll (essentially on each `synchronizeToLocalDirectory()` call). The fix for the https://jira.spring.io/browse/INT-4491 introduced a regression when such an expression was evaluated only once when we call a `setRemoteDirectory()`. So, an original purpose of this option was lost and we don't get an actual remote dir on each poll * Remove `evaluateRemoteDirectory()` method and its usage since it doesn't reflect expectation of the remote dir expression property * Reinstate the `remoteDirectoryExpression` evaluation in the `synchronizeToLocalDirectory()` * Propagate the result of that expression into further methods for copying files * Remove setting of the `remoteDirectory` variable into a global `EvaluationContext` of the `AbstractInboundFileSynchronizer` instance since it is not thread-safe * Instead create an `EvaluationContext` locally for each `synchronizeToLocalDirectory()` call and set the `remoteDirectory` variable into this scoped instances * Generate a local file name from the `localFilenameGeneratorExpression` against locally created `EvaluationContext` with the mentioned `remoteDirectory` variable * Cover the expected functionality with a unit-test **Cherry-pick to `5.4.x` & `5.3.x`**
Queue<String> remoteDirs = new LinkedList<>(); | ||
remoteDirs.add("dir1"); | ||
remoteDirs.add("dir2"); | ||
sync.setRemoteDirectoryExpression(new FunctionExpression<Message<?>>(s -> remoteDirs.poll())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function input is not a Message<?>
(it actually doesn't have a root object, but I guess you have to specify something).
My concern is that reading this test might lead the reader to assume we have a Message<?>
here. FunctionExpression<Void>
?
(filePath, fileAttr) -> fileAttr.isRegularFile()) | ||
.forEach(System.out::println);*/ | ||
|
||
assertThat(localDir.list()).containsAll(remoteDirs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remoteDirs
is empty by now, so this will always pass.
* GH-3554: Eval remote dir on each synchToLocal Fixes #3554 The `remoteDirectoryExpression` was introduced into an `AbstractInboundFileSynchronizer` to let end-user to evaluate a remote directory on each poll (essentially on each `synchronizeToLocalDirectory()` call). The fix for the https://jira.spring.io/browse/INT-4491 introduced a regression when such an expression was evaluated only once when we call a `setRemoteDirectory()`. So, an original purpose of this option was lost and we don't get an actual remote dir on each poll * Remove `evaluateRemoteDirectory()` method and its usage since it doesn't reflect expectation of the remote dir expression property * Reinstate the `remoteDirectoryExpression` evaluation in the `synchronizeToLocalDirectory()` * Propagate the result of that expression into further methods for copying files * Remove setting of the `remoteDirectory` variable into a global `EvaluationContext` of the `AbstractInboundFileSynchronizer` instance since it is not thread-safe * Instead create an `EvaluationContext` locally for each `synchronizeToLocalDirectory()` call and set the `remoteDirectory` variable into this scoped instances * Generate a local file name from the `localFilenameGeneratorExpression` against locally created `EvaluationContext` with the mentioned `remoteDirectory` variable * Cover the expected functionality with a unit-test **Cherry-pick to `5.4.x` & `5.3.x`** * * Fix `testRemoteDirectoryRefreshedOnEachSynchronization` according PR review
* GH-3554: Eval remote dir on each synchToLocal Fixes #3554 The `remoteDirectoryExpression` was introduced into an `AbstractInboundFileSynchronizer` to let end-user to evaluate a remote directory on each poll (essentially on each `synchronizeToLocalDirectory()` call). The fix for the https://jira.spring.io/browse/INT-4491 introduced a regression when such an expression was evaluated only once when we call a `setRemoteDirectory()`. So, an original purpose of this option was lost and we don't get an actual remote dir on each poll * Remove `evaluateRemoteDirectory()` method and its usage since it doesn't reflect expectation of the remote dir expression property * Reinstate the `remoteDirectoryExpression` evaluation in the `synchronizeToLocalDirectory()` * Propagate the result of that expression into further methods for copying files * Remove setting of the `remoteDirectory` variable into a global `EvaluationContext` of the `AbstractInboundFileSynchronizer` instance since it is not thread-safe * Instead create an `EvaluationContext` locally for each `synchronizeToLocalDirectory()` call and set the `remoteDirectory` variable into this scoped instances * Generate a local file name from the `localFilenameGeneratorExpression` against locally created `EvaluationContext` with the mentioned `remoteDirectory` variable * Cover the expected functionality with a unit-test **Cherry-pick to `5.4.x` & `5.3.x`** * * Fix `testRemoteDirectoryRefreshedOnEachSynchronization` according PR review
... and cherry-picked to 5.4.x, 5.3.x. |
Fixes #3554
The
remoteDirectoryExpression
was introduced into anAbstractInboundFileSynchronizer
to let end-user to evaluate a remote directoryon each poll (essentially on each
synchronizeToLocalDirectory()
call).The fix for the https://jira.spring.io/browse/INT-4491 introduced a regression
when such an expression was evaluated only once when we call a
setRemoteDirectory()
.So, an original purpose of this option was lost and we don't get an actual
remote dir on each poll
evaluateRemoteDirectory()
method and its usage since it doesn'treflect expectation of the remote dir expression property
remoteDirectoryExpression
evaluation in thesynchronizeToLocalDirectory()
files
remoteDirectory
variable into a globalEvaluationContext
of the
AbstractInboundFileSynchronizer
instance since it is not thread-safeEvaluationContext
locally for eachsynchronizeToLocalDirectory()
call and set the
remoteDirectory
variable into this scoped instanceslocalFilenameGeneratorExpression
against locally created
EvaluationContext
with the mentionedremoteDirectory
variableCherry-pick to
5.4.x
&5.3.x