Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5742

StopWatch.getDuration produces incorrect results

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.8.0
    • None
    • Core Framework
    • None

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            harschware Tim Harsch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: