Pass empty Configuration in DelegatingCluster#8
Merged
nchandrappa merged 1 commit intoyugabyte:3.8.0-yb-xfrom Aug 5, 2021
ebyhr:delegating-cluster-npe
Merged
Pass empty Configuration in DelegatingCluster#8nchandrappa merged 1 commit intoyugabyte:3.8.0-yb-xfrom ebyhr:delegating-cluster-npe
nchandrappa merged 1 commit intoyugabyte:3.8.0-yb-xfrom
ebyhr:delegating-cluster-npe
Conversation
3 tasks
Author
Author
|
Seems reasonable to me. @nchandrappa |
|
Hello @ebyhr, Thanks for submitting the PR. You have mentioned the code fix is to prevent an NPE, is it possible to define a test case scenario when NPE can occur. Also, Thanks, |
Author
|
Here is the test case that fails before this change and succeeds after that. import static org.testng.Assert.assertNotNull;
import org.testng.annotations.Test;
public class DelegateClusterTest {
@Test(groups = "short")
public void should_not_throw_null_pointer_exception() {
Cluster cluster = Cluster.builder().addContactPoints("localhost").build();
SimpleDelegatingCluster delegatingCluster = new SimpleDelegatingCluster(cluster);
assertNotNull(delegatingCluster);
}
private static class SimpleDelegatingCluster extends DelegatingCluster {
private final Cluster cluster;
SimpleDelegatingCluster(Cluster cluster) {
this.cluster = cluster;
}
@Override
protected Cluster delegate() {
return cluster;
}
}
} |
|
Thanks for providing the testcase @ebyhr. Code fix looks good. |
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.
Otherwise, it causes NPE at https://github.com/yugabyte/cassandra-java-driver/blob/3.8.0-yb-x/driver-core/src/main/java/com/datastax/driver/core/Cluster.java#L1620