forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide correct generic type and annotations in ParamConverterProvider
These changes will provide the correct generic type and array of annotations when the JAX-RS annotation is present on a field or a method of a Bean Param class. The solution is similar to what was being done for the parameters of a REST Client method: it will load the metadata (generic type and annotations from fields and methods) of a BeanParam class using reflection only if there is a ParamConverterProvider present. Fix quarkusio#32765
- Loading branch information
Showing
13 changed files
with
347 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
267 changes: 166 additions & 101 deletions
267
...c/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
...n/java/io/quarkus/jaxrs/client/reactive/runtime/ParameterDescriptorFromClassSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.quarkus.jaxrs.client.reactive.runtime; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Type; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
public class ParameterDescriptorFromClassSupplier | ||
implements Supplier<Map<String, ParameterDescriptorFromClassSupplier.ParameterDescriptor>> { | ||
|
||
private final Class clazz; | ||
private volatile Map<String, ParameterDescriptor> value; | ||
|
||
public ParameterDescriptorFromClassSupplier(Class clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
@Override | ||
public Map<String, ParameterDescriptor> get() { | ||
if (value == null) { | ||
value = new HashMap<>(); | ||
Class currentClass = clazz; | ||
while (currentClass != null && currentClass != Object.class) { | ||
for (Field field : currentClass.getDeclaredFields()) { | ||
ParameterDescriptor descriptor = new ParameterDescriptor(); | ||
descriptor.annotations = field.getAnnotations(); | ||
descriptor.genericType = field.getGenericType(); | ||
value.put(field.getName(), descriptor); | ||
} | ||
|
||
for (Method method : currentClass.getDeclaredMethods()) { | ||
ParameterDescriptor descriptor = new ParameterDescriptor(); | ||
descriptor.annotations = method.getAnnotations(); | ||
descriptor.genericType = method.getGenericReturnType(); | ||
value.put(method.getName(), descriptor); | ||
} | ||
|
||
currentClass = currentClass.getSuperclass(); | ||
} | ||
} | ||
|
||
return value; | ||
} | ||
|
||
public static class ParameterDescriptor { | ||
public Annotation[] annotations; | ||
public Type genericType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.