• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

No RecordNotFoundException would be thrown in the body of Data.unlock() method

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hu Yong Jun:
A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?



It could be thrown with this check:

1) !Is the record locked? AND (&) 2) !Does the record exist?
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your Database interface says unLock method could throw RecordNotFoundException but that doesn�t mean you have to throw it in your implementation.

For me it is not logical to throw that exceptions, because when ever I locked a record no way one can deleted (unless I have a bug in me code), and by that the only two situations a RecordNotFoundException will be throw is:
  • You locked a record, you deleted it, you tried to unlock.
  • There is a Bug in your locking.


  • So my conclusion you don�t have to throw that exception.
    [ October 12, 2004: Message edited by: Omar Kalaldeh ]
     
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    For me it is not logical to throw that exceptions, because when ever I locked a record no way one can deleted



    Hi

    Are you saying that you're not locking a record before you delete it?

    In the version of the assignment I have, the delete method takes a lockCookie param, so a record needs to be locked to delete it.



    Is that the same problem you're having, Hu Yong Jun?

    Rob
     
    Omar Kalaldeh
    Ranch Hand
    Posts: 58
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Rob.

    Are you saying that you're not locking a record before you delete it?



    Noooooooooooooooooooo,

    you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method
     
    Rob Shields
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Noooooooooooooooooooo,

    you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method



    Righty-ho, I'm glad we've got that cleared up

    The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.
     
    Omar Kalaldeh
    Ranch Hand
    Posts: 58
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.



    Again I am talking about unLock method not delete method.

    and as for getting marked down I don't think so as long as you state at your design choices document.
     
    Rob Shields
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Omar

    Again I am talking about unLock method not delete method.



    Sorry, yes, I meant unlock, not delete.

    $myPost =~ s/delete method/unlock method/;

    Rob
    [ October 12, 2004: Message edited by: Rob Shields ]
     
    Ranch Hand
    Posts: 175
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    In my code I just to see if its a valid record number(using the total number of records including deleted), and not if the record was deleted(the record exists although its deleted). Although this sittuation is impossible it can be used to detect bugs in the upper layer code.
     
    Can't .... do .... plaid .... So I did this tiny ad instead:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
    reply
      Bookmark Topic Watch Topic
    • New Topic