You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Pfafferott (Jira)" <ji...@apache.org> on 2023/10/10 06:37:00 UTC

[jira] [Resolved] (LANG-1715) ThreadUtils.getAllThreads returns null threads

     [ https://issues.apache.org/jira/browse/LANG-1715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Pfafferott resolved LANG-1715.
-------------------------------------
    Resolution: Duplicate

Noticed in the master that this already got fixed for LANG-1706. Didn't notice the "unresolved" filter when searching for ThreadUtils issues. Sorry.

> ThreadUtils.getAllThreads returns null threads
> ----------------------------------------------
>
>                 Key: LANG-1715
>                 URL: https://issues.apache.org/jira/browse/LANG-1715
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.13.0
>            Reporter: Stefan Pfafferott
>            Priority: Major
>
> The Collection returned by ThreadUtils.getAllThreads() contains null elements.
> Example test code:
> {code:java}
> @Test
> public void getAllThreads() {
>     Collection<Thread> allThreads = ThreadUtils.getAllThreads();
>     allThreads.forEach(Assertions::assertNotNull);
> }
> {code}
> Cause should be in ThreadUtils.findThreads line 375 in conjunction with line 379. The array is created larger than the actual number of threads. getAllThreads uses an "always true" predicate. This way, the null elements of the array are copied to the result list.
> In 3.12.0, only the elements up to the returned "count" are copied.
> I suggest to add a "not null" filter when creating the result list.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)