RFR: 8088923: IOOBE when adding duplicate categories to the BarChart

Markus Mack mmack at openjdk.org
Wed Jun 19 10:26:25 UTC 2024


This PR provides the test case given in the JBS issue, and a simple fix for the index calculation when inserting data after previous data with duplicate categories.

Also, I've added a comment to `BarChart`s javadoc, clarifying the behavior that was apparently assumed (but broken) previously.

The index lookup is skipped for performance reasons if there are no duplicates, corresponding to the previous implementation.
Further optimizations would be possible, but probably are not really helpful without more extensive changes. The previous code already loops over all categories to check if they are present, typically nested in a loop adding many data items, thus already scaling quadratically when adding lots of mostly unique data points.

-------------

Commit messages:
 - BarChart duplicate category index fix + test

Changes: https://git.openjdk.org/jfx/pull/1476/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1476&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8088923
  Stats: 19 lines in 2 files changed: 18 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jfx/pull/1476.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1476/head:pull/1476

PR: https://git.openjdk.org/jfx/pull/1476


More information about the openjfx-dev mailing list