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
Affects PMD Version: 6.31.0
Rule: UseCorrectExceptionLogging
https://pmd.github.io/pmd-6.31.0/pmd_rules_java_errorprone.html#usecorrectexceptionlogging
Description:
Apache chukwahas ExceptionUtils which containsgetStackTrace().It is for Getting the stack trace from a Throwable as a String.
Apache hadoophas also StringUtils which containsstringifyException().it returns a string with exception name and call stack
Code Sample demonstrating the issue:
Expected outcome:
Don't show any alarm.
Running PMD through: CLI