Uploaded image for project: 'ShrinkWrap'
  1. ShrinkWrap
  2. SHRINKWRAP-455

ConcurrentModificationException during delete on imported archive

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.1.3
    • None
    • None
    • None

      Description from: https://community.jboss.org/message/808603#808603

      I'm trying to use Shrinkwrap to delete a folder in a JavaArchive (jar). My jar is quite simple, it contains only one folder named resources and this folder contains two files :
       
      myJavaArchive.jar:
      /resources/
      /resources/bar.txt
      /resources/foo.txt
       
      So I create a JavaArchive from my JAR file and I call delete method on "/resources" folder (see below) but it causes a ConcurrentModifictionException.
       
      My code : 
       
      package com.test;
        
      import java.io.File;
        
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.spec.JavaArchive;
        
      public class Main {
          public static void main(String[] args) {
              JavaArchive archive = ShrinkWrap.createFromZipFile(JavaArchive.class,
                      new File(Main.class.getResource("/myJavaArchive.jar").getFile()));
              System.out.println(archive.toString(true));
              archive.delete("/resources");
          }
      }
       
       
      The stack trace :
       
      Exception in thread "main" java.util.ConcurrentModificationException
                at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
                at java.util.HashMap$KeyIterator.next(HashMap.java:828)
                at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1010)
                at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.removeNodeRecursively(MemoryMapArchiveBase.java:309)
                at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.delete(MemoryMapArchiveBase.java:291)
                at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.delete(MemoryMapArchiveBase.java:325)
                at org.jboss.shrinkwrap.impl.base.container.ContainerBase.delete(ContainerBase.java:393)
                at com.test.Main.main(Main.java:13)
       
      

      I was able to reproduce this issue.

              mmatloka Michal Matloka (Inactive)
              mmatloka Michal Matloka (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: