< prev index next >
src/share/classes/sun/security/ssl/SSLSocketImpl.java
Print this page
*** 598,609 ****
--- 598,628 ----
shutdownInput(false);
}
}
} else {
if (!conContext.isInboundClosed()) {
+ Exception caughtException = null;
+ try {
+ // Try the best to use up the input records and close the
+ // socket gracefully, without impact the performance too
+ // much.
+ appInput.deplete();
+ } catch (Exception e) {
+ caughtException = e;
+ throw e;
+ } finally {
+ if (caughtException != null) {
+ try {
+ conContext.inputRecord.close();
+ } catch (Throwable t) {
+ caughtException.addSuppressed(t);
+ }
+ } else {
conContext.inputRecord.close();
}
+ }
+ }
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
}
*** 897,906 ****
--- 916,949 ----
}
}
return false;
}
+
+ /**
+ * Try the best to use up the input records so as to close the
+ * socket gracefully, without impact the performance too much.
+ */
+ private synchronized void deplete() {
+ if (!conContext.isInboundClosed()) {
+ if (!(conContext.inputRecord instanceof SSLSocketInputRecord)) {
+ return;
+ }
+
+ SSLSocketInputRecord socketInputRecord =
+ (SSLSocketInputRecord)conContext.inputRecord;
+ try {
+ socketInputRecord.deplete(
+ conContext.isNegotiated && (getSoTimeout() > 0));
+ } catch (IOException ioe) {
+ if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+ SSLLogger.warning(
+ "input stream close depletion failed", ioe);
+ }
+ }
+ }
+ }
}
@Override
public synchronized OutputStream getOutputStream() throws IOException {
if (isClosed()) {
< prev index next >