Avoid NPE when calling `getTotalKeys()` before `ManagedSelector` is started.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-07-10 19:43:13 +02:00
parent 8d87a80410
commit 4f3b4a092d
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 2 additions and 1 deletions

View File

@ -148,7 +148,8 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
@ManagedAttribute(value = "Total number of keys", readonly = true)
public int getTotalKeys()
{
return _selector.keys().size();
Selector selector = _selector;
return selector == null ? 0 : selector.keys().size();
}
@ManagedAttribute(value = "Average number of selected keys", readonly = true)