Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

unlock with delete

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have in my DB interface



There is a little bit difficult situation:

if I run



RecordNotFoundException should be thrown for the unlock, because record 1 is already deleted.

I handled this situation so that delete unlocks the record and notifies all waiters, but I have started to think if I should change the implementation.

What you think, should there be unlock after delete? I think I can do the new implementation, where the RecordNotFoundException is not thrown from the unlock method if the record is deleted and the lockCookie is correct.

BR,

Mika
 
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
Hi Mika,

Of course a deleted record should be unlocked, otherwise you end up having a deadlock. For example with this scenario:

client2 will now wait forever...

In my solution there is just 1 method (besides read and find) that throws a RNFE and that's the lock-method. Because if the lock-method has successfully locked a record, another client can't do anything with that record (so it certainly can't be deleted). If some other client can update/delete that record, there is something wrong with the locking mechanism. So I created my own custom interface (extending the required one) and i copied the delete, update and unlock method signatures but without the throws RecordNotFoundException clause. I was very pleased with this smart "work-around".

Kind regards,
Roel
 
Mika Tapanainen
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel,

I read yesterday some discussions and removed RNFE from the delete, update and unlock methods as you wrote here also.

Mika
 
Roel De Nijs
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
Hi Mika,

I hope you didn't delete it from Sun's interface, because as far as I know it's forbidden to make changes in that interface.

Kind regards,
Roel
 
Mika Tapanainen
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

Thanks for the reminder! I didn't change Sun's interface.

Mika
 
Yes, my master! Here is the tiny ad you asked for:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic