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 wrong return type when invoking Async-annotated method on interface #33957

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anaconda875
Copy link

@anaconda875 anaconda875 commented Nov 25, 2024

The last param of AsyncExecutionAspectSupport.doSubmit is a return type, which can be get from the invocation. But in case of interface with paramter type like:

interface Service<O> {
  O doSomething();
}

class DefaultAsyncService implements Service<Future<String>> {
  @Override
  @Async
  public Future<String> doSomething() {
   return CompletableFuture.abc();
  }
}

@RestController
class Controller {
  @Autowire
  Service<Future<String>> service;

  @GetMapping
  public Future<String> api() {
    return service.doSomething();
  }
}

Return type retuned by invocation.getMethod().getReturnType() will be Object because we invoke doSomething by the interface, not by the impl.
My PR try to fix that

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 25, 2024
@snicoll
Copy link
Member

snicoll commented Nov 26, 2024

Can you please add a unit test that exercise the scenario you've described?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 26, 2024
@anaconda875
Copy link
Author

anaconda875 commented Nov 27, 2024

Can you please add a unit test that exercise the scenario you've described?

Hi @snicoll , you need a unit test which cover the fix/changes, or the unit test to reproduce the issue?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 27, 2024
@snicoll
Copy link
Member

snicoll commented Nov 27, 2024

Isn't that the same thing? I'd like that we see the change covered by an actual test that shows the behavior you've described is now working.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 27, 2024
@anaconda875
Copy link
Author

Isn't that the same thing? I'd like that we see the change covered by an actual test that shows the behavior you've described is now working.

Ok I will add it soon. Thank you

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 27, 2024
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 27, 2024
@anaconda875 anaconda875 changed the title Fix wrong return type when invoking Async-annotated Fix wrong return type when invoking Async-annotated method on interface Nov 27, 2024
@anaconda875
Copy link
Author

I added unit test

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 28, 2024
@snicoll snicoll requested a review from jhoeller December 4, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants