From 2db1fe2c9311be4371bcc654b84e4951f7d4ee08 Mon Sep 17 00:00:00 2001 From: tarekmamdouh Date: Wed, 27 Oct 2021 05:54:52 -0400 Subject: [PATCH] Add support for generic types in synthetic classes such as weld proxies (#2589) (#2754) Co-authored-by: Tarek Ahmed --- .../java/ca/uhn/fhir/rest/server/method/MethodUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/MethodUtil.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/MethodUtil.java index 31a608c2846..6c05f216ae4 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/MethodUtil.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/MethodUtil.java @@ -90,6 +90,15 @@ public class MethodUtil { if (Collection.class.isAssignableFrom(parameterType)) { innerCollectionType = (Class>) parameterType; parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(theMethod, paramIndex); + if(parameterType == null && theMethod.getDeclaringClass().isSynthetic()) { + try { + theMethod = theMethod.getDeclaringClass().getSuperclass().getMethod(theMethod.getName(), parameterTypes); + parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(theMethod, paramIndex); + } catch (NoSuchMethodException e) { + throw new ConfigurationException("A method with name '" + theMethod.getName() + "' does not exist for super class '" + + theMethod.getDeclaringClass().getSuperclass() + "'"); + } + } declaredParameterType = parameterType; } if (Collection.class.isAssignableFrom(parameterType)) {