Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1715

ThreadUtils.getAllThreads returns null threads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.13.0
    • None
    • lang.*
    • None

    Description

      The Collection returned by ThreadUtils.getAllThreads() contains null elements.

      Example test code:

      @Test
      public void getAllThreads() {
          Collection<Thread> allThreads = ThreadUtils.getAllThreads();
          allThreads.forEach(Assertions::assertNotNull);
      }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              spfaffe Stefan Pfafferott
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: