[jboss-jira] [JBoss JIRA] (WFLY-9624) Improper handling of application exceptions on asynchronous ejb invocations

Andrej Kolontai (JIRA) issues at jboss.org
Wed Dec 20 05:49:00 EST 2017


     [ https://issues.jboss.org/browse/WFLY-9624?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrej Kolontai updated WFLY-9624:
----------------------------------
    Description: 
If an asynchronous invocation of an ejb method throws an application exception (declared exception) then the returned future will always return false on isDone(). That means: the client will never know that the operation has finished (unscuccessfully) unless get() is called which would rethrow the original exception.

This behavior has changed from wildfly 10.1.0.Final to 11.0.0.Final. 

I pretty sure that the problem is in org.jboss.as.ejb3.component.interceptors.AsyncInvocationTask.

The isDone Method is implemented like this:

{noformat}
    @Override
    public boolean isDone() {
        return status == ST_DONE;
    }
{noformat}

But status can be one of:
{noformat}
    private static final int ST_RUNNING = 0;
    private static final int ST_DONE = 1;
    private static final int ST_CANCELLED = 2;
    private static final int ST_FAILED = 3;
{noformat}

And and exception sets the status to 

{noformat}
    private synchronized void setFailed(final Exception e) {
        this.failed = e;
        status = ST_FAILED;
        done();
    }
{noformat}

So it's pretty obvious. 

The javadoc on java.util.concurrent.Future states:

{quote}
Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
{quote}

So the isDone() method should  look more like this:
{noformat}
    @Override
    public boolean isDone() {
        return status == ST_DONE || status == ST_FAILED || status == ST_CANCELLED;
    }
{noformat}

In wildfly 10, there was a single boolean variable "done" which was set to true in all three cases:
* cancel()
* setResult(...) and
* setFailed(...)



  was:
If an asynchronous invocation of an ejb method throws an application exception (declared exception) then the returned future will always return false on isDone(). That means: the client will never know that the operation has finished (unscuccessfully) unless get() is called which would rethrow the original exception.

This behavior has changed from wildfly 10.1.0.Final to 11.0.0.Final. 

I pretty sure that the problem is in org.jboss.as.ejb3.component.interceptors.AsyncInvocationTask.

The isDone Method is implemented like this:

    {{@Override
    public boolean isDone() {
        return status == ST_DONE;
    }}}

But status can be one of:
{{
    private static final int ST_RUNNING = 0;
    private static final int ST_DONE = 1;
    private static final int ST_CANCELLED = 2;
    private static final int ST_FAILED = 3;
}}

And and exception sets the status to 

{{
    private synchronized void setFailed(final Exception e) {
        this.failed = e;
        status = ST_FAILED;
        done();
    }
}}

So it's pretty obvious. 

The javadoc on java.util.concurrent.Future states:

{quote}
Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
{quote}

So the isDone() method should  look more like this:
{{
    @Override
    public boolean isDone() {
        return status == ST_DONE || status == ST_FAILED || status == ST_CANCELLED;
    }
}}

In wildfly 10, there was a single boolean variable "done" which was set to true in all three cases:
* cancel()
* setResult(...) and
* setFailed(...)





> Improper handling of application exceptions on asynchronous ejb invocations
> ---------------------------------------------------------------------------
>
>                 Key: WFLY-9624
>                 URL: https://issues.jboss.org/browse/WFLY-9624
>             Project: WildFly
>          Issue Type: Bug
>          Components: EJB
>    Affects Versions: 11.0.0.Final
>            Reporter: Andrej Kolontai
>
> If an asynchronous invocation of an ejb method throws an application exception (declared exception) then the returned future will always return false on isDone(). That means: the client will never know that the operation has finished (unscuccessfully) unless get() is called which would rethrow the original exception.
> This behavior has changed from wildfly 10.1.0.Final to 11.0.0.Final. 
> I pretty sure that the problem is in org.jboss.as.ejb3.component.interceptors.AsyncInvocationTask.
> The isDone Method is implemented like this:
> {noformat}
>     @Override
>     public boolean isDone() {
>         return status == ST_DONE;
>     }
> {noformat}
> But status can be one of:
> {noformat}
>     private static final int ST_RUNNING = 0;
>     private static final int ST_DONE = 1;
>     private static final int ST_CANCELLED = 2;
>     private static final int ST_FAILED = 3;
> {noformat}
> And and exception sets the status to 
> {noformat}
>     private synchronized void setFailed(final Exception e) {
>         this.failed = e;
>         status = ST_FAILED;
>         done();
>     }
> {noformat}
> So it's pretty obvious. 
> The javadoc on java.util.concurrent.Future states:
> {quote}
> Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
> {quote}
> So the isDone() method should  look more like this:
> {noformat}
>     @Override
>     public boolean isDone() {
>         return status == ST_DONE || status == ST_FAILED || status == ST_CANCELLED;
>     }
> {noformat}
> In wildfly 10, there was a single boolean variable "done" which was set to true in all three cases:
> * cancel()
> * setResult(...) and
> * setFailed(...)



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list