You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Nick Burch (Jira)" <ji...@apache.org> on 2020/11/05 16:48:00 UTC
[jira] [Commented] (TIKA-3218) Wrong comment for method
sortLoadedClasses in ServiceLoaderUtils
[ https://issues.apache.org/jira/browse/TIKA-3218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17226820#comment-17226820 ]
Nick Burch commented on TIKA-3218:
----------------------------------
I think the idea of this was so that eg Parsers would have user-provided ones before our own ones, so that user-provided ones would come first and would be able to override built-in Tika ones
> Wrong comment for method sortLoadedClasses in ServiceLoaderUtils
> ----------------------------------------------------------------
>
> Key: TIKA-3218
> URL: https://issues.apache.org/jira/browse/TIKA-3218
> Project: Tika
> Issue Type: Bug
> Components: core
> Affects Versions: 2.0.0
> Reporter: Peter Lee
> Priority: Minor
>
>
> Here is method sortLoadedClasses 's comment:
>
> {code:java}
> /**
> * Sorts a list of loaded classes, so that non-Tika ones come
> * before Tika ones, and otherwise in reverse alphabetical order
> */
> {code}
> 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.
>
> {code:java}
> @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");
> }
> {code}
>
>
> 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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)