< prev index next >

src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -269,34 +269,28 @@
                     : new FilePermission[] { filePermission };
         }
 
         @Override
         public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {
-            InputStream is = null;
-            Throwable t = null;
+            InputStream is;
             if (System.getSecurityManager() == null) {
                 try {
                     is = new FileInputStream(file);
                 } catch (IOException ioe) {
-                    t = ioe;
+                    throw new UncheckedIOException(ioe);
                 }
             } else {
                 try {
                     PrivilegedExceptionAction<FileInputStream> pa =
                             () -> new FileInputStream(file);
                     is = AccessController.doPrivileged(pa, null, filePermissions);
                 } catch (PrivilegedActionException pae) {
-                    t = pae.getCause();
+                    throw new UncheckedIOException((IOException) pae.getCause());
                 }
             }
-            final InputStream fis = is;
-            PullPublisher<ByteBuffer> publisher;
-            if (t == null) {
-                publisher = new PullPublisher<>(() -> new StreamIterator(fis));
-            } else {
-                publisher = new PullPublisher<>(null, t);
-            }
+            PullPublisher<ByteBuffer> publisher =
+                    new PullPublisher<>(() -> new StreamIterator(is));
             publisher.subscribe(subscriber);
         }
 
         @Override
         public long contentLength() {
< prev index next >