You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/14 22:38:16 UTC

[commons-io] 02/02: Use removeIf() for a more efficient implementation which also deals with the PMD empty while loop error.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 0732b44ae2706681a0bc4b8e9d66f0040ff3b3d7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 14 18:37:53 2022 -0400

    Use removeIf() for a more efficient implementation which also deals with
    the PMD empty while loop error.
---
 .../java/org/apache/commons/io/monitor/FileAlterationObserver.java    | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
index 05f766fa..064e2ebe 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
@@ -444,9 +444,7 @@ public class FileAlterationObserver implements Serializable {
      */
     public void removeListener(final FileAlterationListener listener) {
         if (listener != null) {
-            while (listeners.remove(listener)) {
-                // empty
-            }
+            listeners.removeIf(listener::equals);
         }
     }