Skip to content

Subsequent calls to Connection.close() should not throw an error and be ignored #32

@gilius38

Description

@gilius38

According to jdbc spec: "Calling the method close on a Connection object that is already closed is a no-op."
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#close()

This simple code throws an error:

    Class.forName("org.drizzle.jdbc.DrizzleDriver").newInstance();
    Connection conn = null;
    {
        conn = DriverManager.getConnection("jdbc:mysql:thin://" + HOST + ":"
                + PORT + "/" + DB, USER, PASS);
    }
    conn.close();
    conn.close();

Proposed fix in DrizzleConnection:

    public void close() throws SQLException {
        if (isClosed())
            return;
        ...

Note: I was unable to tell whether the timeoutExecutor could be running while protocol.isClosed() is true. It might be worth trying to this.timeoutExecutor.shutdown(); in any case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions