Skip to content
Browse files

[SHRINKWRAP-476] Delete path from nestedArchives internal Map on Arch…

…ive.delete call
  • Loading branch information...
1 parent 67a9f5a commit 024e3e4e87faf4593f20ea6bc3b71946629b3ba5 @ALRubinger committed Mar 3, 2014
View
9 impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/MemoryMapArchiveBase.java
@@ -26,6 +26,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchiveEvent;
@@ -62,12 +63,12 @@
/**
* Storage for the {@link Node}s.
*/
- private final Map<ArchivePath, NodeImpl> content = new ConcurrentHashMap<ArchivePath, NodeImpl>();
+ private final ConcurrentMap<ArchivePath, NodeImpl> content = new ConcurrentHashMap<ArchivePath, NodeImpl>();
/**
* Storage for the {@link ArchiveAsset}s. Used to help get access to nested archive content.
*/
- private final Map<ArchivePath, ArchiveAsset> nestedArchives = new ConcurrentHashMap<ArchivePath, ArchiveAsset>();
+ private final ConcurrentMap<ArchivePath, ArchiveAsset> nestedArchives = new ConcurrentHashMap<ArchivePath, ArchiveAsset>();
private final List<ArchiveEventHandler> handlers = new ArrayList<ArchiveEventHandler>();
@@ -306,6 +307,10 @@ private Node removeNodeRecursively(final NodeImpl node, final ArchivePath path)
if (parentNode != null) {
parentNode.removeChild(node);
}
+
+ // Remove from nested archives if present
+ nestedArchives.remove(path);
+
// Recursively delete children if present
if (node.getChildren() != null) {
final Set<Node> children = node.getChildren();
View
20 impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
@@ -22,9 +22,11 @@
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.container.ManifestContainer;
import org.jboss.shrinkwrap.api.container.ServiceProviderContainer;
import org.jboss.shrinkwrap.api.container.WebContainer;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
@@ -408,6 +410,24 @@ public void testAddWebInfStringTargetResourceFromJar() throws Exception {
}
/**
+ * SHRINKWRAP-476
+ */
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void canDeleteEmbeddedArchiveAddedAsLibrary(){
+ String name = "test.jar";
+ WebArchive war = ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(
+ ShrinkWrap.create(JavaArchive.class, name)
+ .add(EmptyAsset.INSTANCE, "some"));
+
+ ArchivePath path = ArchivePaths.create("WEB-INF/lib", name);
+ Assert.assertTrue(war.contains(path));
+ war.delete(path);
+ Assert.assertFalse("Path should have been deleted", war.contains(path));
+ }
+
+ /**
* Override to handle web archive special case (service providers in WEB-INF/classes/META-INF/services)
*
* @throws Exception

0 comments on commit 024e3e4

Please sign in to comment.
Something went wrong with that request. Please try again.