-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Flow order priority does not match documented behavior #4456
Comments
Hi @robertmcnees, in your tests you seem to assume that Spring Batch will jump to the most generic pattern if there is more than one match. This is not the case. Spring Batch will choose the most specific one. Documented behavior of Spring BatchThe precedence of transitions is described in the reference documentation: https://docs.spring.io/spring-batch/docs/current/reference/html/step.html#conditionalFlow It gives the following example
and states
The implementationThe In It seems to me that the Javadoc of |
Thanks for the detailed reply. We are in agreement on the pattern matching priority but I am missing something in the implementation details. Let's focus on the example However this test fails. In this example, |
According to the logic of DefaultStateTransitionComparator, it is actually The merit of this can be debated but it is (maybe too briefly) stated in the Javadoc:
|
For the sake of completeness: The Javadoc of This is the root cause of #3996, which mentions the interesting workaround to use |
Thank you @hpoettker for the explanation. I was investigating #3996 and when my unit tests didn't pass it lead me to create this issue instead. Your comments helped to straighten out my thinking and indeed there is no bug in the code, although I do believe the documentation to be incorrect. There were 2 issues that caused me confusion: First, I believe the documentation text doesn't match the example. The example provided Second, the order of specificity switches between the To illustrate the switch in ordering (more for my own sake), I created a new passing test for the
Compare this to the existing test from
This is a lot of text for a proposed one word documentation update. I needed to straighten it out in my head. As long as I'm not too far off I'll likely head to #3996 next. |
Bug description
When using a JobExecutionDecider the behavior is not accurate according to the documentation of DefaultStateTransitionComparator. Specifically
Additionally, the actual behavior when running a Job is not consistent with the test results found in DefaultStateTransitionComparatorTests
In almost all test scenarios the documented behavior is not followed.
Environment
Boot 3.1.4
Java 17
Steps to reproduce
See sample GitHub project to be linked in comments below. The JUnit tests have multiple failing scenarios that should pass.
The tests come in 3 different groups, all of which contain failing tests:
Expected behavior
The stated documentation should accurate in regards to the priority Flow. All tests in the sample project should pass.
The text was updated successfully, but these errors were encountered: