Skip to content

Fix IntegrationManagementConfiguration.obtainObservationPatterns() for HashSet sort #9260

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

Closed
artembilan opened this issue Jun 21, 2024 · 0 comments

Comments

@artembilan
Copy link
Member

When we provide config like:

@EnableIntegrationManagement(observationPatterns ={  "!notObserved", "*" })

that HashSet in the IntegrationManagementConfiguration.obtainObservationPatterns() makes specific pattern useless: the common * is moved to the first position and when we call PatternMatchUtils.smartMatch(), this * always wins.
That is according to Javadocs:

	 * Pattern match against the supplied patterns; also supports negated ('!')
	 * patterns. First match wins (positive or negative).
	 * To match the names starting with {@code !} symbol,
	 * you have to escape it prepending with the {@code \} symbol in the pattern definition.

Revise the logic in the IntegrationManagementConfiguration.obtainObservationPatterns() to retain order of the provided patterns.
Or even make it smarter to ignore all the regular patterns if common * is present.
Plus move * to the end of the final array to let all those negative patterns make their decision.

@artembilan artembilan added this to the 6.4.0-M1 milestone Jun 21, 2024
spring-builds pushed a commit that referenced this issue Jun 25, 2024
…terns()` logic

Fixes: #9260

The current `IntegrationManagementConfiguration.obtainObservationPatterns()` is to always have an `*` as a first
pattern in the final result.
Because of `HashSet` natural order.
This would lead to ignore all the patterns, especially those with negation

* Fix `IntegrationManagementConfiguration.obtainObservationPatterns()` logic to ignore regular
patterns if `*` is present.
Optimization wise.
* Always put `*` into the end of final array let negative patterns to do their job
* Modify `IntegrationGraphServerTests` & `WebFluxObservationPropagationTests`
test configurations to ensure that `*` pattern does not have a precedence over negative patterns.

(cherry picked from commit 4108ea5)
spring-builds pushed a commit that referenced this issue Jun 25, 2024
…terns()` logic

Fixes: #9260

The current `IntegrationManagementConfiguration.obtainObservationPatterns()` is to always have an `*` as a first
pattern in the final result.
Because of `HashSet` natural order.
This would lead to ignore all the patterns, especially those with negation

* Fix `IntegrationManagementConfiguration.obtainObservationPatterns()` logic to ignore regular
patterns if `*` is present.
Optimization wise.
* Always put `*` into the end of final array let negative patterns to do their job
* Modify `IntegrationGraphServerTests` & `WebFluxObservationPropagationTests`
test configurations to ensure that `*` pattern does not have a precedence over negative patterns.

(cherry picked from commit 4108ea5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants