Skip to content

Commit 3a4e42e

Browse files
authored
Merge pull request #49611 from zakkak/2025-08-19-fix-49413
Fix Amazon Lambda handler discovery fallback
2 parents b1026a7 + f7b5799 commit 3a4e42e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

extensions/amazon-lambda/deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaProcessor.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ List<AmazonLambdaBuildItem> discover(CombinedIndexBuildItem combinedIndexBuildIt
114114
final DotName name = info.name();
115115
final String lambda = name.toString();
116116
builder.addBeanClass(lambda);
117-
reflectiveClassBuildItemBuildProducer
118-
.produce(ReflectiveClassBuildItem.builder(lambda).methods().build());
119117

120118
String cdiName = null;
121119
AnnotationInstance named = info.declaredAnnotation(NAMED);
@@ -150,9 +148,21 @@ List<AmazonLambdaBuildItem> discover(CombinedIndexBuildItem combinedIndexBuildIt
150148
}
151149
}
152150
}
153-
current = combinedIndexBuildItem.getIndex().getClassByName(current.superName());
151+
if (!done) {
152+
current = combinedIndexBuildItem.getIndex().getClassByName(current.superName());
153+
}
154+
}
155+
if (done) {
156+
String handlerClass = current.name().toString();
157+
ret.add(new AmazonLambdaBuildItem(handlerClass, cdiName, streamHandler));
158+
reflectiveClassBuildItemBuildProducer.produce(ReflectiveClassBuildItem.builder(handlerClass).methods()
159+
.reason(getClass().getName()
160+
+ ": reflectively accessed in io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.discoverHandlerMethod")
161+
.build());
162+
} else {
163+
// Fall back to the root implementor if a matching `handleRequest` is not found in the class hierarchy
164+
ret.add(new AmazonLambdaBuildItem(lambda, cdiName, streamHandler));
154165
}
155-
ret.add(new AmazonLambdaBuildItem(lambda, cdiName, streamHandler));
156166
}
157167
additionalBeanBuildItemBuildProducer.produce(builder.build());
158168
reflectiveClassBuildItemBuildProducer

extensions/amazon-lambda/runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AmazonLambdaRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static void handle(InputStream inputStream, OutputStream outputStream, Co
8888
}
8989

9090
private static Method discoverHandlerMethod(Class<? extends RequestHandler<?, ?>> handlerClass) {
91-
final Method[] methods = handlerClass.getMethods();
91+
final Method[] methods = handlerClass.getDeclaredMethods();
9292
Method method = null;
9393
for (int i = 0; i < methods.length && method == null; i++) {
9494
if (methods[i].getName().equals("handleRequest")) {

0 commit comments

Comments
 (0)