You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2018/06/21 19:28:00 UTC

[jira] [Commented] (TIKA-2677) ConcurrentModificationException in org.apache.tika.mime.MediaTypeRegistry.getAliases

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

Hudson commented on TIKA-2677:
------------------------------

FAILURE: Integrated in Jenkins build tika-2.x-windows #276 (See [https://builds.apache.org/job/tika-2.x-windows/276/])
TIKA-2677 -- fix multithreaded updating/access to MediaTypeRegistry, via (tallison: rev 7bd88f6eb2eb6035dd20f54364f8eeac7e2df0fd)
* (edit) tika-core/src/main/java/org/apache/tika/mime/MediaTypeRegistry.java
* (edit) tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java
* (edit) tika-core/src/test/java/org/apache/tika/mime/MimeTypesReaderTest.java


> ConcurrentModificationException in org.apache.tika.mime.MediaTypeRegistry.getAliases
> ------------------------------------------------------------------------------------
>
>                 Key: TIKA-2677
>                 URL: https://issues.apache.org/jira/browse/TIKA-2677
>             Project: Tika
>          Issue Type: Bug
>    Affects Versions: 1.18
>            Reporter: Yuriy Koval
>            Priority: Major
>
> When using Tika parser on multiple threads and calling MediaTypeRegistry.getAliases, we get ConcurrentModificationException:
> {noformat}
> java.util.ConcurrentModificationException
>  at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
>  at java.util.HashMap$EntryIterator.next(HashMap.java:1463)
>  at java.util.HashMap$EntryIterator.next(HashMap.java:1461)
>  at org.apache.tika.mime.MediaTypeRegistry.getAliases(MediaTypeRegistry.java:78){noformat}
> It will go away, if we use ConcurrentMap here:
> [https://github.com/apache/tika/blob/master/tika-core/src/main/java/org/apache/tika/mime/MediaTypeRegistry.java#L49]
>  
> Here is code snippet to recreate the problem:
> {code:java}
> static boolean stop = false;
> public static void main(String[] args) throws MimeTypeException {
>  MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes();
>  Executors.newSingleThreadExecutor().execute(() -> {
>  try {
>  for (int i=0; i < 1000 && !stop; i++) {
>  System.out.println(mimeTypes.forName("abc" + i + "/abc"));
>  }
>  } catch (MimeTypeException e) {
>  e.printStackTrace();
>  }
>  });
>  for (int i=0; i < 1000 && !stop; i++) {
>  try {
>  System.out.println(mimeTypes.getMediaTypeRegistry().getAliases(MediaType.APPLICATION_ZIP));
>  } catch (ConcurrentModificationException ex) {
>  stop = true;
>  ex.printStackTrace();
>  }
>  }
> }{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)