Skip to content

Commit 9695d69

Browse files
authored
Add Warnings in the async client interface and CrtClient against passing Runnable::run (#5016)
* Add Warnings in the async client interface and CrtClient against passing in Runnable::run * Update warning message * Updated warning message * Added paragraph notation * Add a paragraph notation
1 parent de060da commit 9695d69

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientInterface.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ public ClassName className() {
169169

170170
private String getJavadoc() {
171171
return "Service client for accessing " + model.getMetadata().getDescriptiveServiceName() + " asynchronously. This can be "
172-
+ "created using the static {@link #builder()} method.\n\n" + model.getMetadata().getDocumentation();
172+
+ "created using the static {@link #builder()} method."
173+
+ "The asynchronous client performs non-blocking I/O when configured "
174+
+ "with any {@link SdkAsyncHttpClient} supported in the SDK. "
175+
+ "However, full non-blocking is not guaranteed as the async client may perform "
176+
+ "blocking calls in some cases such as credentials retrieval and "
177+
+ "endpoint discovery as part of the async API call."
178+
+ "\n\n" + model.getMetadata().getDocumentation();
173179
}
174180

175181
private MethodSpec create() {

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-interface.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353

5454
/**
5555
* Service client for accessing Json Service asynchronously. This can be created using the static {@link #builder()}
56-
* method.
56+
* method.The asynchronous client performs non-blocking I/O when configured with any {@link SdkAsyncHttpClient}
57+
* supported in the SDK. However, full non-blocking is not guaranteed as the async client may perform blocking calls in
58+
* some cases such as credentials retrieval and endpoint discovery as part of the async API call.
5759
*
5860
* A service that is implemented using the query protocol
5961
*/

services/s3/src/main/java/software/amazon/awssdk/services/s3/S3CrtAsyncClientBuilder.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,12 @@ default S3CrtAsyncClientBuilder retryConfiguration(Consumer<S3CrtRetryConfigurat
322322
* <li>You want more fine-grained control over the {@link ThreadPoolExecutor} used, such as configuring the pool size
323323
* or sharing a single pool between multiple clients.
324324
* <li>You want to add instrumentation (i.e., metrics) around how the {@link Executor} is used.
325-
* <li>You know, for certain, that all of your {@link CompletableFuture} usage is strictly non-blocking, and you wish to
326-
* remove the minor overhead incurred by using a separate thread. In this case, you can use
327-
* {@code Runnable::run} to execute the future-completion directly from within the I/O thread.
328325
* </ol>
326+
* <p>
327+
* <b>WARNING</b>
328+
* We strongly <strong>discourage</strong> using {@code Runnable::run}, which executes the future-completion directly from
329+
* within the I/O thread because it may block the I/O thread and cause deadlock, especially if you are sending
330+
* another SDK request in the {@link CompletableFuture} chain since the SDK may perform blocking calls in some cases.
329331
*
330332
* @param futureCompletionExecutor the executor
331333
* @return an instance of this builder.

0 commit comments

Comments
 (0)