Skip to content

Commit 5a94048

Browse files
authored
Fix most of the build warnings (#1476)
The following commit introduced many warnings 01aff5a Many of them were then fixed in cd297a1 This commit fixes most of the ones that are still present
1 parent eeeb88f commit 5a94048

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

driver-core/src/test/unit/com/mongodb/internal/connection/ProtocolHelperSpecification.groovy

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import org.bson.BsonNull
3333
import org.bson.BsonString
3434
import spock.lang.Specification
3535

36-
import static com.mongodb.ClusterFixture.*
36+
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS
37+
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT
3738
import static com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException
3839
import static com.mongodb.internal.connection.ProtocolHelper.getQueryFailureException
3940
import static com.mongodb.internal.connection.ProtocolHelper.isCommandOk
@@ -73,22 +74,19 @@ class ProtocolHelperSpecification extends Specification {
7374
def 'command failure exception should be MongoExecutionTimeoutException if error code is 50'() {
7475
expect:
7576
getCommandFailureException(new BsonDocument('ok', new BsonInt32(0)).append('code', new BsonInt32(50)),
76-
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
77-
instanceof MongoExecutionTimeoutException
77+
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoExecutionTimeoutException
7878
}
7979

8080
def 'command failure exception should be MongoOperationTimeoutException if error code is 50 and timeoutMS is set'() {
8181
expect:
8282
getCommandFailureException(new BsonDocument('ok', new BsonInt32(0)).append('code', new BsonInt32(50)),
83-
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT))
84-
instanceof MongoOperationTimeoutException
83+
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT)) instanceof MongoOperationTimeoutException
8584
}
8685

8786
def 'query failure exception should be MongoExecutionTimeoutException if error code is 50'() {
8887
expect:
8988
getQueryFailureException(new BsonDocument('code', new BsonInt32(50)),
90-
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
91-
instanceof MongoExecutionTimeoutException
89+
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoExecutionTimeoutException
9290
}
9391

9492
def 'query failure exception should be MongoOperationTimeoutException if error code is 50'() {
@@ -97,13 +95,12 @@ class ProtocolHelperSpecification extends Specification {
9795
new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS_WITH_INFINITE_TIMEOUT))
9896
exception instanceof MongoOperationTimeoutException
9997
exception.getCause() instanceof MongoExecutionTimeoutException
100-
10198
}
10299

103100
def 'command failure exceptions should handle MongoNotPrimaryException scenarios'() {
104101
expect:
105-
getCommandFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
106-
instanceof MongoNotPrimaryException
102+
getCommandFailureException(
103+
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNotPrimaryException
107104

108105
where:
109106
exception << [
@@ -115,8 +112,8 @@ class ProtocolHelperSpecification extends Specification {
115112

116113
def 'query failure exceptions should handle MongoNotPrimaryException scenarios'() {
117114
expect:
118-
getQueryFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
119-
instanceof MongoNotPrimaryException
115+
getQueryFailureException(
116+
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNotPrimaryException
120117

121118
where:
122119
exception << [
@@ -128,8 +125,8 @@ class ProtocolHelperSpecification extends Specification {
128125

129126
def 'command failure exceptions should handle MongoNodeIsRecoveringException scenarios'() {
130127
expect:
131-
getCommandFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
132-
instanceof MongoNodeIsRecoveringException
128+
getCommandFailureException(
129+
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNodeIsRecoveringException
133130

134131
where:
135132
exception << [
@@ -144,8 +141,8 @@ class ProtocolHelperSpecification extends Specification {
144141

145142
def 'query failure exceptions should handle MongoNodeIsRecoveringException scenarios'() {
146143
expect:
147-
getQueryFailureException(exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS))
148-
instanceof MongoNodeIsRecoveringException
144+
getQueryFailureException(
145+
exception, new ServerAddress(), new TimeoutContext(TIMEOUT_SETTINGS)) instanceof MongoNodeIsRecoveringException
149146

150147
where:
151148
exception << [

driver-core/src/test/unit/com/mongodb/internal/operation/OperationUnitSpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class OperationUnitSpecification extends Specification {
6868
[9, 0]: 25,
6969
]
7070

71-
static int getMaxWireVersionForServerVersion(List<Integer> serverVersion) {
71+
static Integer getMaxWireVersionForServerVersion(List<Integer> serverVersion) {
7272
def maxWireVersion = SERVER_TO_WIRE_VERSION_MAP[serverVersion.subList(0, 2)]
7373

7474
if (maxWireVersion == null) {

driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideEncryptionAwsCredentialFromEnvironmentTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ void shouldThrowMongoCryptExceptionWhenNamedKMSProviderUsesEmptyOnDemandCredenti
230230
.build();
231231

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

269268
MongoCryptException e = assertThrows(MongoCryptException.class, () -> {
270-
try (MongoClient ignore = createMongoClient(getMongoClientSettingsBuilder()
269+
createMongoClient(getMongoClientSettingsBuilder()
271270
.autoEncryptionSettings(autoEncryptionSettings)
272-
.build())) {//NOP
273-
}
271+
.build()).close();
274272
});
275273
assertTrue(e.getMessage().contains("On-demand credentials are not supported for named KMS providers."));
276274
}

0 commit comments

Comments
 (0)