Skip to content

Commit dd1eceb

Browse files
committed
Codereview feedback
1 parent 9b86913 commit dd1eceb

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/KeyManagementService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ private void streamWrite(final Stream stream, final MongoKeyDecryptor keyDecrypt
145145
@Override
146146
public void completed(@Nullable final Void aVoid) {
147147
try {
148-
int readSize = Math.max(keyDecryptor.bytesNeeded(), MongoKeyDecryptor.DEFAULT_KMS_READ_SIZE);
148+
int bytesNeeded = keyDecryptor.bytesNeeded();
149+
int readSize = bytesNeeded > 0 ? bytesNeeded : MongoKeyDecryptor.DEFAULT_KMS_READ_SIZE;
149150
streamRead(stream, keyDecryptor, operationContext, sink, readSize);
150151
} catch (Throwable t) {
151152
stream.close();

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionKmsRetryTest.java renamed to driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideEncryptionKmsRetryProseTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
package com.mongodb.reactivestreams.client;
1818

1919
import com.mongodb.ClientEncryptionSettings;
20-
import com.mongodb.client.AbstractClientSideEncryptionKmsRetryTest;
20+
import com.mongodb.client.AbstractClientSideEncryptionKmsRetryProseTest;
2121
import com.mongodb.client.vault.ClientEncryption;
2222
import com.mongodb.reactivestreams.client.syncadapter.SyncClientEncryption;
2323
import com.mongodb.reactivestreams.client.vault.ClientEncryptions;
2424

25-
public class ClientSideEncryptionKmsRetryTest extends AbstractClientSideEncryptionKmsRetryTest {
25+
public class ClientSideEncryptionKmsRetryProseTest extends AbstractClientSideEncryptionKmsRetryProseTest {
2626
@Override
2727
public ClientEncryption getClientEncryption(final ClientEncryptionSettings settings) {
2828
return new SyncClientEncryption(ClientEncryptions.create(settings));

driver-sync/src/main/com/mongodb/client/internal/Crypt.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ private boolean attemptDecryptKey(final MongoKeyDecryptor keyDecryptor, @Nullabl
416416
keyDecryptor.getMessage(), operationTimeout);
417417
Throwable primary = null;
418418
try {
419-
int readSize = Math.max(keyDecryptor.bytesNeeded(), MongoKeyDecryptor.DEFAULT_KMS_READ_SIZE);
419+
int bytesNeeded = keyDecryptor.bytesNeeded();
420+
int readSize = bytesNeeded > 0 ? bytesNeeded : MongoKeyDecryptor.DEFAULT_KMS_READ_SIZE;
420421
do {
421422
byte[] bytes = new byte[readSize];
422423
int bytesRead = inputStream.read(bytes, 0, bytes.length);

driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideEncryptionKmsRetryTest.java renamed to driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideEncryptionKmsRetryProseTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.bson.BsonDocument;
2929
import org.bson.BsonInt32;
3030
import org.bson.BsonString;
31+
import org.junit.jupiter.api.BeforeEach;
3132
import org.junit.jupiter.api.Test;
32-
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
3333
import org.junit.jupiter.params.ParameterizedTest;
3434
import org.junit.jupiter.params.provider.ValueSource;
3535

@@ -64,15 +64,20 @@
6464
* failpoint server; the whole class is disabled when it is not set (e.g. local runs without the Evergreen
6565
* CSFLE failpoint harness).
6666
*/
67-
@EnabledIfSystemProperty(named = "org.mongodb.test.kms.retry.ca.path", matches = ".+")
68-
public abstract class AbstractClientSideEncryptionKmsRetryTest {
67+
public abstract class AbstractClientSideEncryptionKmsRetryProseTest {
6968

7069
private static final String FAILPOINT_SERVER_ADDRESS = "127.0.0.1:9003";
7170
private static final String FAILPOINT_URL_BASE = "https://" + FAILPOINT_SERVER_ADDRESS;
7271

7372
@NonNull
7473
protected abstract ClientEncryption getClientEncryption(ClientEncryptionSettings settings);
7574

75+
@BeforeEach
76+
public void setUp() {
77+
assumeTrue(System.getProperty("org.mongodb.test.kms.retry.ca.path") != null,
78+
"org.mongodb.test.kms.retry.ca.path system property is not set");
79+
}
80+
7681
/**
7782
* Case 1: createDataKey and encrypt with TCP retry.
7883
*/

driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionKmsRetryTest.java renamed to driver-sync/src/test/functional/com/mongodb/client/ClientSideEncryptionKmsRetryProseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.mongodb.client.vault.ClientEncryption;
2121
import com.mongodb.client.vault.ClientEncryptions;
2222

23-
public class ClientSideEncryptionKmsRetryTest extends AbstractClientSideEncryptionKmsRetryTest {
23+
public class ClientSideEncryptionKmsRetryProseTest extends AbstractClientSideEncryptionKmsRetryProseTest {
2424
@Override
2525
public ClientEncryption getClientEncryption(final ClientEncryptionSettings settings) {
2626
return ClientEncryptions.create(settings);

0 commit comments

Comments
 (0)