You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Brian Ewins (JIRA)" <ji...@apache.org> on 2006/12/04 12:37:22 UTC

[jira] Created: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Log or throw exception in PropertyUtilsBean, not both
-----------------------------------------------------

                 Key: BEANUTILS-266
                 URL: http://issues.apache.org/jira/browse/BEANUTILS-266
             Project: Commons BeanUtils
          Issue Type: Improvement
          Components: Bean / Property Utils
    Affects Versions: 1.7.0
         Environment: all
            Reporter: Brian Ewins


This commit (related to BEANUTILS-224):
http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990

improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.

I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Posted by "Brian Ewins (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/BEANUTILS-266?page=comments#action_12455368 ] 
            
Brian Ewins commented on BEANUTILS-266:
---------------------------------------

Whoops, my bad on thinking that was the responsible change. However - why not initCause() the caught exception rather than log it? It is possible to do this even while keeping compatibility with jdk1.3 (I see this is the target in the project xml). 

One way of doing this is already in the commons: org.apache.commons.httpclient.util.ExceptionUtil.initCause()

The advantage is that (on newer jdks) when you eventually do log the exception that PUB throws, you'll see the whole stacktrace, not half here, half further back in the log.



> Log or throw exception in PropertyUtilsBean, not both
> -----------------------------------------------------
>
>                 Key: BEANUTILS-266
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-266
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>    Affects Versions: 1.7.0
>         Environment: all
>            Reporter: Brian Ewins
>            Priority: Minor
>             Fix For: 1.8.0
>
>
> This commit (related to BEANUTILS-224):
> http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990
> improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.
> I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-266?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497636 ] 

Niall Pemberton commented on BEANUTILS-266:
-------------------------------------------

Thanks for the suggestion - I used the HttpClient code. The only problem is I can't actually get PropertyUtilsBean's invoke method to throw an IllegalArgumentException in that place - other types of exceptions yes, but not that one. Looking at the code though I don't know why its only catching IllegalArgumentException and not any error. Any chance you could provide a test case that causes this?

> Log or throw exception in PropertyUtilsBean, not both
> -----------------------------------------------------
>
>                 Key: BEANUTILS-266
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-266
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>    Affects Versions: 1.7.0
>         Environment: all
>            Reporter: Brian Ewins
>            Priority: Minor
>             Fix For: 1.8.0
>
>
> This commit (related to BEANUTILS-224):
> http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990
> improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.
> I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved BEANUTILS-266.
---------------------------------------

    Resolution: Fixed
      Assignee: Niall Pemberton

Sorry forget that - I've re-produced and added a test - closing as fixed

> Log or throw exception in PropertyUtilsBean, not both
> -----------------------------------------------------
>
>                 Key: BEANUTILS-266
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-266
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>    Affects Versions: 1.7.0
>         Environment: all
>            Reporter: Brian Ewins
>         Assigned To: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.8.0
>
>
> This commit (related to BEANUTILS-224):
> http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990
> improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.
> I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Posted by "Brian Ewins (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/BEANUTILS-266?page=comments#action_12455282 ] 
            
Brian Ewins commented on BEANUTILS-266:
---------------------------------------

Rereading that I see I could have been clearer: I mean just remove this line:

log.error("Method invocation failed", e);

from PropertyUtilsBean.invokeMethod()

> Log or throw exception in PropertyUtilsBean, not both
> -----------------------------------------------------
>
>                 Key: BEANUTILS-266
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-266
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>    Affects Versions: 1.7.0
>         Environment: all
>            Reporter: Brian Ewins
>
> This commit (related to BEANUTILS-224):
> http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990
> improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.
> I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (BEANUTILS-266) Log or throw exception in PropertyUtilsBean, not both

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/BEANUTILS-266?page=all ]

Niall Pemberton updated BEANUTILS-266:
--------------------------------------

    Fix Version/s: 1.8.0
         Priority: Minor  (was: Major)

This has nothing to do with the change made 3 weeks ago (revision 471990 for BEANUTILS-224) which didn't change the logging at all. Anyway, thats academic - I don't think we should remove the logging statement since having the original stack trace could be useful debugging information - but changing it to "debug" level rather than error would be a good idea IMO.

> Log or throw exception in PropertyUtilsBean, not both
> -----------------------------------------------------
>
>                 Key: BEANUTILS-266
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-266
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean / Property Utils
>    Affects Versions: 1.7.0
>         Environment: all
>            Reporter: Brian Ewins
>            Priority: Minor
>             Fix For: 1.8.0
>
>
> This commit (related to BEANUTILS-224):
> http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/PropertyUtilsBean.java?view=diff&r1=471989&r2=471990
> improved the error message for illegal arguments, but also introduced a log message for that same exception. Best practice is to log or throw but not both, since this often results in the error being logged multiple times - when it was created and when the exception is caught. In addition this is logging the problem as an error when it may in fact be handled by the caller, so at worst its a debug-level message.
> I switched up to 1.7 recently and this has been filling up my logs. I know I can work around it by disabling logging for this component but the existence of this log message seems like an oversight.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org