7017840: (zipfs) test/demo/zipfs/basic.sh needs to be updated due to 7013420
authorsherman
Tue, 08 Feb 2011 13:30:30 -0800
changeset 8190 c8cdf811a171
parent 8189 5fd29d2cbc4b
child 8191 c9d1e3a6d6a2
child 8192 f0ee3e38944a
child 8193 626b859aabb2
7017840: (zipfs) test/demo/zipfs/basic.sh needs to be updated due to 7013420 Summary: updated try-with-resourcse usage in test/demo code Reviewed-by: alanb
jdk/src/share/demo/nio/zipfs/Demo.java
jdk/test/demo/zipfs/ZipFSTester.java
jdk/test/demo/zipfs/basic.sh
--- a/jdk/src/share/demo/nio/zipfs/Demo.java	Tue Feb 08 19:31:44 2011 +0000
+++ b/jdk/src/share/demo/nio/zipfs/Demo.java	Tue Feb 08 13:30:30 2011 -0800
@@ -156,7 +156,6 @@
         if (action == Action.create)
             env.put("create", "true");
         try (FileSystem fs = provider.newFileSystem(Paths.get(args[1]), env)) {
-            FileSystem fs2;
             Path path, src, dst;
             boolean isRename = false;
             switch (action) {
@@ -201,12 +200,12 @@
                 Files.copy(src, dst, COPY_ATTRIBUTES);
                 break;
             case zzmove:
-                try (fs2 = provider.newFileSystem(Paths.get(args[2]), env)) {
+                try (FileSystem fs2 = provider.newFileSystem(Paths.get(args[2]), env)) {
                     z2zmove(fs, fs2, args[3]);
                 }
                 break;
             case zzcopy:
-                try (fs2 = provider.newFileSystem(Paths.get(args[2]), env)) {
+                try (FileSystem fs2 = provider.newFileSystem(Paths.get(args[2]), env)) {
                     z2zcopy(fs, fs2, args[3]);
                 }
                 break;
--- a/jdk/test/demo/zipfs/ZipFSTester.java	Tue Feb 08 19:31:44 2011 +0000
+++ b/jdk/test/demo/zipfs/ZipFSTester.java	Tue Feb 08 13:30:30 2011 -0800
@@ -72,7 +72,7 @@
         }
     }
 
-    static void test1(FileSystem fs)
+    static void test1(FileSystem fs0)
         throws Exception
     {
         Random rdm = new Random();
@@ -80,11 +80,11 @@
         Path tmpfsPath = getTempPath();
         Map<String, Object> env = new HashMap<String, Object>();
         env.put("create", "true");
-        FileSystem fs0 = newZipFileSystem(tmpfsPath, env);
-        z2zcopy(fs, fs0, "/", 0);
-        fs0.close();                // sync to file
+        try (FileSystem copy = newZipFileSystem(tmpfsPath, env)) {
+            z2zcopy(fs0, copy, "/", 0);
+        }
 
-        try (fs = newZipFileSystem(tmpfsPath, new HashMap<String, Object>())) {
+        try (FileSystem fs = newZipFileSystem(tmpfsPath, new HashMap<String, Object>())) {
 
             FileSystemProvider provider = fs.provider();
             // newFileSystem(path...) should not throw exception
--- a/jdk/test/demo/zipfs/basic.sh	Tue Feb 08 19:31:44 2011 +0000
+++ b/jdk/test/demo/zipfs/basic.sh	Tue Feb 08 13:30:30 2011 -0800
@@ -21,7 +21,7 @@
 # questions.
 #
 # @test
-# @bug 6990846 7009092 7009085 7015391 7014948 7005986
+# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840
 # @summary Test ZipFileSystem demo
 # @build Basic PathOps ZipFSTester
 # @run shell basic.sh