Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore specific type of uncaught exception in Eclipse?

I am using a third party library in my Java application. This third party library throws a custom uncaught exception at every application startup. The exception is harmless and only used for logging purposes internally to the third party library. Since this exception is not caught it causes my Eclipse IDE to switch into the debug perspective and suspend the thread execution everytime I start the application to inform me of the issue. I have to manually tell Eclipse to ignore this and just resume debugging every time. This is very annoying. I cannot change the third party library in order to fix this issue.

Is there a way to tell the Eclipse IDE to ignore a specific type of uncaught exception?

I tried "Step Filtering" but (I think) since the custom uncaught exception is not in the stack trace it is not being filtered out from the debugger. This is my first foray into Step Filtering so I could be using it wrong. Here is a sample stack trace.

Daemon Thread [Thread-13] (Suspended (exception CustomThirdPartyException)) 
    ThreadPoolExecutor$Worker.run() line: not available [local variables unavailable]   
    Thread.run() line: not available

EDIT:

jluzwick's work around of using our own logger to watch for uncaught exceptions after disabling all uncaught exceptions in Eclipse could technically work but it is not ideal and it's possible we could miss things if our logger is broken.

mazaneicha's Solution seemed to be on the right track but I could not get it to work exactly the way I wanted. This may be due to user error on my part.

jluzwick and mazaneicha both had possible work arounds to this issue but Konstantin Komissarchik had the "correct" answer in that this should be pushed back to the library's creators to fix. Sometimes a technical solution is not the right one.

like image 414
Tansir1 Avatar asked Mar 01 '11 18:03

Tansir1


1 Answers

An old thread, but figured I'd add a bit to it.

In at least Eclipse Indigo: In the Debug Perspective->Breakpoints view:

  1. Specify a breakpoint for Exceptions (and potentially subclasses) you want to pause on. This is done by clicking the "Add Java Exception Breakpoint". An icon that is a J and an exclamation point.
  2. Right click the breakpoint and select "Breakpoint Properties"
  3. Go to "Filtering"
  4. Specify the Class or Packages you want to ignore. This will add them to the list. Just be sure to uncheck them to delineate that it's exclusive (do not stop in the specified location)

I tend to use this so that I can specify NullPointerExceptions as a general exception breakpoint, but ignore packages that are from third party libraries.

like image 67
Jeff Avatar answered Oct 11 '22 11:10

Jeff