A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?
Originally posted by Hu Yong Jun: A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?
It could be thrown with this check:
1) !Is the record locked? AND (&) 2) !Does the record exist?
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Your Database interface says unLock method could throw RecordNotFoundException but that doesn�t mean you have to throw it in your implementation.
For me it is not logical to throw that exceptions, because when ever I locked a record no way one can deleted (unless I have a bug in me code), and by that the only two situations a RecordNotFoundException will be throw is:
You locked a record, you deleted it, you tried to unlock.
There is a Bug in your locking.
So my conclusion you don�t have to throw that exception. [ October 12, 2004: Message edited by: Omar Kalaldeh ]
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
Are you saying that you're not locking a record before you delete it?
Noooooooooooooooooooo,
you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method
Righty-ho, I'm glad we've got that cleared up
The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.
The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.
Again I am talking about unLock method not delete method.
and as for getting marked down I don't think so as long as you state at your design choices document.
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
In my code I just to see if its a valid record number(using the total number of records including deleted), and not if the record was deleted(the record exists although its deleted). Although this sittuation is impossible it can be used to detect bugs in the upper layer code.