RFR: JDK-8240148: Uncaught exceptions from ScheduledThreadPoolExecutor.execute aren't reported
Jaikiran Pai
jai.forums2013 at gmail.com
Thu Jun 25 01:31:54 UTC 2020
Thank you both Martin and David for your inputs.
On 25/06/20 5:40 am, David Holmes wrote:
> Hi Jaikiran,
>
>
>> The patch is available as a webrev at
>> https://cr.openjdk.java.net/~jpai/webrev/8240148/1/
>>
>> The patch updates the ScheduledThreadPoolExecutor.execute(Runnable) to
>> wrap the user passed Runnable into a custom one which then catches any
>> Throwable and reports it through the Thread's uncaught exception
>> handler. After having reviewed the existing code in that class, this was
>> the easiest (and perhaps the only feasible?) and cleanest way that I
>> could think of, to fix this issue.
>
> I do not agree with the solution or even the formulation of the issue.
>
> This is something that has been raised and discussed a number of times
> since Java 5. See for example:
>
> http://cs.oswego.edu/pipermail/concurrency-interest/2011-April/007865.html
>
>
> The UncaughtExceptionHandler is, as the name clearly indicates, for
> execution in response to uncaught exceptions and is the last act of a
> dying thread.
You are right. I looked into the ScheduledThreadPoolExecutor
implementation details but failed to read up on the javadoc of
UncaughtExceptionHandler which already clearly states that it's meant
for use when a thread is terminating. Thank you for linking that
previous discussion too.
-Jaikiran
More information about the core-libs-dev
mailing list