and the most important reason for me is the object locked is the record and not makes sense to unlock a thing than doesn't exists. (I see a deja vu about this point )
and the most important reason for me is the object locked is the record and not makes sense to unlock a thing than doesn't exists. (I see a deja vu about this point )
lock->delete record->unlock sequence
This is one issue I had to spend two cups of coffee to think about. I did not keep locking and persistance classes separated, therefore one could not lock or unlock a deleted record. Since deleting a record requires "owning" its lock, I decided unlocking is not required after deleting one record, for simplicity reasons.
lock->delete record->unlock sequence
This is one issue I had to spend two cups of coffee to think about. I did not keep locking and persistance classes separated, therefore one could not lock or unlock a deleted record. Since deleting a record requires "owning" its lock, I decided unlocking is not required after deleting one record, for simplicity reasons.
1. During this sequence: lock->delete record->unlock, if I check the db.isValidRecord() inside the call to locking.unlock(), as you mention, the record will not exist anymore, and an RNFE will be thrown. But its not true, because I need to unlock the record... How did you handle that?
2.About InterruptedException. I did not understand it yet. My implementation is swallowing this exception and checking again the while-expression, and if it was not reached, sleep again. Is this wrong? I need to interrupt the process and return some exception to the client?