SOLR-18188: Misc test fixes#4496
Merged
Merged
Conversation
- PrepRecoveryOp: add class-level javadoc - ShowFileRequestHandlerTest, TestPrometheusResponseWriter, TestCborDataFormat: close response streams to fix resource leaks - TestDistributedTracing: retry logic for span assertions to reduce flakiness Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
setSoTimeout(1000) is classic "fix the thread that won't die during test teardown" advice. The accept loop in SocketProxy blocks indefinitely on serverSocket.accept(). Without a timeout, when the test calls close(), the acceptor thread is stuck in accept() and can't notice it should stop — it lingers until the JVM exits or some other socket event breaks it out. This causes test hangs or "thread leaked" warnings from the Solr test framework.
Move proxy.close() from the finally block to before server.stop(). If proxy.close() stays in the finally block and qtp.join() blocks indefinitely (e.g. stuck PrepRecoveryOp handlers or H2C session threads), the finally block is never reached and the SocketProxy acceptor thread leaks. Closing the proxy first ensures cleanup even when server shutdown hangs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mkhludnev
approved these changes
Jun 3, 2026
dsmiley
added a commit
that referenced
this pull request
Jun 9, 2026
Accumulated from several commits on the misc-test-fixes branch. PrepRecoveryOp: add class-level javadoc to explain its purpose. ShowFileRequestHandlerTest, TestPrometheusResponseWriter, TestCborDataFormat: close response streams to fix resource leaks flagged by the test framework. TestDistributedTracing: add retry logic around span assertions to reduce flakiness caused by timing-sensitive telemetry delivery. SocketProxy: call setSoTimeout(1000) on the server socket so the accept loop unblocks promptly when close() is called. Without a timeout the acceptor thread blocks indefinitely in accept() and leaks, causing test hangs or "thread leaked" warnings. JettySolrRunner: move proxy.close() to before server.stop() rather than leaving it in the finally block. If qtp.join() hangs (e.g. stuck PrepRecoveryOp handlers or H2C session threads) the finally block is never reached, leaving the SocketProxy acceptor thread leaked. Closing the proxy first ensures cleanup even when server shutdown hangs. HttpJettySolrClientCompatibilityTest: switch from @ClassRule to @rule so the Jetty server lifecycle is per-test as intended. TestSolrJ: delete this file -- it contains no actual tests. ClientUtils: add Objects.requireNonNull() guard on serverRootUrl to surface null earlier with a clear error rather than a cryptic NPE downstream. AbstractFullDistribZkTestBase: wrap control-collection creation in RetryUtil.retryOnException() to tolerate transient ZooKeeper errors during setup. Also move coreClients.clear(), solrClientByCollection.clear(), and super.destroyServers() into a finally block after ExecutorUtil.shutdownAndAwaitTermination() so teardown always completes even if the executor shutdown throws. HttpPartitionTest: decrease leaderConflictResolveWait to 10sec so stale PrepRecoveryOp handlers time out within the Jetty graceful stop window Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A set of test-related misc fixes / docs that I didn't want to include in #4451 and that which weren't PR/commit worthy by themselves.
I'll merge this in a couple days with a lengthy commit message.