This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SecurityException never thrown?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "SecurityException never thrown??" Watch "SecurityException never thrown??" New topic
Author

SecurityException never thrown??

biang lin
Ranch Hand

Joined: Jun 02, 2003
Posts: 91
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
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
"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

Joined: Mar 28, 2003
Posts: 11404
    
  81

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
biang lin
Ranch Hand

Joined: Jun 02, 2003
Posts: 91
Thank you Andrew,
I think I have understood after reading your reply.
[ July 13, 2003: Message edited by: biang lin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SecurityException never thrown??
 
Similar Threads
Question of unlock() method
unlock cookie problem
Reusing the record number
B&S 2.1.1: lock(), delete() and unlock() confusion
URLyBird 1.2.1 - SecurityException