This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Unlock method

 
GD Deepz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This method throws SecurityException, its a runtime exception, how do we use it this exception. If the cookie passed in IS NOT the cookie used to lock the record then a security exception is thown?

public void unlock(long recNo, long cookie)
throws SecurityException;
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it in many ways.

Send a response back to user saying that the room cannot be booked(record cannot be locked)
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi GD,

Your code should never see a SecurityException, since the code you write will always keep the cookie that you got back from the lock() method, and then use this cookie in the call to unlock().

How other people handle it is up to them .

Regards, Andrew
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi GD,

If the cookie passed in IS NOT the cookie used to lock the record then a security exception is thown?


Correct.

Regards, Andrew
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,

Under normal conditions this is true

Your code should never see a SecurityException, since the code you write will always keep the cookie that you got back from the lock() method, and then use this cookie in the call to unlock().


A security exception will be thrown during abnormal(exceptional) condition. An exceptional condition can be a data corruption in the network leading to the cookievalue getting changed.
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi GD,

Your code should never see a SecurityException, since the code you write will always keep the cookie that you got back from the lock() method, and then use this cookie in the call to unlock().

How other people handle it is up to them .

Regards, Andrew


Hi Andrew,

I guess the SecurityException proves to be useful as to program debugging. Thanks to the SecurityException in the unlock method that I noticed a flaw in my locking mechanism. Just my 2 cents

Regards,
Clivant
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic