ShrinkWrap
  1. ShrinkWrap
  2. SHRINKWRAP-455

ConcurrentModificationException during delete on imported archive

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None
    • Similar Issues:
      Show 10 results 

      Description

      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.

        Activity

        Show
        Andrew Rubinger
        added a comment - Upstream: https://github.com/shrinkwrap/shrinkwrap/commit/9883f240f5fe936d53b861e0139d1cb18233a545

          People

          • Assignee:
            Michal Matloka
            Reporter:
            Michal Matloka
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: