aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Hidden Swing exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Hidden Swing exceptions" Watch "Hidden Swing exceptions" New topic
Author

Hidden Swing exceptions

Miklos Szeles
Ranch Hand

Joined: Oct 21, 2008
Posts: 142
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

Joined: May 03, 2008
Posts: 4642
    
    5

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?


luck, db
There are no new questions, but there may be new answers.
Miklos Szeles
Ranch Hand

Joined: Oct 21, 2008
Posts: 142
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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


[My Blog]
All roads lead to JavaRanch
 
Consider Paul's rocket mass heater.
 
subject: Hidden Swing exceptions