-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Exception match order in ErrorMessageExceptionTypeRouter #2873
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
Comments
The |
artembilan
added a commit
to artembilan/spring-integration
that referenced
this issue
Apr 1, 2019
Fixes spring-projects#2873 Sometime it is important to map to most specific exception instead of its super class. * Use `LinkedHashMap` for mapping keys in the `ErrorMessageExceptionTypeRouter`, as well as in its `AbstractMappingMessageRouter` superclass. Since we don't do that internal map modification, there is no reason to worry about concurrent access: we just replace an internal instance atomically with a new `LinkedHashMap` every time we modify a mapping for router **Cherry-pick to 5.1.x**
artembilan
added a commit
to artembilan/spring-integration
that referenced
this issue
Apr 1, 2019
Fixes spring-projects#2873 Sometime it is important to map to most specific exception instead of its super class. * Use `LinkedHashMap` for mapping keys in the `ErrorMessageExceptionTypeRouter`, as well as in its `AbstractMappingMessageRouter` superclass. Since we don't do that internal map modification, there is no reason to worry about concurrent access: we just replace an internal instance atomically with a new `LinkedHashMap` every time we modify a mapping for router **Cherry-pick to 5.1.x**
garyrussell
pushed a commit
that referenced
this issue
Apr 1, 2019
* GH-2873: Preserve mapping order in the router Fixes #2873 Sometime it is important to map to most specific exception instead of its super class. * Use `LinkedHashMap` for mapping keys in the `ErrorMessageExceptionTypeRouter`, as well as in its `AbstractMappingMessageRouter` superclass. Since we don't do that internal map modification, there is no reason to worry about concurrent access: we just replace an internal instance atomically with a new `LinkedHashMap` every time we modify a mapping for router **Cherry-pick to 5.1.x** * * Fix `RouterSpec.RouterMappingProvider` to `LinkedHashMap` as well * * Fix `RouterTests` for proper mapping order * Polishing for `AbstractMappingMessageRouter` hierarchy, so we don't use `protected channelMappings` field access any more
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ErrorMessageExceptionTypeRouter uses ConcurrentHashMap internally, and this does not guarantee the order.
Therefore, it is not possible to flexibly route Exception with hierarchy.
link : https://github.com/spring-projects/spring-integration/blob/v5.1.3.RELEASE/spring-integration-core/src/main/java/org/springframework/integration/router/ErrorMessageExceptionTypeRouter.java#L49
For example, when routing NullPointerException and RuntimeException, NullPointerException may be routed to the channel of RuntimeException.
This is the routing that are not intended.
The following measures are required to solve this problem.
The text was updated successfully, but these errors were encountered: