Skip to content

Fix most of the build warnings #1476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import org.bson.BsonNull
import org.bson.BsonString
import spock.lang.Specification

import static com.mongodb.ClusterFixture.*
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT
import static com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException
import static com.mongodb.internal.connection.ProtocolHelper.getQueryFailureException
import static com.mongodb.internal.connection.ProtocolHelper.isCommandOk
Expand Down Expand Up @@ -73,22 +74,19 @@ class ProtocolHelperSpecification extends Specification {
def 'command failure exception should be MongoExecutionTimeoutException if error code is 50'() {
expect:
getCommandFailureException(new BsonDocument('ok', new BsonInt32(0)).append('code', new BsonInt32(50)),
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoExecutionTimeoutException
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoExecutionTimeoutException
}

def 'command failure exception should be MongoOperationTimeoutException if error code is 50 and timeoutMS is set'() {
expect:
getCommandFailureException(new BsonDocument('ok', new BsonInt32(0)).append('code', new BsonInt32(50)),
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT))
instanceof MongoOperationTimeoutException
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT)) instanceof MongoOperationTimeoutException
}

def 'query failure exception should be MongoExecutionTimeoutException if error code is 50'() {
expect:
getQueryFailureException(new BsonDocument('code', new BsonInt32(50)),
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoExecutionTimeoutException
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoExecutionTimeoutException
}

def 'query failure exception should be MongoOperationTimeoutException if error code is 50'() {
Expand All @@ -97,13 +95,12 @@ class ProtocolHelperSpecification extends Specification {
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT))
exception instanceof MongoOperationTimeoutException
exception.getCause() instanceof MongoExecutionTimeoutException

}

def 'command failure exceptions should handle MongoNotPrimaryException scenarios'() {
expect:
getCommandFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoNotPrimaryException
getCommandFailureException(
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNotPrimaryException

where:
exception << [
Expand All @@ -115,8 +112,8 @@ class ProtocolHelperSpecification extends Specification {

def 'query failure exceptions should handle MongoNotPrimaryException scenarios'() {
expect:
getQueryFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoNotPrimaryException
getQueryFailureException(
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNotPrimaryException

where:
exception << [
Expand All @@ -128,8 +125,8 @@ class ProtocolHelperSpecification extends Specification {

def 'command failure exceptions should handle MongoNodeIsRecoveringException scenarios'() {
expect:
getCommandFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoNodeIsRecoveringException
getCommandFailureException(
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNodeIsRecoveringException

where:
exception << [
Expand All @@ -144,8 +141,8 @@ class ProtocolHelperSpecification extends Specification {

def 'query failure exceptions should handle MongoNodeIsRecoveringException scenarios'() {
expect:
getQueryFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
instanceof MongoNodeIsRecoveringException
getQueryFailureException(
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNodeIsRecoveringException

where:
exception << [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class OperationUnitSpecification extends Specification {
[9, 0]: 25,
]

static int getMaxWireVersionForServerVersion(List<Integer> serverVersion) {
static Integer getMaxWireVersionForServerVersion(List<Integer> serverVersion) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the warning we had for this method, but the change removed that warning. I don't want to spend more time on investigating the weirdness of Groovy.

def maxWireVersion = SERVER_TO_WIRE_VERSION_MAP[serverVersion.subList(0, 2)]

if (maxWireVersion == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ void shouldThrowMongoCryptExceptionWhenNamedKMSProviderUsesEmptyOnDemandCredenti
.build();

MongoCryptException e = assertThrows(MongoCryptException.class, () -> {
try (ClientEncryption ignore = createClientEncryption(settings)) {//NOP
}
createClientEncryption(settings).close();
});
assertTrue(e.getMessage().contains("On-demand credentials are not supported for named KMS providers."));
}
Expand Down Expand Up @@ -267,10 +266,9 @@ public void shouldThrowMongoCryptExceptionWhenNamedKMSProviderUsesEmptyOnDemandC
.build();

MongoCryptException e = assertThrows(MongoCryptException.class, () -> {
try (MongoClient ignore = createMongoClient(getMongoClientSettingsBuilder()
createMongoClient(getMongoClientSettingsBuilder()
.autoEncryptionSettings(autoEncryptionSettings)
.build())) {//NOP
}
.build()).close();
});
assertTrue(e.getMessage().contains("On-demand credentials are not supported for named KMS providers."));
}
Expand Down