Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deadlock testing class for B&S 2.2.1

 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is adapted from Bob Perillo's original class which was used for Urlybird. Anyone utilisng this class will probably have to make some
adjustments, especially in the FindingRecordsThread() method. One area where your code may differ is that I did my unlocking in a finally block
and I also used a cache map to cut down on I/O. The loop can be increased to whatever you like and exceptions will be thrown dependant upon
input. The program should complete fairly quickly and if it sits there hanging this probably indicates deadlock.

Hope others find the class useful.

Cheers Kevin.

 
Roel De Nijs
Sheriff
Posts: 10230
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin,

Does your unlock method doesn't throw any Exception, like a RecordNotFoundException for example?

Because this code in my program result in compiler errors. And adding try/catch block in the finally-block seems a little bit crappy


It could be of course that our assignments differ at that point
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My unlock() method throws a SecurityException when the passed cookie doesn't match the cookie held in the locking map.

My Sun DBAccess interface for unlock() method is:

 
Roel De Nijs
Sheriff
Posts: 10230
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And i guess your SecurityException is a checked exception... But how could this code compile in your test-case? Or maybe i'm missing something here but i would expect a try/catch around the call to unlock in the finally block

 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Roel not quite sure what you mean here? And my SecurityException class extends RuntimeException.

My lock/process/unlock method calls are delegated to my Data class. so my RemoteServicesImpl class calls the following on the Data singleton
delegated on SERVER mode startup



I don't call unlock() within say the Update() method. But yes the whole lock/process/unlock is within a try block.

Both these classes throw either a ServicesException/RemoteServicesException so when the Data instance is called this is also
wrapped in a try/catch block.
 
Roel De Nijs
Sheriff
Posts: 10230
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin,

I was just wondering why your deadlock testing class compiles, but if your SecurityException extends RuntimeException (like you said), then that's the reason why. I thought that your SecurityException was a checked exception (like i did myself in my code, but with the RecordNotFoundException), so i was a bit amazed that your code did compile.

So you solved the "mystery"

Kind regards,
Roel
 
Lukas Jenny
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you very much for your Test Class.

As I'm currently doing the Version 2.3.2 of the B&S assignment I had to adapt it a bit. Now it runs without exception on my code. I hope this still means that my locking is ok.

btw: Do we have to note the first comment in every class? I can't remember having read something like this...

Best regards
Lukas Jenny

 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
btw: Do we have to note the first comment in every class? I can't remember having read something like this...


No you don't is the simple answer, it's just there for clarity.
 
Lukas Jenny
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin,

Ok, thanks for your answer.

best regards
Lukas Jenny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic