From instructions: // Releases the lock on a record. Cookie must be the cookie // returned when the record was locked; otherwise throws SecurityException. public void unlock(long recNo, long cookie) throws SecurityException; I think in no case will SecurityException be thrown. Can anybody tell me the case that ecurityException will be thrown??
biang
Philippe Maquet
Bartender
Joined: Jun 02, 2003
Posts: 1872
posted
0
Hi Biang,
Can anybody tell me the case that SecurityException will be thrown??
When you pass the unlock() method a cookie which was not returned (produced) by the lock() method on that recNo. (I am not sure what you don't understand there - Can you be more precise ?) Cheers, Phil. [ July 13, 2003: Message edited by: Philippe Maquet ]
biang lin
Ranch Hand
Joined: Jun 02, 2003
Posts: 91
posted
0
"When you pass the unlock() method a cookie which was not returned (produced) by the lock() method on that recNo. " I think this would never happen.
Andrew Monkhouse
author and jackaroo
Marshal Commander
"When you pass the unlock() method a cookie which was not returned (produced) by the lock() method on that recNo. " I think this would never happen.
It should never happen, and probably never does happen in the code you wrote. But who is to say what some other application may do? If the programmer was malicious (or even just lazy) they could try and unlock a record that they dont own the lock on. Sun have given a specific instruction implying that you have to guard against this. So even if it is unlikely, you still have to check for it, and throw the exception if it happens. Regards, Andrew