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

NX: (Contractors) Error handling between lock/unlock

 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble determining what to do in the case where a client calls lockRecord successfully but unlock (or a call to updateRecord) fails. I am thinking that this will be too difficult to deal with and that I might cop-out and write in my documentation that the complexity of solving the solution outweighed the need for it.
Have any of you handled this problem gracefully?
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,
public long lockRecord(long recNo) throws RecordNotFoundException;
It means lockRecord will throw RNFE if the record is not available. Once the record is locked after the record is found, updateRecord() will just update the database. If there are any exceptions while updating, in the catch block, you should call unlock(long recNo, long lockCookie) to unlock the record which is already locked.
Am I right guys?
Ganapathy.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is about the unlock possibly failing.
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry,
This is not a junk name what I am using. This is a proper and a popular name (Ganapathy, Ganeshan are very common names). This is the name I use normally.
Let me know, if any problem with my name Barry.
Ganapathy
[ May 02, 2003: Message edited by: Venkateswara Rao Gunturu ]
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry,
I feel updateRecord() may fail due to some IOExceptions, but unlock() won't fail. In unlock we just remove the entry from the collection object(may be HashMap interface in this case) and call collectionObj.notifyAll().
Ganapathy
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simply unlock in finally clause and you'll be alright
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic