[CONJ-261] NullPointerException when closing a streaming statement twice Created: 2016-02-29  Updated: 2016-04-28  Resolved: 2016-04-28

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.3.4, 1.3.5
Fix Version/s: 1.3.6

Type: Bug Priority: Major
Reporter: David Smith Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

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)



 Comments   
Comment by Diego Dupin [ 2016-04-28 ]

this has been corrected in 1.3.6.
test added to avoid any regression : https://github.com/MariaDB/mariadb-connector-j/commit/58f90dcfbc77f10f3618063e785fa597ee126c2f

Generated at Thu Feb 08 03:14:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.