AWS code-library documentation change
Summary
Removed a Java code example demonstrating AWS Batch job listing functionality including custom HTTP client configuration
Security assessment
The change removes a general code example showing how to configure HTTP timeouts and retries. While timeout configurations can indirectly improve resilience, there's no evidence this removal addresses a specific security vulnerability or weakness. The removed content was routine SDK usage documentation without security-specific context.
Diff
diff --git a/code-library/latest/ug/batch_code_examples.md b/code-library/latest/ug/batch_code_examples.md index c54f1c813..6080bb92b 100644 --- a//code-library/latest/ug/batch_code_examples.md +++ b//code-library/latest/ug/batch_code_examples.md @@ -30,95 +29,0 @@ _Scenarios_ are code examples that show you how to accomplish specific tasks by -**Get started** - -The following code example shows how to get started using AWS Batch. - -Java - - -**SDK for Java 2.x** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/batch#code-examples). - - - import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; - import software.amazon.awssdk.core.retry.RetryPolicy; - import software.amazon.awssdk.http.async.SdkAsyncHttpClient; - import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; - import software.amazon.awssdk.regions.Region; - import software.amazon.awssdk.services.batch.BatchAsyncClient; - import software.amazon.awssdk.services.batch.model.JobStatus; - import software.amazon.awssdk.services.batch.model.JobSummary; - import software.amazon.awssdk.services.batch.model.ListJobsRequest; - import software.amazon.awssdk.services.batch.paginators.ListJobsPublisher; - import java.time.Duration; - import java.util.ArrayList; - import java.util.List; - import java.util.concurrent.CompletableFuture; - - public class HelloBatch { - private static BatchAsyncClient batchClient; - - public static void main(String[] args) { - List<JobSummary> jobs = listJobs("my-job-queue"); - jobs.forEach(job -> - System.out.printf("Job ID: %s, Job Name: %s, Job Status: %s%n", - job.jobId(), job.jobName(), job.status()) - ); - } - - public static List<JobSummary> listJobs(String jobQueue) { - if (jobQueue == null || jobQueue.isEmpty()) { - throw new IllegalArgumentException("Job queue cannot be null or empty"); - } - - ListJobsRequest listJobsRequest = ListJobsRequest.builder() - .jobQueue(jobQueue) - .jobStatus(JobStatus.SUCCEEDED) - .build(); - - List<JobSummary> jobSummaries = new ArrayList<>(); - ListJobsPublisher listJobsPaginator = getAsyncClient().listJobsPaginator(listJobsRequest); - CompletableFuture<Void> future = listJobsPaginator.subscribe(response -> { - jobSummaries.addAll(response.jobSummaryList()); - }); - - future.join(); - return jobSummaries; - } - - private static BatchAsyncClient getAsyncClient() { - SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder() - .maxConcurrency(100) // Increase max concurrency to handle more simultaneous connections. - .connectionTimeout(Duration.ofSeconds(60)) // Set the connection timeout. - .readTimeout(Duration.ofSeconds(60)) // Set the read timeout. - .writeTimeout(Duration.ofSeconds(60)) // Set the write timeout. - .build(); - - ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder() - .apiCallTimeout(Duration.ofMinutes(2)) // Set the overall API call timeout. - .apiCallAttemptTimeout(Duration.ofSeconds(90)) // Set the individual call attempt timeout. - .retryPolicy(RetryPolicy.builder() // Add a retry policy to handle transient errors. - .numRetries(3) // Number of retry attempts. - .build()) - .build(); - - if (batchClient == null) { - batchClient = BatchAsyncClient.builder() - .region(Region.US_EAST_1) - .httpClient(httpClient) - .overrideConfiguration(overrideConfig) - .build(); - } - return batchClient; - } - } - - - - * For API details, see [listJobsPaginator](https://docs.aws.amazon.com/goto/SdkForJavaV2/batch-2016-08-10/listJobsPaginator) in _AWS SDK for Java 2.x API Reference_. - - - -