--- old/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java 2021-01-13 21:50:32.242967138 +0000 +++ new/src/share/classes/sun/security/ssl/SSLSocketInputRecord.java 2021-01-13 21:50:32.042963902 +0000 @@ -472,4 +472,17 @@ return n; } + + // Try to use up the input stream without impact the performance too much. + void deplete(boolean tryToRead) throws IOException { + int remaining = is.available(); + if (tryToRead && (remaining == 0)) { + // try to wait and read one byte if no buffered input + is.read(); + } + + while ((remaining = is.available()) != 0) { + is.skip(remaining); + } + } }