src/java.net.http/share/classes/jdk/internal/net/http/ResponseBodyHandlers.java
branchhttp-client-branch
changeset 56138 4f92b988600e
parent 56132 c8a1eccbc719
child 56257 82a9340bdda6
--- a/src/java.net.http/share/classes/jdk/internal/net/http/ResponseBodyHandlers.java	Fri Feb 16 10:34:17 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/ResponseBodyHandlers.java	Fri Feb 16 15:06:29 2018 +0000
@@ -31,7 +31,7 @@
 import java.nio.file.OpenOption;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.security.AccessControlContext;
+import java.nio.file.StandardOpenOption;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentMap;
@@ -52,30 +52,19 @@
 
     /**
      * A Path body handler.
-     *
-     * Note: Exists mainly too allow setting of the senders ACC post creation of
-     * the handler.
      */
-    public static class PathBodyHandler implements UntrustedBodyHandler<Path> {
+    public static class PathBodyHandler implements BodyHandler<Path>{
         private final Path file;
-        private final OpenOption[]openOptions;
-        private volatile AccessControlContext acc;
+        private final List<OpenOption> openOptions;
 
-        public PathBodyHandler(Path file, OpenOption... openOptions) {
+        public PathBodyHandler(Path file, List<OpenOption> openOptions) {
             this.file = file;
             this.openOptions = openOptions;
         }
 
         @Override
-        public void setAccessControlContext(AccessControlContext acc) {
-            this.acc = acc;
-        }
-
-        @Override
         public BodySubscriber<Path> apply(int statusCode, HttpHeaders headers) {
-            PathSubscriber bs = (PathSubscriber) asFileImpl(file, openOptions);
-            bs.setAccessControlContext(acc);
-            return bs;
+            return new PathSubscriber(file, openOptions);
         }
     }
 
@@ -125,22 +114,16 @@
         }
     }
 
-    // Similar to Path body handler, but for file download. Supports setting ACC.
-    public static class FileDownloadBodyHandler implements UntrustedBodyHandler<Path> {
+    // Similar to Path body handler, but for file download.
+    public static class FileDownloadBodyHandler implements BodyHandler<Path> {
         private final Path directory;
-        private final OpenOption[] openOptions;
-        private volatile AccessControlContext acc;
+        private final List<OpenOption> openOptions;
 
-        public FileDownloadBodyHandler(Path directory, OpenOption... openOptions) {
+        public FileDownloadBodyHandler(Path directory, List<OpenOption> openOptions) {
             this.directory = directory;
             this.openOptions = openOptions;
         }
 
-        @Override
-        public void setAccessControlContext(AccessControlContext acc) {
-            this.acc = acc;
-        }
-
         /** The "attachment" disposition-type and separator. */
         static final String DISPOSITION_TYPE = "attachment;";
 
@@ -221,14 +204,7 @@
                         "Resulting file, " + file.toString() + ", outside of given directory");
             }
 
-            PathSubscriber bs = (PathSubscriber)asFileImpl(file, openOptions);
-            bs.setAccessControlContext(acc);
-            return bs;
+            return new PathSubscriber(file, openOptions);
         }
     }
-
-    // no security check
-    private static BodySubscriber<Path> asFileImpl(Path file, OpenOption... openOptions) {
-        return new ResponseSubscribers.PathSubscriber(file, openOptions);
-    }
 }