Fix NPE when closing a pool during initialization#864
Open
dkropachev wants to merge 1 commit intoscylladb:scylla-3.xfrom
Open
Fix NPE when closing a pool during initialization#864dkropachev wants to merge 1 commit intoscylladb:scylla-3.xfrom
dkropachev wants to merge 1 commit intoscylladb:scylla-3.xfrom
Conversation
nikagra
reviewed
Apr 9, 2026
Comment on lines
+317
to
+321
| this.connections = connectionsByShard; | ||
| scheduledForCreation = scheduledForCreationByShard; | ||
| open = openByShard; | ||
| trash = trashByShard; | ||
| pendingBorrows = pendingBorrowsByShard; |
There was a problem hiding this comment.
Race window still remains which may cause a partial initialization.
| public void onFailure(Throwable t) { | ||
| phase.compareAndSet(Phase.INITIALIZING, Phase.INIT_FAILED); | ||
| forceClose(connections); | ||
| for (List<Connection> shardConnections : HostConnectionPool.this.connections) { |
There was a problem hiding this comment.
According to Claude there is a chance connections can be null here, hardening recommended
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.
Summary
Users reported the following failure during pool teardown:
java.lang.NullPointerException: Cannot read the array length because "<local2>" is nullat
com.datastax.cql3.scylla_shaded.driver.core.HostConnectionPool.closeAsync(HostConnectionPool.java:841).This change:
HostConnectionPool.closeAsync()tolerate pools that are still uninitialized or only partially initializedTesting
mvn -pl driver-core -Dtest=HostConnectionPoolTest#should_close_uninitialized_pool_without_npe testFixes #85.