From 3295730d28059707144c5b713c15a212140c9d44 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Tue, 24 Nov 2026 11:23:37 -0800 Subject: [PATCH] PHOENIX-8095 MetadataServerConnectionsIT reads empty slots of the thread array Thread.enumerate can fill fewer slots than the array has, when threads exit after activeCount. The test streamed all slots and failed with a NullPointerException on an empty slot. Read only the filled slots. Co-Authored-By: Claude Opus 5.5 --- .../apache/phoenix/end2end/MetadataServerConnectionsIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java index bebabc9bbfd..30084c336fd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataServerConnectionsIT.java @@ -161,9 +161,9 @@ public void createTable(RpcController controller, MetaDataProtos.CreateTableRequ int count = Thread.activeCount(); Thread[] th = new Thread[count]; // returns the number of threads put into the array - Thread.enumerate(th); + int n = Thread.enumerate(th); long hTablePoolCount = - Arrays.stream(th).filter(s -> s.getName().equals("htable-pool-0")).count(); + Arrays.stream(th, 0, n).filter(s -> s.getName().equals("htable-pool-0")).count(); // Assert no default HTable threadpools are created. assertEquals(0, hTablePoolCount); LOGGER.debug("htable-pool-0 threads {}", hTablePoolCount);