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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Aleksey Shipilev-5
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
Reply | Threaded
Open this post in threaded view
|

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

Sergey Bylokhov-2
On Fri, 12 Mar 2021 15:44:39 GMT, Aleksey Shipilev <[hidden email]> wrote:

> 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.

It will be good to update the year in Copyright as well.

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

Marked as reviewed by serb (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2974
Reply | Threaded
Open this post in threaded view
|

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

Alexander Zuev-3
In reply to this post by Aleksey Shipilev-5
On Fri, 12 Mar 2021 15:44:39 GMT, Aleksey Shipilev <[hidden email]> wrote:

> 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.

Marked as reviewed by kizune (Reviewer).

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

PR: https://git.openjdk.java.net/jdk/pull/2974
Reply | Threaded
Open this post in threaded view
|

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

Aleksey Shipilev-5
In reply to this post by Aleksey Shipilev-5
> 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.

Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:

  Update copyright

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/2974/files
  - new: https://git.openjdk.java.net/jdk/pull/2974/files/7dc5ab53..d1565744

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2974&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2974&range=00-01

  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
Reply | Threaded
Open this post in threaded view
|

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

Aleksey Shipilev-5
In reply to this post by Aleksey Shipilev-5
On Fri, 12 Mar 2021 15:44:39 GMT, Aleksey Shipilev <[hidden email]> wrote:

> 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.

This pull request has now been integrated.

Changeset: 7b4aefe9
Author:    Aleksey Shipilev <[hidden email]>
URL:       https://git.openjdk.java.net/jdk/commit/7b4aefe9
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

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

Reviewed-by: serb, kizune

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

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