Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I throw RecordNotFoundException in lock()?

 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


public long lockRecord(long recNo) throws RecordNotFoundException


According lock method signature provided by Sun, it throws RNFE, if I don't want to check invalid record and discard RNFE in my implementation, is it OK?

Thank you,
Surasak
 
Anthony Watson
Ranch Hand
Posts: 327
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of one good reason why you should throw the RecordNotFoundException from lockRecord: A client may in the future want to lock a record down indefinitely, without calling any other methods on the data object before or after locking. This might happen if a subcontractor was suspended and could not be used for a while. In this case, all the client would want to do is call the lockRecord method, which is public. The client could not count on discovering that a record did not exist by calling other methods like readRecord because all the client wants to do is lock the record. Thus, the client should be made aware that a record does not exist if it tries to lock a record, and hence the RecordNotFoundException should be thrown in lockRecord.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic