users@glassfish.java.net

[gf-users] Future get() method behavior

From: Dennis Gesker <dennis_at_gesker.com>
Date: Wed, 6 Aug 2014 12:53:57 -0600

I have an EJB method (in an EJB module within my EAR) which calls several
other @Asynchronous methods in other classes which of course return a
Future.

In the calling method I issue get() statements so that I can use the
returned value in a calculation. Nothing fancy there.

I've been running this routine from @Schedule (once per day) method with no
issues. Runs quickly (about 20 min) and reliably and returns the correct
result -- an integer of record counts.

However, when I try to run this same routine from my web module (within the
same EAR) from within an @ApplicationScoped bean the method that calls the
@Asynchronous methods returns/completes *before* the future.get() method
called completes and returns a value. No exception is thrown.

Shouldn't a Future.get() call just block/wait until its work is complete
regardless of how its called? Is a different behavior to be expected when
called from a web module? Perhaps some kind of implied timeout?

I could use a hint.

NetBeans 8 and JDK 1.8.0_11 and Glassfish 4.0.1 promoted build 10 (July-29)
on Win8.1 Pro 64

Dennis