[concurrency-interest] Thread.uncaughtExceptionHandler is not called in ScheduledThreadPool/ThreadPool-executors

Aleksey Shipilev aleksey.shipilev at gmail.com
Tue Apr 26 15:22:52 EDT 2011


Hi,

I've been recently stumbled upon the issue about
ScheduledThreadPoolExecutor. I was thinking that I can trace whether
my scheduled task experienced some fatal exception and dump that
exception to log. I had set my own ThreadFactory which creates the
threads with appropriate Thread.UncaughtExceptionHandler. However,
it's not being called when it's anticipated to.

Is there anything I miss? May be this is correct behavior, and I
should trace exceptional cases in some other way?
I don't really want to drag my Future<?> around just to handle this
logging case.

Attached patch against jsr166 trunk contains the test cases.
Apparently, ThreadPoolExecutor has the same issue. Both new test cases
are failing on my machine (Ubuntu 10.10 x86 i5-520M):

    [junit] Running ScheduledExecutorTest
    [junit] Tests run: 61, Failures: 1, Errors: 0, Time elapsed: 1.221 sec
    [junit] Test ScheduledExecutorTest FAILED
    [junit] java version "1.6.0_24"
    [junit] Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    [junit] Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)

    [junit] Running ThreadPoolExecutorTest
    [junit] Tests run: 102, Failures: 1, Errors: 0, Time elapsed: 0.86 sec
    [junit] Test ThreadPoolExecutorTest FAILED
    [junit] java version "1.6.0_24"
    [junit] Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    [junit] Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)

I've double-checked those tests pass when done.countDown() is being
done before throwing exception.

Thanks,
Aleksey.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jsr166-unhandled-1.patch
Type: text/x-patch
Size: 4436 bytes
Desc: not available
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20110426/02b29c82/attachment.bin>


More information about the Concurrency-interest mailing list