United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6459029 Attempt to close Query object after closing DataSet throws NPE
JDK-6459029 : Attempt to close Query object after closing DataSet throws NPE

Details
Type:
Bug
Submit Date:
2006-08-10
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-08-25
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.sql
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
After closing a DataSet, an attempt to close the associated Query object throws a NPE, even though the isClosed() method of the Query object returns false.

The attached test case produces the following output:

Dropping table...
Creating table...
Closing DataSet addressesDS.
Is addressesDS closed? true
Is Query object aq closed? false
Closing Query object aq.
Exception in thread "main" java.sql.SQLRuntimeException: java.lang.NullPointerException
        at com.sun.sql.QueryObjectGeneratorImpl.deregisterAllDataSets(Unknown Source)
        at com.sun.sql.QueryObjectGeneratorImpl.invoke(Unknown Source)
        at $Proxy0.close(Unknown Source)
        at CloseTest.main(CloseTest.java:67)
Caused by: java.lang.NullPointerException
        at com.sun.sql.DataSetImpl$DataSetItr.<init>(Unknown Source)
        at com.sun.sql.DataSetImpl.iterator(Unknown Source)
        at java.util.AbstractList.hashCode(AbstractList.java:524)
        at java.util.WeakHashMap.remove(WeakHashMap.java:543)
        at java.util.WeakHashMap$HashIterator.remove(WeakHashMap.java:779)
        ... 4 more

                                    

Comments
EVALUATION

After DataSet is closed, the hashCode for that DataSet results in NullPointerException. Need to ignore closed DataSet.
                                     
2006-08-24
SUGGESTED FIX

The closed datasets are not closed when QueryObject.close() is called.
Also weakReferences is cleared when QueryObject.close() is called.

checkin logs:
Checking in DataSetImpl.java;
/m/jws/jdbc4.0/src/com/sun/sql/DataSetImpl.java,v  <--  DataSetImpl.java
new revision: 1.56; previous revision: 1.55
done
Checking in QueryObject.java;
/m/jws/jdbc4.0/src/com/sun/sql/QueryObject.java,v  <--  QueryObject.java
new revision: 1.3; previous revision: 1.2
done
                                     
2006-08-25



Hardware and Software, Engineered to Work Together