File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S : Exception

 
henry ang
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

I am quite puzzle as to why the given requirement require us to throw RecordNotFoundException in the method lockRecord(long recNo)

I have a hashmap(lockedRecords) which stored the recNo and its matching cookie value.

In the event that a recNo is found in the hashmap, it would mean someone is already using it, and the client wanting to lock the record would need to wait until it is unlocked by the prev client.

In the event that no recNo is found in the lockedRecords, it would mean that the recNo is safe to use for the calling client, and my program would update the hashmap, return the cookie number and notify all.

However, i can't see the occasion where i need to throw a RecordNotFoundException
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just because the method signature in the interface mentions the exception doesn't mean the implementation class must actually throw it.
It just means the implementation class CAN throw it.
 
Mike Ngo
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, i can't see the occasion where i need to throw a RecordNotFoundException


what if the recoNo does not exist in the database file?
 
henry ang
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike..

You are right.. this is the condition which i have missed
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic