Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

confusion - unlock and delete

 
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I've just started with this URLyBird assignment. I'm implementing methods

unlock(rec, cookie) throws RecordNotFoundException,SecurityException
and
delete(rec, cookie) throws RecordNotFoundException,SecurityException.

i wonder what if following scenario happens.

consider the following code:



as unlock() is throwing RecordNotFoundException, I'm checking if the given recNo is valid one (using record flag) before unlocking the record(removing this record entry from lock map).

my question is: since record 10 is already deleted. when the control reaches data.unlock(10,c), RecordNotFoundException would be thrown. is it okay ?? or should I change the code as to check record-valid after unlocking, i mean removing recordNo entry from lock map?.

thanks in advance.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My unlock-method does not contain any check to see if recNo is valid, because that makes no sense. The RecordNotFoundException is only thrown by the lock (and find) method(s).
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Roel De Nijs wrote:My unlock-method does not contain any check to see if recNo is valid, because that makes no sense.



Agreed.

Makeshkumar, what you can do is verify if the record to be unlocked was locked (or, if it is in the structure that keeps the locked records - normally a Map<Long, Long>); if it wasn't, then you can throw IllegalStateException.
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic