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

deleteMethod and unlock

 
Harish Yerneni
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers:

I am trying to run concurrency test on delete method. My pseudo code is



Consider this scenario:
100 = lockRecord(5)
deleteRecord(5, 100)
unlock(5, 100)

lockRecord(5) will throw RNFE
unlock(5, 0) will throw Security Exception when in theory I was expecting RNFE.
unlock() method had only SecurityException and didnt have RecordNotFoundException in the signature in my
assignment. How is everyone handling this?

Thanks,

Harish
 
Chih-Wei Lee
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
My assignment has RNFE on unlock method signature but
I didn't really throw it in my unlock method implementation.
The reason is if user delete a record, it makes sense there is no RNFE is thrown from unlock method. Unlock method should only remove this record from the locked list instead of checking the database file and then throw a RNFE.
If the second thread try to lock this record, the lock method will throw RNFE.
 
Harish Yerneni
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Lee.

Harish
 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi;

also don't check if the record exist or not because your unlock don't throws it. so you are safe by just check for security exception.
my assignment tell me that the unlock throws SecurityException and RecordNotFoundException and i implements that and i will document that this case does not make sense as you talk.

Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic