<AWT Dev> RFR: 8263530: sun.awt.X11.ListHelper.removeAll() should use clear()

Aleksey Shipilev shade at openjdk.java.net
Fri Mar 12 16:13:29 UTC 2021


SonarCloud reports:
  Remove or correct this "removeAll" call.

    void removeAll() {
        items.removeAll(items); // <--- here
        updateScrollbars();
    }

Calling `removeAll()` with the same collection risks concurrent modification exceptions. `clear()` would be correct and more efficient.

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

Commit messages:
 - 8263530: sun.awt.X11.ListHelper.removeAll() should use clear()

Changes: https://git.openjdk.java.net/jdk/pull/2974/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2974&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263530
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2974.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2974/head:pull/2974

PR: https://git.openjdk.java.net/jdk/pull/2974


More information about the awt-dev mailing list