[jboss-cvs] JBossAS SVN: r91121 - projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 10 20:15:36 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-07-10 20:15:36 -0400 (Fri, 10 Jul 2009)
New Revision: 91121
Modified:
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/ZipFileSystem.java
Log:
Fix a zip indexing bug
Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/ZipFileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/ZipFileSystem.java 2009-07-10 21:34:44 UTC (rev 91120)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/spi/ZipFileSystem.java 2009-07-11 00:15:36 UTC (rev 91121)
@@ -73,7 +73,7 @@
final ZipCatalog catalog = Zip.readCatalog(zipFile);
final Collection<ZipEntry> entries = catalog.allEntries();
final ZipNode rootNode = new ZipNode(new HashMap<String, ZipNode>(), null);
- for (ZipEntry zipEntry : entries)
+ FILES: for (ZipEntry zipEntry : entries)
{
final List<String> tokens = PathTokenizer.getTokens(zipEntry.getName());
ZipNode node = rootNode;
@@ -82,11 +82,17 @@
{
String token = it.next();
final Map<String, ZipNode> children = node.children;
+ if (children == null) {
+ // todo - log bad zip entry
+ continue FILES;
+ }
ZipNode child = children.get(token);
if (child == null)
{
child = it.hasNext() || zipEntry.getEntryType() == ZipEntryType.DIRECTORY ? new ZipNode(new HashMap<String, ZipNode>(), null) : new ZipNode(null, zipEntry);
+ children.put(token, child);
}
+ node = child;
}
}
this.rootNode = rootNode;
@@ -151,11 +157,27 @@
{
final ZipNode zipNode = rootNode.find(pathComponents.iterator());
if (zipNode == null) {
- throw new FileNotFoundException();
+ throw new FileNotFoundException(join(pathComponents));
}
return zipNode;
}
+ private static String join(List<String> pathComponents)
+ {
+ int l = 0;
+ for (String pathComponent : pathComponents)
+ {
+ l += pathComponent.length();
+ }
+ final StringBuilder sb = new StringBuilder(l);
+ for (String pathComponent : pathComponents)
+ {
+ sb.append('/');
+ sb.append(pathComponent);
+ }
+ return sb.toString();
+ }
+
public boolean isReadOnly()
{
return true;
More information about the jboss-cvs-commits
mailing list