db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: A potential bug report
Date Tue, 13 Sep 2011 08:56:52 GMT
Yiqing Zhu <XGDJ_alex@hotmail.com> writes:

> Hi, 
> Thank you very much for your reply.
> I find one program semantic rule in this class is "each time when
> 'currentRow' is set to null, 'currentRowHasBeenUpdated' should be set
> to false, which is done by calling initializeUpdateRowModifiers(). And
> this rule is proved by the comments in this class.
> I think your point of view is right. After the "close()" is called,
> the "isClosed" field will be set to true, so if other methods in this
> class are called and check this value, it will throw SQLException.
> However, because I don’t have a complete idea of derby, I'm not sure
> whether there exists some method missing checking the "isClosed"
> field, so I think this inconsistent state may cause some potential
> problem.


The JDBC specification requires that all ResultSet methods throw
SQLException when called on a closed ResultSet (except close() and
isClosed(), but they will not do any work and return immediately). So if
some public method doesn't check the isClosed field, that's a bug that
would have to be fixed.

I think your understanding of the invariants in the EmbedResultSet class
is correct. However, these invariants only have any meaning while the
ResultSet is open. Once it's closed, the state of the ResultSet is
simply that, closed, and no other state variable carries any meaning

Semantically, the close() method doesn't have to set currentRow to null.
It is only done in case it references some large objects that it would
be better to allow the garbage collector to reclaim, since we will not
access them anymore. Calling initializeUpdateRowModifiers() to reset
some boolean flags that aren't used anymore, doesn't have any similar
benefits, so I think it is better to leave the code as it is and not do
that extra work every time a ResultSet is closed.


Knut Anders

View raw message