[
https://issues.apache.org/jira/browse/TIKA-2677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16519747#comment-16519747
]
Hudson commented on TIKA-2677:
------------------------------
FAILURE: Integrated in Jenkins build tika-branch-1x #50 (See
[https://builds.apache.org/job/tika-branch-1x/50/])
TIKA-2677 -- fix multithreaded updating/access to MediaTypeRegistry, via
(tallison:
[https://github.com/apache/tika/commit/b4cdfcfe19b008c2e9955f42caf6d52e8389a172])
* (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
> Assignee: Tim Allison
> Priority: Major
> Fix For: 1.19, 2.0.0
>
>
> 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)