[ https://issues.apache.org/jira/browse/NIFI-5742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16661809#comment-16661809 ]
Koji Kawamura commented on NIFI-5742: ------------------------------------- [~harschware] Thanks for reporting the issue. I think returning duration if getElapsed() is called when duration > -1 is the safe and most meaningful way to fix this. Do you want to submit a patch for this? > StopWatch.getDuration produces incorrect results > ------------------------------------------------ > > Key: NIFI-5742 > URL: https://issues.apache.org/jira/browse/NIFI-5742 > Project: Apache NiFi > Issue Type: Bug > Components: Core Framework > Affects Versions: 0.8.0 > Reporter: Tim Harsch > Priority: Major > > getDuration will produce unexpected results when the StopWatch has been > stopped. > See: > https://github.com/apache/nifi/blob/02261311b3b3f765ebb394f8f101b0373a7fb3ab/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/StopWatch.java#L77 > Currently, if the stopwatch has been stopped it returns the current nanos > since epoch - (-1), which is meaningless at best and likely to cause issues > for applications using this method. > It should either return an exception because the elapsed time has no meaning > after being stopped, or return the elapsed time when the watch was stopped, > or just keep going and return the current value. > The following gist demonstrates the problem: > https://gist.github.com/harschware/6974b61837618574bae6ab75369ead30 -- This message was sent by Atlassian JIRA (v7.6.3#76005)