Skip to content

Commit a0bf49b

Browse files
author
Anirav Kareddy
committed
moved the validation check for instruction file put operations to the top
1 parent b50ee55 commit a0bf49b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,16 @@ public static Consumer<AwsRequestOverrideConfiguration.Builder> withAdditionalCo
216216
* @throws S3EncryptionClientException if the new keyring has the same materials description as the current one
217217
*/
218218
public ReEncryptInstructionFileResponse reEncryptInstructionFile(ReEncryptInstructionFileRequest reEncryptInstructionFileRequest) {
219+
if (!_instructionFileConfig.isInstructionFilePutEnabled()) {
220+
throw new S3EncryptionClientException("Instruction file put operations must be enabled to re-encrypt instruction files");
221+
}
222+
219223
//Build request to retrieve the encrypted object and its associated instruction file
220224
final GetObjectRequest request = GetObjectRequest.builder()
221225
.bucket(reEncryptInstructionFileRequest.bucket())
222226
.key(reEncryptInstructionFileRequest.key())
223227
.build();
224228

225-
if (!_instructionFileConfig.isInstructionFilePutEnabled()) {
226-
throw new S3EncryptionClientException("Instruction file put operations must be enabled to re-encrypt instruction files");
227-
}
228-
229229
ResponseInputStream<GetObjectResponse> response = this.getObject(request);
230230
ContentMetadataDecodingStrategy decodingStrategy = new ContentMetadataDecodingStrategy(_instructionFileConfig);
231231
ContentMetadata contentMetadata = decodingStrategy.decode(request, response.response());

0 commit comments

Comments
 (0)