The following assertion is incorrect, the behavior of Assert.state is to throw an exception when the expression is false

private void validateConfiguration() {
    if (hasCustomAddress() || hasCustomCredentials() || hasReplicaSet()) {
        Assert.state(this.properties.getUri() == null,
           "Invalid mongo configuration, either uri or host/port/credentials/replicaSet must be specified");
    }
}

The code above throws an exception when the configuration includes a valid mongo-URI

TLDR; Assert.state() // tests for the expression to be false. when Assert.state(getURI() == null) is false then Assert.state throws an Exception. Also if the configuration hasCustomAddress() then the test for URI should not be considered as a validator option.

Comment From: pivotal-issuemaster

@devzer01 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-issuemaster

@devzer01 Thank you for signing the Contributor License Agreement!

Comment From: wilkinsona

Thanks for the PR but I believe that the current behaviour is correct. The intent of the assertion is to enforce that either a URI is configured or the host/port/credentials/replicaSet are configured. In other words you should configure everything using the URI or everything using the individual properties rather than mixing the two. Thanks anyway.

Comment From: devzer01

yep, I realized the same later on :-) maybe my English isn't that good to understand the error message being produced.