< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2016, 2019, 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 --- 1,7 ---- /* ! * 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,302 **** : new FilePermission[] { filePermission }; } @Override public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { ! InputStream is = null; ! Throwable t = null; if (System.getSecurityManager() == null) { try { is = new FileInputStream(file); } catch (IOException ioe) { ! t = ioe; } } else { try { PrivilegedExceptionAction<FileInputStream> pa = () -> new FileInputStream(file); is = AccessController.doPrivileged(pa, null, filePermissions); } catch (PrivilegedActionException pae) { ! t = pae.getCause(); } } ! final InputStream fis = is; ! PullPublisher<ByteBuffer> publisher; ! if (t == null) { ! publisher = new PullPublisher<>(() -> new StreamIterator(fis)); ! } else { ! publisher = new PullPublisher<>(null, t); ! } publisher.subscribe(subscriber); } @Override public long contentLength() { --- 269,296 ---- : new FilePermission[] { filePermission }; } @Override public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { ! InputStream is; if (System.getSecurityManager() == null) { try { is = new FileInputStream(file); } catch (IOException ioe) { ! throw new UncheckedIOException(ioe); } } else { try { PrivilegedExceptionAction<FileInputStream> pa = () -> new FileInputStream(file); is = AccessController.doPrivileged(pa, null, filePermissions); } catch (PrivilegedActionException pae) { ! throw new UncheckedIOException((IOException) pae.getCause()); } } ! PullPublisher<ByteBuffer> publisher = ! new PullPublisher<>(() -> new StreamIterator(is)); publisher.subscribe(subscriber); } @Override public long contentLength() {
< prev index next >