src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java
author dfuchs
Fri, 30 Aug 2019 15:42:27 +0100
branchJDK-8229867-branch
changeset 57968 8595871a5446
parent 47216 71c04702a3d5
permissions -rw-r--r--
JDK-8229867: first prototype
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
     2
 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3865
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.net.www.http;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    29
import java.util.concurrent.locks.ReentrantLock;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.net.ProgressSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.net.www.MeteredStream;
35786
9d26db88aa14 8149653: Move sun.misc.InnocuousThread to jdk.internal.misc
chegar
parents: 29920
diff changeset
    32
import jdk.internal.misc.InnocuousThread;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A stream that has the property of being able to be kept alive for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * multiple downloads from the same server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author Stephen R. Pietrowicz (NCSA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author Dave Brown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
class KeepAliveStream extends MeteredStream implements Hurryable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    // instance variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    HttpClient hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    boolean hurried;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    // has this KeepAliveStream been put on the queue for asynchronous cleanup.
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    50
    protected volatile boolean queuedForCleanup = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
    52
    private static final KeepAliveStreamCleaner queue = new KeepAliveStreamCleaner();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
    53
    private static Thread cleanerThread; // null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public KeepAliveStream(InputStream is, ProgressSource pi, long expected, HttpClient hc)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        super(is, pi, expected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        this.hc = hc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    63
    final ReentrantLock readLock() {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    64
        return readLock;
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    65
    }
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    66
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Attempt to cache this connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public void close() throws IOException  {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    71
        // If the inputstream is closed already, or if this stream
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    72
        // has already been queued for cleanup.just return.
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    73
        if (closed || queuedForCleanup) return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        // Skip past the data that's left in the Inputstream because
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        // some sort of error may have occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // Do this ONLY if the skip won't block. The stream may have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        // been closed at the beginning of a big file and we don't want
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        // to hang around for nothing. So if we can't skip without blocking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        // we just close the socket and, therefore, terminate the keepAlive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        // NOTE: Don't close super class
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    82
        // For consistency, access to `expected` and `count` should be
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    83
        // protected by readLock
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    84
        readLock.lock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        try {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    86
            if (closed || queuedForCleanup) return;
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    87
            try {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    88
                if (expected > count) {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    89
                    long nskip = expected - count;
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    90
                    if (nskip <= available()) {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    91
                        do {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    92
                        } while ((nskip = (expected - count)) > 0L
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    93
                                && skip(Math.min(nskip, available())) > 0L);
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    94
                    } else if (expected <= KeepAliveStreamCleaner.MAX_DATA_REMAINING && !hurried) {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    95
                        //put this KeepAliveStream on the queue so that the data remaining
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    96
                        //on the socket can be cleanup asyncronously.
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    97
                        queueForCleanup(new KeepAliveCleanerEntry(this, hc));
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    98
                    } else {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
    99
                        hc.closeServer();
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   100
                    }
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   101
                }
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   102
                if (!closed && !hurried && !queuedForCleanup) {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   103
                    hc.finished();
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   104
                }
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   105
            } finally {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   106
                if (pi != null)
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   107
                    pi.finishTracking();
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   108
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   109
                if (!queuedForCleanup) {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   110
                    // nulling out the underlying inputstream as well as
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   111
                    // httpClient to let gc collect the memories faster
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   112
                    in = null;
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   113
                    hc = null;
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   114
                    closed = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } finally {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   118
            readLock.unlock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /* we explicitly do not support mark/reset */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public boolean markSupported()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public void mark(int limit) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public void reset() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        throw new IOException("mark/reset not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   134
    public boolean hurry() {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   135
        readLock.lock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            /* CASE 0: we're actually already done */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            if (closed || count >= expected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            } else if (in.available() < (expected - count)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                /* CASE I: can't meet the demand */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                /* CASE II: fill our internal buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                 * Remind: possibly check memory here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                int size = (int) (expected - count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                byte[] buf = new byte[size];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                DataInputStream dis = new DataInputStream(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                dis.readFully(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                in = new ByteArrayInputStream(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                hurried = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            // e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            return false;
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   158
        } finally {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   159
            readLock.unlock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   163
    private static void queueForCleanup(KeepAliveCleanerEntry kace) {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   164
        queue.queueLock.lock();
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   165
        try {
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   166
            if(!kace.getQueuedForCleanup()) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   167
                if (!queue.offer(kace)) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   168
                    kace.getHttpClient().closeServer();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   169
                    return;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   170
                }
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   171
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   172
                kace.setQueuedForCleanup();
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   173
                queue.waiter.signalAll();
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   174
            }
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   175
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   176
            boolean startCleanupThread = (cleanerThread == null);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   177
            if (!startCleanupThread) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   178
                if (!cleanerThread.isAlive()) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   179
                    startCleanupThread = true;
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   180
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   183
            if (startCleanupThread) {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   184
                java.security.AccessController.doPrivileged(
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   185
                    new java.security.PrivilegedAction<Void>() {
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   186
                    public Void run() {
36680
c9fe8f8e7e6f 8151571: InnocuousThread cannot be created during early startup
mchung
parents: 35786
diff changeset
   187
                        cleanerThread = InnocuousThread.newSystemThread("Keep-Alive-SocketCleaner", queue);
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   188
                        cleanerThread.setDaemon(true);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   189
                        cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   190
                        cleanerThread.start();
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   191
                        return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    }
3865
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   193
                });
cc2ca3d07bbb 6882654: Remove dependency on java.util.concurrent from KeepAlive implementaion
chegar
parents: 715
diff changeset
   194
            }
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   195
        } finally {
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   196
            queue.queueLock.unlock();
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   197
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    protected long remainingToRead() {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   201
        assert readLock.isHeldByCurrentThread();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return expected - count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    protected void setClosed() {
57968
8595871a5446 JDK-8229867: first prototype
dfuchs
parents: 47216
diff changeset
   206
        assert readLock.isHeldByCurrentThread();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        in = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        hc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        closed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
}