-
Bug
-
Resolution: Done
-
Minor
-
4.4.2.Final
-
None
Resteasy client doesn't apply ParamConverter when serializing HeaderParam values.
JAX-RS: Java™ API for RESTful Web Services (Version 2.1), section 3.2 (Fields and Bean Properties):
When a resource class is instantiated, the values of fields and bean properties annotated with one the following annotations are set according to the semantics of the annotation:
@MatrixParam Extracts the value of a URI matrix parameter.
@QueryParam Extracts the value of a URI query parameter.
@PathParam Extracts the value of a URI template parameter.
@CookieParam Extracts the value of a cookie.
@HeaderParam Extracts the value of a header.
@Context Injects an instance of a supported resource, see chapters 10 and 11 for more details.
Because injection occurs at object creation time, use of these annotations (with the exception of @Context) on resource class fields and bean properties is only supported for the default per-request resource class lifecycle. An implementation SHOULD warn if resource classes with other lifecycles use these annotations on resource class fields or bean properties.
A JAX-RS implementation is only required to set the annotated field and bean property values of instances created by its runtime. Objects returned by sub-resource locators (see Section 3.4.1) are expected to be initialized by their creator.
Valid parameter types for each of the above annotations are listed in the corresponding Javadoc, however in general (excluding @Context) the following types are supported:
- Types for which a ParamConverter is available via a registered ParamConverterProvider. See Javadoc for these classes for more information.
- Primitive types.
- Types that have a constructor that accepts a single String argument.
- Types that have a static method named valueOf or fromString with a single String argument
that return an instance of the type. If both methods are present then valueOf MUST be used unless
the type is an enum in which case fromString MUST be used1.- List<T>, Set<T>, or SortedSet<T>, where T satisfies 1, 3 or 4 above.
Point 1 is not being applied with HeaderParam when single value is used. Class org.jboss.resteasy.client.jaxrs.internal.proxy.processors.AbstractCollectionProcessor<T> (in resteasy-client artifact) is processing in a valid way Collections and Arrays, but with single values is delegating such processing to final classes. FormParamProcessor (for example) is doing in the right way (lines 52-53), but HeaderParamProcessor is using directly toString result of the object (line 30).