Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-3218

Wrong comment for method sortLoadedClasses in ServiceLoaderUtils

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.0
    • Component/s: core
    • Labels:
      None

      Description

       

      Here is method sortLoadedClasses 's comment:

       

       /**     
         * Sorts a list of loaded classes, so that non-Tika ones come     
         *  before Tika ones, and otherwise in reverse alphabetical order     
         */
      

      But you will find the method do the opposite thing if you check the code . See [1]

      Also , If you run this test , you can see the Tika's class come before non-Tika' class in the sorted list.

       

      @Test
      public void test() {
          List<Object> list = new ArrayList<>();
          list.add(new Object());
          list.add(new TikaException("abcd"));
          ServiceLoaderUtils.sortLoadedClasses(list);
      
          assertEquals(list.get(0).getClass().getName(), "org.apache.tika.exception.TikaException");
          assertEquals(list.get(1).getClass().getName(), "java.lang.Object");
      }
      

       

       

      I think the code is right and we need to modify the comment.

       

      [1]https://github.com/apache/tika/blob/6d2312a98cb4d9698c73158c2e28d296756ef959/tika-core/src/main/java/org/apache/tika/utils/ServiceLoaderUtils.java#L30

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              peterlee Peter Lee

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment