Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353194

Summary: AbstractDeclarativeValidator: Don't wrap RuntimeException in a RuntimeException
Product: [Modeling] TMF Reporter: Karsten Thoms <karsten.thoms>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Karsten Thoms CLA 2011-07-27 06:40:47 EDT
In AbstractDeclarativeValidator#invoke() the target of a InvocationTargetException is thrown as a RuntimeException. It is not necessary to wrap it when the target is already a RuntimeException, in this case just throw that instance.



        catch (InvocationTargetException e) {
          // ignore GuardException, check is just not evaluated if
          // guard is false
          // ignore NullPointerException, as not having to check for
          // NPEs all the time is a convenience feature
          Throwable targetException = e.getTargetException();
          if (!(targetException instanceof GuardException)
              && !(targetException instanceof NullPointerException))
            if (targetException instanceof RuntimeException)
               throw targetException;
            else
               throw new RuntimeException(targetException);
        }
Comment 1 Sebastian Zarnekow CLA 2011-08-16 17:21:55 EDT
Pushed to master.

Out of curiosity: Have you had any actual problems with the wrapped runtime exception?
Comment 2 Karsten Thoms CLA 2011-08-23 02:50:23 EDT
No, this caused no problems. Just noticed that I have an unnecessary wrapped exception.
Comment 3 Karsten Thoms CLA 2017-09-19 17:14:49 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:26:25 EDT
Closing all bugs that were set to RESOLVED before Neon.0