[jboss-jira] [JBoss JIRA] (WFLY-6672) EJB's async methods' Future#get should treat zero timeout as "don't wait"

Vsevolod Golovanov (JIRA) issues at jboss.org
Sat Jun 4 09:57:00 EDT 2016


    [ https://issues.jboss.org/browse/WFLY-6672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13247961#comment-13247961 ] 

Vsevolod Golovanov commented on WFLY-6672:
------------------------------------------

The problem seems to be due to {{org.jboss.as.ejb3.component.interceptors.AsyncInvocationTask}}'s implementation:
{code}
@Override
public synchronized Object get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
    if (!isDone()) {
        wait(unit.toMillis(timeout));
{code}
Unlike {{Future#get}}, {{Object#wait}} does specify special treatment for the zero timeout value:
{quote}
If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified. 
{quote}

> EJB's async methods' Future#get should treat zero timeout as "don't wait"
> -------------------------------------------------------------------------
>
>                 Key: WFLY-6672
>                 URL: https://issues.jboss.org/browse/WFLY-6672
>             Project: WildFly
>          Issue Type: Bug
>          Components: EJB
>    Affects Versions: 8.2.0.Final
>            Reporter: Vsevolod Golovanov
>
> Say there is an asynchronous EJB method:
> {code}
> @Asynchronous
> public Future<Boolean> method() {
>    ...
> }
> {code}
> Calling Future#get with a zero timeout:
> {code}
> if (bean.method().get(0, TimeUnit.MILLISECONDS))
> {code}
> results in a block until the task is finished.
> Instead I expected zero waiting, because {{java.util.concurrent.Future.get(long, TimeUnit)}} doesn't specify any special treatment for a zero timeout value.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list