• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SecurityException never thrown??

 
biang lin
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Pie
Posts: 11941
211
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Biang
"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
 
biang lin
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Andrew,
I think I have understood after reading your reply.
[ July 13, 2003: Message edited by: biang lin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic