You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "Lei Rui (Jira)" <ji...@apache.org> on 2023/01/21 09:02:00 UTC

[jira] [Created] (IOTDB-5433) IndexOutOfBoundsException: ExactOrderStatistics constructs an empty ArrayList and then sets it

Lei Rui created IOTDB-5433:
------------------------------

             Summary: IndexOutOfBoundsException: ExactOrderStatistics constructs an empty ArrayList and then sets it
                 Key: IOTDB-5433
                 URL: https://issues.apache.org/jira/browse/IOTDB-5433
             Project: Apache IoTDB
          Issue Type: Bug
            Reporter: Lei Rui


For example:
{code:java}
  public static double getMad(LongArrayList nums) {
    if (nums.isEmpty()) {
      throw new NoSuchElementException();
    } else {
      double median = getMedian(nums);
      DoubleArrayList dal = new DoubleArrayList();
      for (int i = 0; i < nums.size(); ++i) {
        dal.set(i, Math.abs(nums.get(i) - median));
      }
      return getMedian(dal);
    }
  }
{code}

"DoubleArrayList dal = new DoubleArrayList();" will construct an empty list, and dal.set(...) will throw IndexOutOfBoundsException.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)