This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

SecurityException never thrown??

 
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??
 
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.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • 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 ]
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic