eclipse-ee4j / eclipse-ee4j/jersey

MessageBodyReader/Writer matching doesn't work properly with CDI beans

Open
#4,400 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When a `MessageBodyReader` or `MessageBodyWriter` is defined as a CDI `@ApplicationScoped` bean, it is wrapped by the proxy.

This causes `org.glassfish.jersey.message.AbstractEntityProviderModel#getProviderClassParam` call to fail to get the provided Java type from the generic type argument from the provider instance (the class returned is the class of the proxy object, not the class of the actual provider implementation), which ultimately results in `Object.class` being returned to the caller.

This can make custom MBR/MBW "further away" if there are multiple providers for a given type, and prevent it from ever being used.

Contributor guide

Open the contributing guide

Research direction

Start at org.glassfish.jersey.message.AbstractEntityProviderModel#getProviderClassParam, which the issue identifies as returning Object.class for CDI-proxied providers. Trace how MessageBodyReader and MessageBodyWriter provider classes are inspected, then verify that the actual generic Java type is recovered and provider matching no longer ranks custom CDI beans incorrectly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.