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

Exception not thrown by OnFailure() when using ListenableFutureCallback [SPR-12797] #17394

Closed
spring-issuemaster opened this issue Mar 9, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Mar 9, 2015

Antonio Parolini opened SPR-12797 and commented

In class AsyncExecutionAspectSupport, line 171:

The check to see if the method return type is of type Futur and descendants is inverted. It dosen't rethrow the original exception in case of ListenableFuture
It should be

if (Future.class.isAssignableFrom(method.getReturnType())) {

Exemple code when using ListenableFuture with asyc:

@Async((Application.MASS_THREAD_EXECUTOR))
public ListenableFuture<ImportJob> importOneJobMassAsync(ImportJob importJob, UTILSessionData sessionData) {
    //throw new IllegalArgumentException("test execption");
    importPartialData(importJob, sessionData);
    return new AsyncResult<>(importJob);
}
              futur.addCallback(
                        new ListenableFutureCallback<ImportJob>() {
                            /**
                             * On success is called also when we cancel the execussion pool
                             * But Import Job will be null
                            */

                            @Override
                            public void onSuccess(ImportJob importJob) {
                                UTILLog.logInfo(this.getClass().getName(), "futur.get finished");
                           }

                            /**
                             * This is called only when the job has been canceled
                             * @param ex
                             */
                            @Override
                            public void onFailure(Throwable ex) {
                                UTILLog.logError(this.getClass().getName(), "Job in error:" + ex.getMessage(), ex);
                            }
                        });
  

Affects: 4.1.5

Attachments:

Issue Links:

  • #16706 UncaughtExceptionHandler is not configured with AspectJ

Referenced from: commits 406adb3, 8f8a859

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 9, 2015

Antonio Parolini commented

Attached the patched file AsyncExecutionAspectSupport.java

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 9, 2015

Stéphane Nicoll commented

Good catch, thanks.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 9, 2015

Stéphane Nicoll commented

The faulty condition has been revisited. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.