Repository navigation
GH-1901 - Use type name for array types in FormattableType.of(ResolvableType). - #1902
Closed
cwJohnPark wants to merge 1 commit into
Closed
cwJohnPark wants to merge 1 commit into
cwJohnPark wants to merge 1 commit into
Conversation
…Type.of(ResolvableType). FormattableType.of(ResolvableType) used Class#getName(), which renders array types by their JVM binary names (e.g. [B or [Ljava.lang.String;). As the instance is cached under the same key that FormattableType.of(Class) uses, the broken instance also leaked into Class-based lookups, so the result depended on call order. We now use Class#getTypeName() in line with FormattableType.of(Class). Signed-off-by: cwjohnpark <pierrotcw@gmail.com>
odrotbohm
pushed a commit
that referenced
this pull request
Oct 1, 2026
…bleType). FormattableType.of(ResolvableType) used Class#getName(), which renders array types by their JVM binary names (e.g. [B or [Ljava.lang.String;). As the instance is cached under the same key that FormattableType.of(Class) uses, the broken instance also leaked into Class-based lookups, so the result depended on call order. We now use Class#getTypeName() in line with FormattableType.of(Class). Original pull request: GH-1902 Signed-off-by: cwjohnpark <pierrotcw@gmail.com>
odrotbohm
pushed a commit
that referenced
this pull request
Oct 1, 2026
…bleType). FormattableType.of(ResolvableType) used Class#getName(), which renders array types by their JVM binary names (e.g. [B or [Ljava.lang.String;). As the instance is cached under the same key that FormattableType.of(Class) uses, the broken instance also leaked into Class-based lookups, so the result depended on call order. We now use Class#getTypeName() in line with FormattableType.of(Class). Original pull request: GH-1902 Signed-off-by: cwjohnpark <pierrotcw@gmail.com>
odrotbohm
pushed a commit
that referenced
this pull request
Oct 9, 2026
…bleType). FormattableType.of(ResolvableType) used Class#getName(), which renders array types by their JVM binary names (e.g. [B or [Ljava.lang.String;). As the instance is cached under the same key that FormattableType.of(Class) uses, the broken instance also leaked into Class-based lookups, so the result depended on call order. We now use Class#getTypeName() in line with FormattableType.of(Class). Original pull request: GH-1902 Signed-off-by: cwjohnpark <pierrotcw@gmail.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.
Fixes #1901.
FormattableType.of(ResolvableType)built the type name fromClass#getName(), which yields the JVM binary name for array types ([B,[Ljava.lang.String;). As the instance is cached under the same key thatFormattableType.of(Class)uses, the garbled instance also leaked intoClass-based lookups, so the result depended on call order.This switches to
Class#getTypeName(), in line withFormattableType.of(Class). It only differs fromClass#getName()for array types, so all other types render as before.Tests added to
FormattableTypeUnitTests:handlesArrayTypesFromResolvableType()covers reference, primitive and multi-dimensional arrays as well as an array used as generic argument.rendersArrayTypesConsistentlyIndependentOfLookupOrder()looks up an array type viaResolvableTypefirst and viaClassafterwards. It uses a type not referenced by any other test, so the check does not depend on the test execution order.Verified with
./mvnw -pl spring-modulith-core -am testand the tests ofspring-modulith-observability-core, which renders observed method parameters through this code path.