I think I've found a bug with Set.remove.
I tried to remove an element from a persistent set (not
an inverse set) that was not in that set. I expected the
Set.remove() method tro return false, it returned true
thus breaking the contract of the Set interface.
I tried to find the code and I think it is in...
AbstractSetStore.remove(StateManager sm, Object
element)
Looking at the code, the following lines lead me to think
it will return true even if the element did not exists in the
set...
ps.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Time = " +
(System.currentTimeMillis() - startTime) + " ms: " +
removeStmt);
modified = true;
This does not check the number of rows by the query
and so cannot know if there was a row to delet or not.
Would something like this do the job...
int deleteCount = ps.executeUpdate();
if (LOG.isDebugEnabled())
LOG.debug("Time = " +
(System.currentTimeMillis() - startTime) + " ms: " +
removeStmt);
modified = deleteCount == 1;
Maybe an assertion that deleteCount is < 1 would be
good too.
I couldn't find the unit test for this so don;t know if it has
been tested.
Matty.
Logged In: YES
user_id=582193
Applied. A test has been added for Set.remove() as well.
Thanks,
Mike