Skip to content

Fix ClassCastException when servlet filter is loaded by a different classloader#16396

Closed
trask wants to merge 3 commits intoopen-telemetry:mainfrom
trask:issue-16393
Closed

Fix ClassCastException when servlet filter is loaded by a different classloader#16396
trask wants to merge 3 commits intoopen-telemetry:mainfrom
trask:issue-16393

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Mar 5, 2026

Resolves #16393

cc @SylvainJuge

Comment on lines +68 to +72
@Nullable
public F get(T object, Class<? extends F> expectedType) {
F value = get(object);
return expectedType.isInstance(value) ? value : null;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking it could make sense to use this everywhere just as a safeguard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a lots of changes, could we make the VirtualField implementation store and reuse the Class argument that is passed in the VirtualField.find method call ?

@trask trask marked this pull request as ready for review March 6, 2026 01:25
@trask trask requested a review from a team as a code owner March 6, 2026 01:25
@laurit
Copy link
Copy Markdown
Contributor

laurit commented Mar 6, 2026

The issue with this approach is that the functionality will be broken because the returned objet is null. I create #16403 that fixes the issue in a different way.

@trask
Copy link
Copy Markdown
Member Author

trask commented Mar 6, 2026

Closing in favor of #16403

@trask trask closed this Mar 6, 2026
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.

ClassCastException for JakartaServletFilterMappingResolverFactory introduced in 2.23.0 with servlet filter

3 participants