• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hidden Swing exceptions

 
Miklos Szeles
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I found a really annoying bug today in our application. It was a NullPointerException in a table cell renderer. The visible effect of the bug was that some component was only partially visible or not visible at all and the component didn't refreshed itself(only when I dragged the window off the screen and then back).
I've spent more than an hour by commenting out and back lines from the code to find that the NullPointerException in the cell renderer caused the bug. At this time I was lucky, since I was able to locate the bug, but I still had to spend more than an hour with it. Usually Swing prints stack trace on the console, when an exception occures, but not in this case. Can anybody tell me why? Is there a good solution to find these bugs somehow?
I was searching a little bit, and I've found the following code, but it didn't work for this case.


Thanks in advance
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miklos Szeles wrote: a NullPointerException in a table cell renderer. The visible effect of the bug was that some component was only partially visible or not visible at all and the component didn't refreshed itself(only when I dragged the window off the screen and then back).

Looks like a concurrency issue. Does the code respect Swing's single threaded rule?
 
Miklos Szeles
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer Darryl.
I made a small test program for the case and I found that it works fine. I compared the stack traces and at last I found that the only difference is that we use a custom EventQueue in our application. And the problem was there. For some unknown reason somebody put a try catch block in the dispatchEvent method which swallowed the NullPointerException without any log.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some unknown reason somebody put a try catch block in the dispatchEvent method which swallowed the NullPointerException without any log.

Welcome to the amazing world of programming
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic