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

Closing MySqlDataSource Connection object made using named pipe results in java.io.SocketException warning

    XMLWordPrintable

Details

    • x86_64
    • windows

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.192]

      A DESCRIPTION OF THE PROBLEM :
      This is a bug originally logged with the MySQL team in 2011. They concluded it was a JVM bug but from searching, it appears it was never logged here.

      Original report: https://bugs.mysql.com/bug.php?id=62518

      Although the code in the original report uses DriverManager, the same warning is shown when closing a Connection object obtained from a MySqlDataSource object:

      MysqlDataSource dataSource = new MysqlDataSource();
      dataSource.setURL(DB_URL);
      dataSource.setUser(DB_USER);
      dataSource.setPassword(DB_PASSWORD);
      dataSource.setSocketFactory("com.mysql.jdbc.NamedPipeSocketFactory");
      dataSource.setUseSSL(false);
      conn = dataSource.getConnection();

      Once conn.close() is called, an exception is displayed as a log message in the output console:
      ---Message block---
      Fri Feb 09 12:03:32 GMT 2018 WARN: Caught while disconnecting...

      EXCEPTION STACK TRACE:



      ** BEGIN NESTED EXCEPTION **

      java.net.SocketException
      MESSAGE: Socket is not connected

      STACKTRACE:

      java.net.SocketException: Socket is not connected
      at java.net.Socket.shutdownInput(Socket.java:1523)
      at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2246)
      at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4236)
      at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1462)
      at apiconnection.connectors.DBConnector.closeConnection(DBConnector.java:53)
      at apiconnection.connectors.DBConnector.populateCustomFieldInfoTable(DBConnector.java:1074)
      at apiconnection.connectors.APIConnector.putCustomFieldInfo(APIConnector.java:268)
      at apiconnection.APIConnection.main(APIConnection.java:20)


      ** END NESTED EXCEPTION **
      ---End of message block---

      The MySQL team found that close() is in fact called on the Connection object. However, for an unknown reason, the socket is disconnected before Socket.shutdownInput() is called.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a Connection object using a named pipe and then close it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Connection object would close normally.
      ACTUAL -
      The following displayed in the output console:

      Fri Feb 09 12:03:32 GMT 2018 WARN: Caught while disconnecting...

      EXCEPTION STACK TRACE:



      ** BEGIN NESTED EXCEPTION **

      java.net.SocketException
      MESSAGE: Socket is not connected

      STACKTRACE:

      java.net.SocketException: Socket is not connected
      at java.net.Socket.shutdownInput(Socket.java:1523)
      at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2246)
      at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4236)
      at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1462)
      at apiconnection.connectors.DBConnector.closeConnection(DBConnector.java:53)
      at apiconnection.connectors.DBConnector.populateCustomFieldInfoTable(DBConnector.java:1074)
      at apiconnection.connectors.APIConnector.putCustomFieldInfo(APIConnector.java:268)
      at apiconnection.APIConnection.main(APIConnection.java:20)


      ** END NESTED EXCEPTION **

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Fri Feb 09 12:03:32 GMT 2018 WARN: Caught while disconnecting...

      EXCEPTION STACK TRACE:



      ** BEGIN NESTED EXCEPTION **

      java.net.SocketException
      MESSAGE: Socket is not connected

      STACKTRACE:

      java.net.SocketException: Socket is not connected
      at java.net.Socket.shutdownInput(Socket.java:1523)
      at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2246)
      at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4236)
      at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1462)
      at apiconnection.connectors.DBConnector.closeConnection(DBConnector.java:53)
      at apiconnection.connectors.DBConnector.populateCustomFieldInfoTable(DBConnector.java:1074)
      at apiconnection.connectors.APIConnector.putCustomFieldInfo(APIConnector.java:268)
      at apiconnection.APIConnection.main(APIConnection.java:20)


      ** END NESTED EXCEPTION **

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      As the MySQL team concluded that Connection.close() is called anyway, the resulting warning can, presumably, be ignored. Database interaction does not appear to be affected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: