Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird: about the RecordNotFoundException of unlock method.

 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Zhongbo Li
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't need to unlock, if successful the deletion of a record in the business layer.
[ June 24, 2008: Message edited by: Zhongbo Li ]
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic