This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Removing RecordNotFoundException from subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Removing RecordNotFoundException from subclass" Watch "Removing RecordNotFoundException from subclass" New topic
Author

Removing RecordNotFoundException from subclass

Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

i think the RecordNotFoundException in the writing methods is not necessary and here's why:

since the lock method already check that the record exist, and the writing methods
make sure the record is locked, that mean one thing ---> the record exist!

just making a point..


SCJP 5, SCWCD 5, SCBCD 5
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4926
    
  10



But you are not the first one, that point is already made several times (I made the same remark more than 2 years ago, and not onlt for the write methods, but also for unlock-method )


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

now that you mention it, it's quite contradictory to have a RecordNotFoundException in the unlock method.
suppose someone lock a record, delete it and then call the unlock.
i just found a bug in my code now thanks to you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Removing RecordNotFoundException from subclass
 
Similar Threads
lock() > delete() > unlock() > BANG!
[NX:URLyBird] About deleted record
B&S: Reading a deleted record - best way to handle this
DB.unlock() vs. RecordNotFoundException
B&S Version 2.3.3 locking