Usage of an API that is not recommended High

APIs that are not recommended were found. This could indicate a deeper problem in the code.

Detector ID
java/not-recommended-apis@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-

Noncompliant example

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}

Compliant example

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}