Hi guys,
I have also faced this problem and thought about it. The delete process will have to be lock() -> delete() -> unlock() , so which means that throwing RNFException on unlocking will always happen if the condition to throw RNFException is record not existing or deleted. This does not make sense.
Post 04 April 2009 16:27:58 Subject: unlock method question
It could be when you try to unlock a record that doesn't exist... obviously, this is not likely to happen in your application, but we have to think that we are creating these APIs for other people to use, you know... so if someone uses it wrongly, then we're prepared.
Even if someone else is trying to use this API, why would he/she unlock something that is not locked.
My solution to locking records in the database is using Map<Integer,Long> so every record that is locked is registered.
So the only condition I can consider of throwing RNFException is when the record number entered is not registered in the Map.
PS : the specification on the assignment about throwing RNFException is
Any methods that throw RecordNotFoundException
should do so if a specified record does not exist or is marked as deleted in the database file.
It's not a must statement, so it should be safe if you dont fully follow it.