Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-261

NullPointerException when closing a streaming statement twice

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.3.4, 1.3.5
    • 1.3.6
    • Other
    • None
    • Windows 7, MariaDB 5.5.47 serve

    Description

      The problem can be reproduced using this simple example, replacing the obvious bits with server location, port, etc.

      package com.dms.mariadb;
       
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.Statement;
       
      public class MariaDbNPETest
      {
          public static void main(final String[] args)
          {
              try (final Connection dbConnection = DriverManager.getConnection("jdbc:mariadb://<machine>:<port>/<dbName>", "<username>", "<password>"))
              {
                  Class.forName("org.mariadb.jdbc.Driver");
       
                  final Statement statement = dbConnection.createStatement();
       
                  // Make sure it is a streaming statement:
                  statement.setFetchSize(Integer.MIN_VALUE);
       
                  for (int count = 1; count <= 10; count++)
                  {
                      try
                      {
                          System.out.println("Closing count: " + count);
       
                          statement.close();
                      }
                      catch (final Exception ex)
                      {
                          ex.printStackTrace();
                          break;
                      }
                  }
              }
              catch (final Exception ex)
              {
                  ex.printStackTrace();
              }
          }
      }
      

      This is the output I get:

      Closing count: 1
      Closing count: 2
      java.lang.NullPointerException
      	at org.mariadb.jdbc.MariaDbStatement.getInternalMoreResults(MariaDbStatement.java:908)
      	at org.mariadb.jdbc.MariaDbStatement.close(MariaDbStatement.java:588)
      	at com.dms.mariadb.MariaDbNPETest.main(MariaDbNPETest.java:31)
      

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            DavidSmith David Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.