APIs that are not recommended were found. This could indicate a deeper problem in the code.
1public void s3MultiPartUploadNoncompliant() {
2 AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
3 .withRegion(Regions.US_EAST_1)
4 .build();
5 // Noncompliant: uses an API that we don't recommend, and a better alternative exists.
6 s3Client.initiateMultipartUpload(new InitiateMultipartUploadRequest(bucketName,key));
7}
1public void shutdownTransferManagerCompliant(final PutObjectRequest putRequest) {
2 TransferManager transferManager = null;
3 try {
4 transferManager = TransferManagerBuilder.defaultTransferManager();
5 final Upload upload = transferManager.upload(putRequest);
6 upload.waitForCompletion();
7 } catch (InterruptedException e) {
8 Thread.currentThread().interrupt();
9 } finally {
10 // Compliant: uses recommended APIs from TransferManager.
11 transferManager.shutdownNow();
12 }
13}