aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird: about the RecordNotFoundException of unlock method. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "URLyBird: about the RecordNotFoundException of unlock method." Watch "URLyBird: about the RecordNotFoundException of unlock method." New topic
Author

URLyBird: about the RecordNotFoundException of unlock method.

Ronggen Liu
Ranch Hand

Joined: Jul 29, 2007
Posts: 40
Hi guys,

the method unlock in Data.java will throw out the RecordNotFoundException when the record not found, but here is a case i encountered in the delete method, you know, in the business layer, when we want to delete a record, first, we will lock the record, then, delete the record, last, unlock the record, but because the record had been deleted, so the RecordNotFoundException will be throw out.

what do you guys think about it?

Thank you!
Ronggen


SCJP 1.4,<br />SCJD Java 2,<br />...
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
Hi:
I think that's an uncertain point in this project.
As you said, RecordNotFoundException will be thrown every time if you delete a record. That's weird cuz this should be ok.
So, in my unlock method implementation, I left the signaure there but didn't implement the part of throwing RecordNotFoundException, which means I didn't check the database and throw a RecordNotFoundException if the record doesn't exist because of the delete scenario.
And I bullet this on my choice.txt to tell why I didn't throw a RecordNotFoundException in my unlock.


SCEA, SCJD, SCDJWS, SCWCD, SCJP
Zhongbo Li
Greenhorn

Joined: Dec 06, 2003
Posts: 23
Don't need to unlock, if successful the deletion of a record in the business layer.
[ June 24, 2008: Message edited by: Zhongbo Li ]

SCJP,SCJD,软件设计师<br />Skype:mediumwave<br />QQ:85646604<br /><a href="http://www.yjping.com" target="_blank" rel="nofollow">http://www.yjping.com</a>
rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
An exception is about a situation which shouldn't have occurred. Something is wrong when an exception happens.
Now, in this case, it is clear that if the previous method called was the delete method, the absence of the record is exactly what we would except.

Raising an exception in a situation which is to be expected is very silly, and typically not a situation in which it is appropriate to raise the exception.

So just ignore the throws clause, and put in your javadoc that the exception is never raised by this method.


_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Ronggen Liu
Ranch Hand

Joined: Jul 29, 2007
Posts: 40
for simple implementation, i will not throw the RNFE in the unlock method, thank you guys for your replys.

Thank you!
Ronggen
Jean Robillard
Greenhorn

Joined: Apr 07, 2008
Posts: 16
Hmm I don't know which version of URLyBird you guys are working on, but my version (1.2.3) of URLyBird does not throw RNFE from unlock, only SecurityException. This makes sense for me because my implementation of unlock() does not care whether the record is deleted or not, it cares only that it can successfully unlock a record.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: URLyBird: about the RecordNotFoundException of unlock method.
 
Similar Threads
An unlock method that doesn't throw RecordNotFoundException
locking and RecordNotFoundException
unlock method question
My Choices
B&S RecordNotFoundException: what exactly does it mean?