Improve exception handling for missing converters - #7327
Draft
andreas-grafenberger wants to merge 6 commits into
Draft
Improve exception handling for missing converters#7327andreas-grafenberger wants to merge 6 commits into
andreas-grafenberger wants to merge 6 commits into
Conversation
…rs_exception_handling' into feature/improve_missing_converters_exception_handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The Enhanced Client currently fails to build converters for collection fields such as
Map<String, Object>,Set<Object>, andList<Object>with an unhelpfulIndex: 0exception.This occurs because
DefaultAttributeConverterProvider.findConverterInternal(EnhancedType<T> type)checks collection assignability in the wrong direction. As a result, broad types such asObject.classcan be incorrectly treated asMap,Set, orListtypes, even though they do not provide the required generic type parameters.This PR corrects these checks so unsupported collection types fail with a meaningful converter-not-found error instead of exposing an internal generic-type-list implementation detail.
See also:
Map<String, Object>valuesObjectas a mapModifications
Updated the collection type checks in
DefaultAttributeConverterProvider.findConverterInternal(EnhancedType<T> type)to use exact type matching.Previous behavior:
New behavior:
Prevented
Object.classand other broad types from being incorrectly interpreted asMap,Set, orListtypes.Changed failures for unsupported collection types such as
Map<String, Object>,Set<Object>, andList<Object>from the internalIndex: 0error to a meaningful converter-not-found error, for example:Applications that require support for these types can continue to register custom
AttributeConverterimplementations.Testing
Test Coverage on modified classes
TBC
Test Coverage Checklist
TBC
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License