A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3100 below:

[java] UseCorrectExceptionLogging FP in 6.31.0 · Issue #3100 · pmd/pmd · GitHub

Affects PMD Version: 6.31.0

Rule: UseCorrectExceptionLogging
https://pmd.github.io/pmd-6.31.0/pmd_rules_java_errorprone.html#usecorrectexceptionlogging

Description:
Apache chukwa has ExceptionUtils which contains getStackTrace().
It is for Getting the stack trace from a Throwable as a String.
Apache hadoop has also StringUtils which contains stringifyException().
it returns a string with exception name and call stack

Code Sample demonstrating the issue:

import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.chukwa.util.ExceptionUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

class TestUseCorrectExceptionLogging{
        private static Log log = LogFactory.getLog(TestUseCorrectExceptionLogging.class);
        public void testPMD(){
                try{
                        //something
                }
                catch(Exception e){
                        log.error(ExceptionUtil.getStackTrace(e));
                        log.error(StringUtils.stringifyException(e));
                }
        }
}

Expected outcome:
Don't show any alarm.

Running PMD through: CLI


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4