| Bug #42183 | cacheResultSetMetaData causing NullPointerException with CallableStatements | ||
|---|---|---|---|
| Submitted: | 17 Jan 2009 22:55 | Modified: | 20 Jan 2009 16:07 |
| Reporter: | Chris Lampley | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | 5.1.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[20 Jan 2009 16:03]
Tonci Grgin
Test case
Attachment: TestBug42183.java (text/java), 2.43 KiB.
[20 Jan 2009 16:07]
Tonci Grgin
Hi Chris and thanks for your report. I am unable to repeat it using latest c/J sources against MySQL server 5.1.31 on Win2k8 x64 localhost. Test case is attached. For sake of completeness, here are additional settings in my connection string (Window/Preferences/JAva/Installed JREs in Eclipse): -Xmx512M -XX:+UseParallelGC -Djavax.net.debug=all -Dcom.mysql.jdbc.java6.javac=C:\jvms\jdk1.6.0\bin\javac.exe -Dcom.mysql.jdbc.java6.rtjar=C:\jvms\jdk1.6.0\jre\lib\rt.jar -Dcom.mysql.jdbc.testsuite.url.default=jdbc:mysql://localhost:3306/test?user=root&password=*******&autoReconnect=false&connectTimeout=5000&socketTimeout=30000&enablePacketDebug=true&rewriteBatchedStatements=true Other details: Connected to 5.1.30-community-log java.vm.version : 1.5.0_17-b04 java.vm.vendor : Sun Microsystems Inc. java.runtime.version : 1.5.0_17-b04 os.name : Windows Server 2008 os.version : null sun.management.compiler : HotSpot Client Compiler Time: 0,433 OK (1 test) If you can provide me with accurate test case I will retry. Also, you can try latest available version and see if it helps. In either case keep me informed.

Description: When setting cacheResultSetMetadata=true, if no result set is returned, the following exception is being thrown. Stack Trace: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.initializeResultsMetadataFromCache(ConnectionImpl.java:5485) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1027) at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:878) .... How to repeat: 1. Setup the following jdbc url settings: noAccessToProcedureBodies=true emulateUnsupportedPstmts=true useServerPrepStmts=false jdbcCompliantTruncation=false cacheCallableStmts=false elideSetAutoCommits=true cachePrepStmts=true cacheResultSetMetadata=true zeroDateTimeBehavior=convertToNull 2. Create a procedure that returns an empty result set using a SELECT *. Suggested fix: Based off the release version of ConnectionImpl.java for version 5.1.7. Index: src/com/mysql/jdbc/ConnectionImpl.java =================================================================== --- src/com/mysql/jdbc/ConnectionImpl.java +++ src/com/mysql/jdbc/ConnectionImpl.java @@ -5449,7 +5449,7 @@ /** * Caches CachedResultSetMetaData that has been placed in the cache using * the given SQL as a key. - * + * 00 * This method is synchronized by the caller on getMutex(), so if * calling this method from internal code in the driver, make sure it's * synchronized on the mutex that guards communication with the server. @@ -5482,11 +5482,14 @@ this.resultSetMetadataCache.put(sql, cachedMetaData); } else { - resultSet.initializeFromCachedMetaData(cachedMetaData); - resultSet.initializeWithMetadata(); + if (resultSet != null) { - if (resultSet instanceof UpdatableResultSet) { - ((UpdatableResultSet)resultSet).checkUpdatability(); + resultSet.initializeFromCachedMetaData(cachedMetaData); + resultSet.initializeWithMetadata(); + + if (resultSet instanceof UpdatableResultSet) { + ((UpdatableResultSet)resultSet).checkUpdatability(); + } } } }