changeset 2834:64328fe5e4a6

8024434: problem running javadoc tests in samevm mode on Windows Reviewed-by: darcy
author jjg
date Fri, 06 Sep 2013 15:31:59 -0700
parents 7c7b4aea6d50
children e84587462a47
files src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java test/tools/javadoc/api/basic/APITest.java test/tools/javadoc/api/basic/GetTask_FileManagerTest.java
diffstat 3 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java	Fri Sep 06 09:53:24 2013 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java	Fri Sep 06 15:31:59 2013 -0700
@@ -34,6 +34,7 @@
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -221,8 +222,10 @@
         /** If the file is a directory, list its contents. */
         public Iterable<DocFile> list() throws IOException {
             List<DocFile> files = new ArrayList<DocFile>();
-            for (Path f: Files.newDirectoryStream(file)) {
-                files.add(new StandardDocFile(f));
+            try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) {
+                for (Path f: ds) {
+                    files.add(new StandardDocFile(f));
+                }
             }
             return files;
         }
--- a/test/tools/javadoc/api/basic/APITest.java	Fri Sep 06 09:53:24 2013 +0100
+++ b/test/tools/javadoc/api/basic/APITest.java	Fri Sep 06 15:31:59 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URI;
+import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
@@ -164,11 +165,13 @@
     }
 
     private void listFiles(Path dir, Set<Path> files) throws IOException {
-        for (Path f: Files.newDirectoryStream(dir)) {
-            if (Files.isDirectory(f))
-                listFiles(f, files);
-            else if (Files.isRegularFile(f))
-                files.add(f);
+        try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)) {
+            for (Path f: ds) {
+                if (Files.isDirectory(f))
+                    listFiles(f, files);
+                else if (Files.isRegularFile(f))
+                    files.add(f);
+            }
         }
     }
 
--- a/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java	Fri Sep 06 09:53:24 2013 +0100
+++ b/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java	Fri Sep 06 15:31:59 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6493690
+ * @bug 6493690 8024434
  * @summary javadoc should have a javax.tools.Tool service provider
  * @build APITest
  * @run main GetTask_FileManagerTest