Skip to content

Commit 1acd568

Browse files
committed
Move check to proper place
1 parent 51cb94a commit 1acd568

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/software/amazon/encryption/s3/S3EncryptionClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,7 @@ public Builder rsaKeyPair(PartialRsaKeyPair partialRsaKeyPair) {
666666
* @return Returns a reference to this object so that method calls can be chained together.
667667
*/
668668
public Builder kmsKeyId(String kmsKeyId) {
669-
try {
670-
Class.forName("software.amazon.awssdk.services.kms.KmsClient");
671-
} catch (ClassNotFoundException e) {
672-
throw new RuntimeException("software.amazon.awssdk:kms is required to set up with KMS key", e);
673-
}
669+
this._kmsKeyId = kmsKeyId;
674670
checkKeyOptions();
675671

676672
return this;
@@ -1143,6 +1139,11 @@ public S3EncryptionClient build() {
11431139
.secureRandom(_secureRandom)
11441140
.build();
11451141
} else if (_kmsKeyId != null) {
1142+
try {
1143+
Class.forName("software.amazon.awssdk.services.kms.KmsClient");
1144+
} catch (ClassNotFoundException e) {
1145+
throw new RuntimeException("software.amazon.awssdk:kms is required to set up with KMS key", e);
1146+
}
11461147
KmsClient kmsClient = KmsClient.builder()
11471148
.credentialsProvider(_awsCredentialsProvider)
11481149
.region(_region)

0 commit comments

Comments
 (0)