GH-1786 - Fix NPE in FormattableType.of() - #1787
Open
arimu1 wants to merge 1 commit into
Open
Conversation
…nresolvable generics. Rely on ResolvableType.resolve() and map null (unbounded wildcards / type variables) to "?", instead of feeding type.toString() into package abbreviation. That path NPEd on of(Class) when callers used resolve(), and also double-rendered generics as List<?><?> while mangling nested types. Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
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.
Summary
Fixes #1786.
When observability renders an observed method whose parameter type involves an unbounded wildcard (for example
Class<?>as used byAbstractHttpMessageConverter.canWrite/canRead, orList<?>/List<T>),ResolvableType.resolve()returnsnull. Feeding that intoFormattableType.of(Class)NPE'd ontype.getTypeName().This is the same root cause as #1748 / #1713. Main already routes through
FormattableType.of(ResolvableType), but that factory usedtype.toString()as a type name. That:?/ unresolvable type variable as the wildcard token for all call paths.DefaultObservedModule.renderthen double-appended them (List<?><?>) and mangled nested generics during package abbreviation (Map<String, List<?>>→j.u.M.l.S.u.List<?>>).Fix
FormattableType.of(ResolvableType)now:resolve()and mapsnullto the existing?wildcard instanceDefaultObservedModule.render) can still compose generic arguments recursivelyAlso adds
Assert.notNullonof(Class)for consistency withof(JavaClass).Tests
FormattableTypeUnitTests— unbounded wildcard / type variable →?;Class<?>regression (Null Pointer in FormattableType.of() #1786)DefaultObservedModuleUnitTests— exact signatures forList<?>,List<T>, andClass<?>FormattableTypeUnitTests: 9/9DefaultObservedModuleUnitTests: 4/4Documentation