ambari-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Gergely (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AMBARI-15585) Losing stacktrace when an exception is cought and an other one is thrown
Date Fri, 25 Mar 2016 10:15:25 GMT
Daniel Gergely created AMBARI-15585:
---------------------------------------

             Summary: Losing stacktrace when an exception is cought and an other one is thrown
                 Key: AMBARI-15585
                 URL: https://issues.apache.org/jira/browse/AMBARI-15585
             Project: Ambari
          Issue Type: Improvement
            Reporter: Daniel Gergely


When throwing an exception in a "catch" block, it should contain the original exception as
a cause.
Otherwise we lose information: the original stacktrace is not obtainable.

This improvement decreases time on investigating issues, since the log contains the root cause
of the exception.

For example in AgentResource:
{noformat}
try {
      heartBeatResponse = hh.handleHeartBeat(message);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Sending heartbeat response with response id " + heartBeatResponse.getResponseId());
        LOG.debug("Response details " + heartBeatResponse);
      }
    } catch (Exception e) {
      LOG.warn("Error in HeartBeat", e);
      throw new WebApplicationException(500); // <--- cause is lost
    }
{noformat}
 should be changed to:
 {noformat}
 try {
      heartBeatResponse = hh.handleHeartBeat(message);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Sending heartbeat response with response id " + heartBeatResponse.getResponseId());
        LOG.debug("Response details " + heartBeatResponse);
      }
    } catch (Exception e) {
      LOG.warn("Error in HeartBeat", e);
      throw new WebApplicationException(e,500);  // <--- the original exception is added
as cause for the new exception
    }
 {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message