Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix correct parsing of collections in AmazonLambdaRecorder #40464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hamburml
Copy link
Contributor

@hamburml hamburml commented May 5, 2024

test to make sure that the objectMapper parses the Input correct.

@patriot1burke thx for the hint.

I also adjusted the objectWriter but I am not sure if this is really necessary.

@quarkus-bot

This comment has been minimized.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I spotted something that looks a bit odd to me.

Also the tests are not passing.

@hamburml hamburml requested a review from gsmet May 10, 2024 14:28
@quarkus-bot

This comment has been minimized.

@hamburml hamburml force-pushed the feature/AmazonLambdaHandlerCollections branch 4 times, most recently from 46ee579 to ecfbe08 Compare May 10, 2024 17:11
@hamburml hamburml requested a review from gsmet May 10, 2024 17:24
@hamburml hamburml force-pushed the feature/AmazonLambdaHandlerCollections branch from ecfbe08 to 0886509 Compare May 10, 2024 17:37
@hamburml hamburml requested a review from gsmet May 10, 2024 17:40
@gsmet gsmet force-pushed the feature/AmazonLambdaHandlerCollections branch from 0886509 to 06d24d4 Compare May 13, 2024 14:24
@quarkus-bot
Copy link

quarkus-bot bot commented May 13, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 06d24d4.

✅ 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.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

CI is happy so let's merge this.

Thanks for your contribution!

@gsmet
Copy link
Member

gsmet commented May 13, 2024

@patriot1burke are you happy with it? If so, we can merge.

@patriot1burke
Copy link
Contributor

@gsmet My reviews have not been resolved yet.

@gsmet
Copy link
Member

gsmet commented May 15, 2024

@patriot1burke which reviews? I don't see any in this PR? Could you point me to where your comments are?

@geoand
Copy link
Contributor

geoand commented May 15, 2024

Maybe the review was not posted by accident (the GH UI tends to make this extremely easy to happen)?

@hamburml
Copy link
Contributor Author

Maybe he means this comment in the linked Issue #40349 (comment)
To be honest I never had issues with the output of the lambda, so I did not do the same to the objectWriter.

Copy link
Contributor

@patriot1burke patriot1burke left a comment

Choose a reason for hiding this comment

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

See my reviews now?

}
objectWriter = new JacksonOutputWriter(objectMapper.writerFor(handlerMethod.getReturnType()));
objectWriter = new JacksonOutputWriter(objectMapper.writerFor(javaType));
Copy link
Contributor

Choose a reason for hiding this comment

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

You must get the generic return type for the object writer. You cannot reuse the method parameter for the output.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll have to handle this case for this PR to be approved:

public class GenericTypeHandler implements RequestHandler<List<String>, List<Food>> {

   public List<String> handleRequest(List<Food> food) {
...
}

This case is a little harder:

public abstract class AbstractHandler implements RequestHandler<R,T> {
    public R handleRequest(T input) {
       ...
    }
}

public class ConcreteHandler extends AbstractHandler<String, String> {
}

public class PersonListLambda implements RequestHandler<List<Person>, String> {

@Override
public String handleRequest(List<Person> people, Context context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should test returning a collection as well.

if (parameterType.equals(S3Event.class)) {
objectReader = new S3EventInputReader(objectMapper);
} else if (Collection.class.isAssignableFrom(parameterType)) {
objectReader = new CollectionInputReader<>(objectMapper, handlerMethod);
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need a separate class just to abstract out 3 lines of code. Gmet is just asking to put the generic setup in an if-then block.

} else {
objectReader = new JacksonInputReader(objectMapper.readerFor(parameterType));
}

objectWriter = new JacksonOutputWriter(objectMapper.writerFor(handlerMethod.getReturnType()));
Copy link
Contributor

Choose a reason for hiding this comment

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

You are still ignoring the generic return type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not seeing these?

@patriot1burke
Copy link
Contributor

Maybe he means this comment in the linked Issue #40349 (comment) To be honest I never had issues with the output of the lambda, so I did not do the same to the objectWriter.

That is one of the comments. This PR is incomplete without supporting generic return type.

@hamburml
Copy link
Contributor Author

@patriot1burke Now your comments are visible. Maybe tomorrow I will find some time. Not sure. Thanks.

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.

HandleRequestCollectionHelper for Quarkus Amazon Lambda
4 participants