Repository navigation
fix(ric): resolve generic method types against handler class hierarchy - #670
Open
mayankcodes-dev wants to merge 1 commit into
Open
mayankcodes-dev wants to merge 1 commit into
mayankcodes-dev wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Fixes #552
Description of changes:
When configuring a Lambda handler with method-name syntax (
ClassName::methodName),EventHandlerLoader.getHandlerFromOverloadpreviously passedMethod.getGenericReturnType()andMethod.getGenericParameterTypes()without resolving class-level type variables against the concrete handler subclass. In contrast, class-name syntax (ClassName) resolvedRequestHandler<I, O>type arguments viafindInterfaceParametersandClassContext.This left inherited generic parameters/return types as unresolved
TypeVariableinstances (for exampleInputT/OutputT), causing:CustomPojoSerializer(fromJson/toJson) to receive unresolvedTypeVariables instead of the concrete types.LinkedHashMapand fail invocation withClassCastException.Voidreturn types to missisVoid(rType)and attempt response serialization.RequestHandlergeneric base classes, interfacedefaultmethods, and multi-level nested generic types (List<T>,T[]) to fail type resolution.Summary of Changes
clazzinEventHandlerLoader.getHandlerFromOverload:findClassContext(Class<?> clazz, Class<?> targetClass)using BFS over superclasses and interfaces (sharingnextClassContexttraversal withfindInterfaceParameters) to locate the parameterized context ofm.getDeclaringClass().ClassContextwith recursiveresolveTypesupport forTypeVariable,ParameterizedType,GenericArrayType, andWildcardType, plus lightweightResolvedParameterizedType,ResolvedGenericArrayType, andResolvedWildcardTypeimplementations with standard JDKequals/hashCode/toStringsemantics fortypeCachecompatibility.TypeVariableby declaration identity (t.equals(variables[i])) instead of name-only equality so method-scoped type parameters are not shadowed by class-level type parameters of the same name.EventHandlerLoaderTest:CustomPojoSerializerand Jackson serialization withRequestHandlersubclasses using::handleRequestsyntax.RequestHandler, interfacedefaultmethods, multi-level nestedList<T>andT[]types, bounded generic base classes (bridge-method selection + resolution),Voidreturn types, and method-level type-variable shadowing.Local Verification
build-tools/checkstyle.xml) onEventHandlerLoader.java: 0 violations.javac -source 8 -target 8.EventHandlerLoaderTest(20 tests),PojoSerializerLoaderTest(6 tests), andHandlerInfoTest(13 tests): 39/39 passing (MockWebServer/JNI tests require Linux/Docker CI).Target (OCI, Managed Runtime, both):
both
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.