You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Duncan Doyle (JIRA)" <ji...@apache.org> on 2019/04/19 16:17:00 UTC

[jira] [Updated] (CAMEL-13437) ThrowExceptionProcessor should use 'getConstructor' instead of 'getDeclaredConstructor', so it doesn't force users to implement the constructors of their exception classes.

     [ https://issues.apache.org/jira/browse/CAMEL-13437?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Duncan Doyle updated CAMEL-13437:
---------------------------------
    Description: 
ThrowExceptionProcessor uses this line of code to retrieve the constructor of an Exception class:
{code:java}
Constructor<?> constructor = type.getDeclaredConstructor(String.class);{code}
The problem is that this will only find constructors defined in the actual class itself, not in its superclasses. This forces users to unnecessarily implement a constructor that excepts a {{String}} in their custom exception classes.

Easy fix, use the following method:
{code:java}
Constructor<?> constructor = type.getConstructor(String.class);{code}
 Will fix and create a PR.

  was:
ThrowExceptionProcessor uses this line of code to retrieve the constructor of an Exception class:
{code:java}
Constructor<?> constructor = type.getDeclaredConstructor(String.class);{code}
The problem is that this will only find constructors defined in the actual class itself, not in its superclasses. This forces users to unnecessarily implement a constructor that excepts a {{String}} in their custom exception classes.

Easy fix, use the following method:
{code:java}
Constructor<?> constructor = type.getConstructor(String.class);{code}
 


> ThrowExceptionProcessor should use 'getConstructor' instead of 'getDeclaredConstructor', so it doesn't force users to implement the constructors of their exception classes.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-13437
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13437
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.23.2
>            Reporter: Duncan Doyle
>            Priority: Major
>
> ThrowExceptionProcessor uses this line of code to retrieve the constructor of an Exception class:
> {code:java}
> Constructor<?> constructor = type.getDeclaredConstructor(String.class);{code}
> The problem is that this will only find constructors defined in the actual class itself, not in its superclasses. This forces users to unnecessarily implement a constructor that excepts a {{String}} in their custom exception classes.
> Easy fix, use the following method:
> {code:java}
> Constructor<?> constructor = type.getConstructor(String.class);{code}
>  Will fix and create a PR.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)