cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel FOUCHE (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-5016) ArithmeticException on ResponseTimeCounterMBean.getAvgResponseTime() after counter reset()
Date Wed, 15 May 2013 09:01:21 GMT
Emmanuel FOUCHE created CXF-5016:
------------------------------------

             Summary: ArithmeticException on ResponseTimeCounterMBean.getAvgResponseTime()
after counter reset()
                 Key: CXF-5016
                 URL: https://issues.apache.org/jira/browse/CXF-5016
             Project: CXF
          Issue Type: Bug
          Components: Management
    Affects Versions: 2.7.0
            Reporter: Emmanuel FOUCHE
            Priority: Minor


A JMX client program such as monitoring platform (Nagios plugin, HypericHQ, ...) retrieve
metrics like AvgResponseTime per minute.
One way to retrieve data is to fetch value every minute and reset counter immediately after.

However, if no calls to the service has been made since last reset, you get an ArithmeticException
"divide by zero" when calling ResponseTimeCounterMBean.getAvgResponseTime()

I suggest handling this case by returning 0 or -1 instead, thus avoiding exception and alarming
stacktrace on the monitoring client side.

{code:title=ResponseTimeCounter.getAvgResponseTime()}
public Number getAvgResponseTime() {        
  if (_invocations.get() == 0) {
     return -1; // avoid divide by 0;
  }
  return (int)(totalHandlingTime / invocations.get());
}
{code}




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message