From 7661a24bf9d489c75a26ba65340ab4f00086d5b6 Mon Sep 17 00:00:00 2001 From: strogiyotec Date: Sat, 24 Jun 2023 13:04:19 -0700 Subject: [PATCH 1/3] Issue #9947 - check that SelectorManager has not null _selectors before calculating #totalKeys --- .../src/main/java/org/eclipse/jetty/io/SelectorManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index ad35aa2f388b..08030b3cb7e4 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -147,6 +147,10 @@ protected void execute(Runnable task) @ManagedAttribute(value = "Total number of keys in all selectors", readonly = true) public int getTotalKeys() { + if (_selectors == null || _selectors.length == 0) + { + return 0; + } int keys = 0; for (final ManagedSelector selector : _selectors) { From ca5a76f593ef71069982ed70f5aeef66be11a191 Mon Sep 17 00:00:00 2001 From: strogiyotec Date: Sat, 24 Jun 2023 15:05:41 -0700 Subject: [PATCH 2/3] Issue #9947 check if selecto isn't null before calculating #totalKeys --- .../java/org/eclipse/jetty/io/SelectorManager.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index 08030b3cb7e4..acacd8a549bd 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -147,14 +147,13 @@ protected void execute(Runnable task) @ManagedAttribute(value = "Total number of keys in all selectors", readonly = true) public int getTotalKeys() { - if (_selectors == null || _selectors.length == 0) - { - return 0; - } int keys = 0; - for (final ManagedSelector selector : _selectors) + for (ManagedSelector selector : _selectors) { - keys += selector.getTotalKeys(); + if (selector != null) + { + keys += selector.getTotalKeys(); + } } return keys; } From c25125bfde7be1b918cf64b39924e4eaafdf58f5 Mon Sep 17 00:00:00 2001 From: strogiyotec Date: Sat, 24 Jun 2023 15:32:03 -0700 Subject: [PATCH 3/3] Issue #9947 Fix formatting --- .../src/main/java/org/eclipse/jetty/io/SelectorManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index acacd8a549bd..fab730916228 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -151,14 +151,11 @@ public int getTotalKeys() for (ManagedSelector selector : _selectors) { if (selector != null) - { keys += selector.getTotalKeys(); - } } return keys; } - /** * @return the number of selectors in use */