Skip to content

Conversation

zakkak
Copy link
Contributor

@zakkak zakkak commented Jun 17, 2025

Instead of registering subclasses of the class actually implementing the
handler, registers the class that actually implements the handler.

This way Quarkus can use getDeclaredMethods instead of getMethods at
runtime, which has less coverage (it doesn't return inherited methods).

Instead of registering subclasses of the class actually implementing the
handler, registers the class that actually implements the handler.

This way Quarkus can use `getDeclaredMethods` instead of `getMethods` at
runtime, which has less coverage (it doesn't return inherited methods).

Closes: quarkusio#44656
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the reflection behavior for Amazon Lambda handler discovery to limit the methods inspected and to register only the class that directly implements the handler.

  • Updated reflection usage in AmazonLambdaRecorder to use getDeclaredMethods instead of getMethods.
  • Adjusted AmazonLambdaProcessor to register reflective build items based on the discovered concrete handler class.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/amazon-lambda/runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AmazonLambdaRecorder.java Switched from getMethods() to getDeclaredMethods() to restrict method lookup to declared methods only.
extensions/amazon-lambda/deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaProcessor.java Modified logic to register the reflective build item for the actual implementing handler class when the discovery process is complete.
Comments suppressed due to low confidence (3)

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

  • Add a comment explaining why getDeclaredMethods() is preferred over getMethods(), noting that inherited methods are intentionally excluded for performance and precision.
final Method[] methods = handlerClass.getDeclaredMethods();

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

  • [nitpick] The variable name 'done' is ambiguous; consider renaming it to something more descriptive that clarifies its role in the handler discovery process.
if (!done) {

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

  • [nitpick] Include an inline comment to describe the condition under which 'done' becomes true to improve code readability and maintainability.
if (done) {

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how it goes :)

@zakkak zakkak added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 17, 2025
Copy link

quarkus-bot bot commented Jun 17, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 56470f2.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@zakkak zakkak merged commit da9f88e into quarkusio:main Jun 17, 2025
26 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.25 - main milestone Jun 17, 2025
@zakkak zakkak deleted the 2025-06-17-contain-reflection-usage-in-amazon-lambda branch June 17, 2025 12:30
@quarkus-bot quarkus-bot bot added kind/bugfix and removed triage/waiting-for-ci Ready to merge when CI successfully finishes labels Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The usage of the amazon extensions results in unregistered resource or reflective accesses in native mode
2 participants