You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2017/04/11 14:54:41 UTC

[jira] [Comment Edited] (SLING-6261) ThreadExpiringThreadPool is relying on uncaught exceptions to kill threads

    [ https://issues.apache.org/jira/browse/SLING-6261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15964474#comment-15964474 ] 

Konrad Windszus edited comment on SLING-6261 at 4/11/17 2:53 PM:
-----------------------------------------------------------------

Thanks for the feedback, will rework the patch to make the API backwards compatible. 

Regarding supporting weird Java Runtimes where the reflection trick does not work: I would rather log explicitly that thread locals are not cleaned up in that case instead of falling back to the {{ThreadExpiringThreadPool}}. I assume that this should almost never happen and I don't think it is worth the effort to maintain the code for {{ThreadExpiringThreadPool}} for those JREs. Also it is not clear whether those non-Oracle JREs are compliant with the {{ThreadExpiringThreadPool}} in its current form because even that relies on the undocumented feature that throwing an exception from its {{afterExecute}} method leads to discarding the thread.


was (Author: kwin):
Thanks for the feedback, will rework the patch to make the API still compatible. 

Regarding supporting weird Java Runtimes where the reflection trick does not work: I would rather log explicitly that thread locals are not cleaned up in that case instead of falling back to the {{ThreadExpiringThreadPool}}. I assume that this should almost never happen and I don't think it is worth the effort to maintain the code for {{ThreadExpiringThreadPool}} for those JREs. Also it is not clear whether those non-Oracle JREs are compliant with the {{ThreadExpiringThreadPool}} in its current form because even that relies on the undocumented feature that throwing an exception from its {{afterExecute}} method leads to discarding the thread.

> ThreadExpiringThreadPool is relying on uncaught exceptions to kill threads
> --------------------------------------------------------------------------
>
>                 Key: SLING-6261
>                 URL: https://issues.apache.org/jira/browse/SLING-6261
>             Project: Sling
>          Issue Type: Improvement
>          Components: Commons
>    Affects Versions: Commons Threads 3.2.6
>            Reporter: Konrad Windszus
>             Fix For: Commons Threads 3.2.8
>
>         Attachments: SLING-6261-v01.patch
>
>
> In {{o.a.s.commons.threads.impl.ThreadExpiringThreadPool}} a {{RuntimeException}} with message "Kill old thread" is used in {{checkMaxThreadAge(final Thread thread)}}. This leads by default to a suspension of the thread when debugging with Eclipse (as since Neon JDT will suspend the thread on all uncaught exceptions). More information is available in http://stackoverflow.com/questions/6290470/eclipse-debugger-always-blocks-on-threadpoolexecutor-without-any-obvious-excepti. There should be a different mechanism to kill the thread than an uncaught exception.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)