Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8208657

Endless loop in SSLSocketImpl.waitForClose for MSSQL JDBC driver

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Microsoft Windows [Version 10.0.10586]
      openjdk version "11-ea" 2018-09-25
      OpenJDK Runtime Environment 18.9 (build 11-ea+24)
      OpenJDK 64-Bit Server VM 18.9 (build 11-ea+24, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      JDBC connection cannot be obtained by MSSQL JDBC driver 6.4 in Java 11-ea24. DriverManager.getConnection hangs because of an endless loop in SSLSocketImpl.waitForClose.
      In Java 10.0.2, a connection can be established.

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the sample.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A JDBC connection.
      ACTUAL -
      No result. Program hangs in

      sun.security.ssl.SSLSocketImpl.class:
          private void waitForClose() throws IOException {
      ...
              while (!conContext.isInboundDone()) { // endless
              }

      jstack.exe shows:

      "main" #1 prio=5 os_prio=0 cpu=73328.13ms elapsed=75.83s tid=0x0000015602def000 nid=0x214c runnable [0x000000425f0fe000]
         java.lang.Thread.State: RUNNABLE
      at java.lang.Throwable.fillInStackTrace(java.base@11-ea/Native Method)
      at java.lang.Throwable.fillInStackTrace(java.base@11-ea/Throwable.java:787)
      - locked <0x0000000767a73f80> (a java.io.EOFException)
      at java.lang.Throwable.<init>(java.base@11-ea/Throwable.java:270)
      at java.lang.Exception.<init>(java.base@11-ea/Exception.java:66)
      at java.io.IOException.<init>(java.base@11-ea/IOException.java:58)
      at java.io.EOFException.<init>(java.base@11-ea/EOFException.java:62)
      at sun.security.ssl.SSLSocketInputRecord.decode(java.base@11-ea/SSLSocketInputRecord.java:169)
      at sun.security.ssl.SSLTransport.decode(java.base@11-ea/SSLTransport.java:108)
      at sun.security.ssl.SSLSocketImpl.decode(java.base@11-ea/SSLSocketImpl.java:877)
      at sun.security.ssl.SSLSocketImpl.waitForClose(java.base@11-ea/SSLSocketImpl.java:952)
      at sun.security.ssl.SSLSocketImpl.closeSocket(java.base@11-ea/SSLSocketImpl.java:929)
      at sun.security.ssl.SSLSocketImpl.shutdown(java.base@11-ea/SSLSocketImpl.java:1170)
      at sun.security.ssl.TransportContext.initiateOutboundClose(java.base@11-ea/TransportContext.java:567)
      at sun.security.ssl.TransportContext.closeOutbound(java.base@11-ea/TransportContext.java:482)
      at sun.security.ssl.TransportContext.close(java.base@11-ea/TransportContext.java:450)
      at sun.security.ssl.SSLSocketImpl.close(java.base@11-ea/SSLSocketImpl.java:447)
      - locked <0x0000000760000b70> (a sun.security.ssl.SSLSocketImpl)
      at com.microsoft.sqlserver.jdbc.TDSChannel.disableSSL(IOBuffer.java:711)
      at com.microsoft.sqlserver.jdbc.TDSWriter.writePacket(IOBuffer.java:4093)
      at com.microsoft.sqlserver.jdbc.TDSWriter.endMessage(IOBuffer.java:3196)
      at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:7712)
      at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:7700)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4547)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3409)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3373)
      at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7344)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713)
      - locked <0x0000000760006228> (a java.lang.Object)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077)
      at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623)
      at java.sql.DriverManager.getConnection(java.sql@11-ea/DriverManager.java:677)
      at java.sql.DriverManager.getConnection(java.sql@11-ea/DriverManager.java:189)
      at SSLCloseHangsInJDBCDriver.main(SSLCloseHangsInJDBCDriver.java:18)


      ---------- BEGIN SOURCE ----------
      ------ Java source ------
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.util.Properties;

      public class SSLCloseHangsInJDBCDriver {

      public static void main(String[] args) throws Exception {
      System.out.println("PID=" + ProcessHandle.current().pid());

      Properties props = new Properties();
      props.put("user", "sa");
      props.put("password", "sa123456");
      props.put("socketTimeout", "10");

      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

      Connection cnn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433", props);
      System.out.println("cnn=" + cnn);
      cnn.close();
      System.out.println("OK");
      }

      }

      --- BAT for compile and test ---
      @echo off
      set JAVA_HOME="c:\Program Files\OpenJDK\jdk-11"
      REM set JAVA_HOME="c:\Program Files\OpenJDK\jdk-10.0.2"
      set JAVAC=%JAVA_HOME%\bin\javac
      set JAVA=%JAVA_HOME%\bin\java
      set CLASSPATH=.\bin;.\lib\mssql-jdbc-6.4.0.jre9.jar

      REM compile
      DEL /Q .\bin\*.*
      %JAVAC% -d .\bin .\src\SSLCloseHangsInJDBCDriver.java

      REM execute
      VER
      %JAVA% -version
      %JAVA% SSLCloseHangsInJDBCDriver

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No Workaround.

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psonal Pallavi Sonal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: