db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: Possible NPE code bug in DRDAConnThread.writeSQLCINRD - any ideas??
Date Fri, 11 Jan 2008 19:31:49 GMT
Knut Anders Hatlen wrote:
> Daniel John Debrunner <djd@apache.org> writes:
> 
>> In DRDAConnThread.writeSQLCINRD() at line 4129 we have:
>>
>>     ResultSet rs = null;
>>
>>     ...
>>
>>     if (!stmt.needsToSendParamData)    <<< line 4129
>> 	 rs = stmt.getResultSet();
>>
>>
>> then later at line 4137 we access rs regardless of its setting:
>>
>>    ResultSetMetaData rsmeta = rs.getMetaData();
>>
>> this will lead to an NPE if stmt.needsToSendParamData was true.
>>
>> Any ideas on what is going on here? Should the test of
>> needsToSendParamData be removed?
> 
> I think the test is there to ensure that we don't send the result set
> until all out parameters (for callable statements) have been sent. The
> only place writeSQLCINRD() is called, stmt.finishParams() is called
> first, so needsToSendParamData is always false when writeSQLCINRD() is
> called.
> 
> Since the intention seems to be that !needsToSendParamData is a
> precondition for writeSQLCINRD(), I think it would be fine to replace
> the test with an assert.
> 

Thanks for looking into this, I just removed the check. If you want to 
put an assert in go ahead, but I couldn't see the real reason for such 
an assert given the way the code is structured.

Dan.

Mime
View raw message