-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
From the PR:
At the moment the resteasy-client doesn't retrieve ParamConverters for objects different from Collection and array if the ParamConverterProvider requires the genericType or the annotations. This PR fixes the issue.
I haven't found any tests for the retrieval of ParamConverters on client-side. If there are any could you just point me to them so that I can add a test case for this.
This seems to be an issue with proxied clients.
Provider
@Provider public class UnmodifiedSinceParamConverterProvider implements ParamConverterProvider { @Override public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { if (rawType.isAssignableFrom(OffsetDateTime.class) && Optional.ofNullable(annotations) .stream() .flatMap(Stream::of) .anyMatch(this::match)) { //noinspection unchecked return (ParamConverter<T>) new UnmodifiedSinceParamConverter(); } return null; } private boolean match(Annotation annotation) { return annotation instanceof HeaderParam && "If-Unmodified-Since".equals(((HeaderParam) annotation).value()); } private static class UnmodifiedSinceParamConverter implements ParamConverter<OffsetDateTime> { @Override public OffsetDateTime fromString(String value) { return value == null ? null : OffsetDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME); } @Override public String toString(OffsetDateTime value) { return value == null ? null : value.format(DateTimeFormatter.RFC_1123_DATE_TIME); } } }
TestClient
@Path("/test") public interface TestClient { @POST String update(@HeaderParam("If-Unmodified-Since") OffsetDateTime ifUnmodifiedSince); }
Example Usage
final TestClient client = ((ResteasyWebTarget) ClientBuilder.newBuilder() .register(UnmodifiedSinceParamConverterProvider.class) .build() .target("http://localhost:8080/contacts/api/")).proxy(TestClient.class); System.out.println(client.update(OffsetDateTime.now()));
- is incorporated by
-
WFLY-18376 Upgrade RESTEasy to 6.2.5.Final
- Closed