Skip to content

GH-1748 - Guard against unresolvable generics in observed method rendering#1749

Open
Hronom wants to merge 1 commit into
spring-projects:mainfrom
Hronom:gh-1748
Open

GH-1748 - Guard against unresolvable generics in observed method rendering#1749
Hronom wants to merge 1 commit into
spring-projects:mainfrom
Hronom:gh-1748

Conversation

@Hronom

@Hronom Hronom commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Fixes #1748.

When observability is enabled, invoking an observed module service method whose parameter has an unbounded wildcard generic (Foo<?>) — or an unbounded type variable (Foo<T>) — failed with a NullPointerException while rendering the observed method signature.

This is a sibling of #1713. DefaultObservedModule.render(ResolvableType) passed the result of ResolvableType.resolve() straight into FormattableType.of(Class) without a null check. For an unbounded wildcard/type variable, resolve() returns null, so FormattableType.of threw an NPE dereferencing type.getTypeName().

Because ModuleEntryInterceptor.invoke evaluates module.format(invocation) before invocation.proceed(), the exception aborted the call entirely — the target method was never invoked.

Fix

render(ResolvableType) now falls back to rendering ? when the type resolves to null.

Tests

Added two regression tests in DefaultObservedModuleUnitTests (wildcard and type-variable parameters) that exercise format() and assert no exception is thrown and the rendered signature contains <?>. Backed by new fixture methods on SampleComponent.

🤖 Generated with Claude Code

…ved method rendering.

Unbounded wildcard (Foo<?>) and unbounded type variable (Foo<T>) parameters
caused ResolvableType.resolve() to return null, which was passed straight into
FormattableType.of(Class), triggering a NullPointerException while rendering the
observed method signature. As the signature is rendered before the actual
invocation proceeds, the cross-module call was aborted entirely.

DefaultObservedModule.render(ResolvableType) now falls back to rendering "?" when
the type resolves to null.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Yevhen Tienkaiev <hronom@gmail.com>
@Hronom

Hronom commented Jun 16, 2026

Copy link
Copy Markdown
Author

I also verbally confirming that I'm ok that maintainers modify as they want this PR or close and re-open with how they see the fix from theirs name.

My intention is to have this issues fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded wildcard / type-variable generic parameters break FormattableType (NPE in DefaultObservedModule.render)

1 participant