zipfs problems
Joel Uckelman
uckelman at nomic.net
Tue Oct 20 13:22:45 PDT 2009
Thus spake Joel Uckelman:
> Hi,
>
> I've been looking at the zipfs demo and have noticed some problems:
>
> * ZipFileSystemProvider.fileSystems has concurrency problems similar to
> ZipFileSystem.closeableObjects.
>
Attached are patches to fix this problem, as well as a patch to add a
missing type parameter.
-------------- next part --------------
# HG changeset patch
# User uckelman at adsl-208-39.dsl.uva.nl
# Date 1256069972 -7200
# Node ID da6c4e140924f13a4e63f11b859ca8acf972e2cb
# Parent 6062b4852112a09a4cf59720a59cc61d40380da7
ZipFileSystemProvider.fileSystems synchronized to prevent concurrent
modification.
diff --git a/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java b/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java
--- a/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java
+++ b/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java
@@ -38,6 +38,7 @@
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.channels.FileChannel;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -46,7 +47,8 @@
extends FileSystemProvider {
private String scheme = "zip";
- private Map<URI, ZipFileSystem> fileSystems = new HashMap<URI, ZipFileSystem>();
+ private Map<URI, ZipFileSystem> fileSystems =
+ Collections.synchronizedMap(new HashMap<URI, ZipFileSystem>());
public ZipFileSystemProvider() {
}
-------------- next part --------------
# HG changeset patch
# User uckelman at adsl-208-39.dsl.uva.nl
# Date 1256069552 -7200
# Node ID 6062b4852112a09a4cf59720a59cc61d40380da7
# Parent 716fe8ce64d09f69265c46466f5d53eca296a35a
Specified type parameter for HashSet.
diff --git a/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java b/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java
--- a/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java
+++ b/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java
@@ -258,7 +258,8 @@
}
}
private static final Set<String> supportedFileAttributeViews =
- Collections.unmodifiableSet(new HashSet(Arrays.asList("basic", "zip", "jar")));
+ Collections.unmodifiableSet(
+ new HashSet<String>(Arrays.asList("basic", "zip", "jar")));
@Override
public Set<String> supportedFileAttributeViews() {
More information about the nio-dev
mailing list