counts in commands classes should be long not int

XMLWordPrintable

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor
    • 4.22.0, 6.1.0, 7.0.1
    • Affects Version/s: 7.0.1
    • Component/s: None
    • None

      Line: int currentCount = GrouperUtil.intValue(debugMap.get(countKey), 0);

      The parameter numberOfCalls is long, but currentCount is read as int. Then on the next line:
       debugMap.put(countKey, currentCount + numberOfCalls);
       
      This expression currentCount + numberOfCalls promotes to long (since numberOfCalls is long), so the first time it works fine. But on the second calldebugMap.get(countKey) returns a Long object, and GrouperUtil.intValue() is being asked to convert a Long to int — which could truncate if the value exceeds Integer.MAX_VALUE.

      It's not a practical problem (you'd need billions of API calls in a single provisioner run to overflow), but it's inconsistent — currentCount should be long using GrouperUtil.longValue() to match the type of numberOfCalls, just like currentMillis on the next line correctly uses longValue. It's a minor code quality issue, not a real bug.

            Assignee:
            Chris Hyzer
            Reporter:
            Chris Hyzer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: