3333import software .amazon .awssdk .annotations .SdkPublicApi ;
3434import software .amazon .awssdk .core .FileRequestBodyConfiguration ;
3535import software .amazon .awssdk .core .internal .async .ByteBuffersAsyncRequestBody ;
36- import software .amazon .awssdk .core .internal .async .ClosableAsyncRequestBodyAdaptor ;
3736import software .amazon .awssdk .core .internal .async .FileAsyncRequestBody ;
3837import software .amazon .awssdk .core .internal .async .InputStreamWithExecutorAsyncRequestBody ;
3938import software .amazon .awssdk .core .internal .async .SplittingPublisher ;
@@ -501,22 +500,23 @@ static AsyncRequestBody empty() {
501500 return fromBytes (new byte [0 ]);
502501 }
503502
504-
505503 /**
506504 * Converts this {@link AsyncRequestBody} to a publisher of {@link AsyncRequestBody}s, each of which publishes a specific
507505 * portion of the original data, based on the provided {@link AsyncRequestBodySplitConfiguration}. The default chunk size
508506 * is 2MB and the default buffer size is 8MB.
509507 *
510508 * <p>
511- * Each divided {@link AsyncRequestBody} is sent after the entire content for that chunk is buffered.
509+ * By default, if content length of this {@link AsyncRequestBody} is present, each divided {@link AsyncRequestBody} is
510+ * delivered to the subscriber right after it's initialized. On the other hand, if content length is null, it is sent after
511+ * the entire content for that chunk is buffered. In this case, the configured {@code maxMemoryUsageInBytes} must be larger
512+ * than or equal to {@code chunkSizeInBytes}. Note that this behavior may be different if a specific implementation of this
513+ * interface overrides this method.
512514 *
513515 * @see AsyncRequestBodySplitConfiguration
514- * @deprecated Use {@link #splitV2(AsyncRequestBodySplitConfiguration)} instead.
515516 */
516- @ Deprecated
517517 default SdkPublisher <AsyncRequestBody > split (AsyncRequestBodySplitConfiguration splitConfiguration ) {
518518 Validate .notNull (splitConfiguration , "splitConfiguration" );
519- return splitV2 ( splitConfiguration ).map (body -> new ClosableAsyncRequestBodyAdaptor ( body ) );
519+ return new SplittingPublisher ( this , splitConfiguration , false ).map (r -> r );
520520 }
521521
522522 /**
@@ -525,27 +525,26 @@ default SdkPublisher<AsyncRequestBody> split(AsyncRequestBodySplitConfiguration
525525 * size is 2MB and the default buffer size is 8MB.
526526 *
527527 * <p>
528- * Each divided {@link ClosableAsyncRequestBody} is sent after the entire content for that chunk is buffered . This behavior
529- * may be different if a specific implementation of this interface overrides this method .
528+ * The default implementation behaves the same as {@link #split(AsyncRequestBodySplitConfiguration)} . This behavior may
529+ * vary in different implementations .
530530 *
531531 * <p>
532- * Each {@link ClosableAsyncRequestBody} MUST be closed by the user when it is ready to be disposed.
532+ * Caller is responsible for closing {@link ClosableAsyncRequestBody} when it is ready to be disposed to release any
533+ * resources.
533534 *
534535 * @see AsyncRequestBodySplitConfiguration
535536 */
536- default SdkPublisher <ClosableAsyncRequestBody > splitV2 (AsyncRequestBodySplitConfiguration splitConfiguration ) {
537+ default SdkPublisher <ClosableAsyncRequestBody > splitClosable (AsyncRequestBodySplitConfiguration splitConfiguration ) {
537538 Validate .notNull (splitConfiguration , "splitConfiguration" );
538- return new SplittingPublisher (this , splitConfiguration );
539+ return new SplittingPublisher (this , splitConfiguration , false );
539540 }
540541
541542 /**
542543 * This is a convenience method that passes an instance of the {@link AsyncRequestBodySplitConfiguration} builder,
543544 * avoiding the need to create one manually via {@link AsyncRequestBodySplitConfiguration#builder()}.
544545 *
545546 * @see #split(AsyncRequestBodySplitConfiguration)
546- * @deprecated Use {@link #splitV2(Consumer)} instead.
547547 */
548- @ Deprecated
549548 default SdkPublisher <AsyncRequestBody > split (Consumer <AsyncRequestBodySplitConfiguration .Builder > splitConfiguration ) {
550549 Validate .notNull (splitConfiguration , "splitConfiguration" );
551550 return split (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
@@ -555,12 +554,12 @@ default SdkPublisher<AsyncRequestBody> split(Consumer<AsyncRequestBodySplitConfi
555554 * This is a convenience method that passes an instance of the {@link AsyncRequestBodySplitConfiguration} builder,
556555 * avoiding the need to create one manually via {@link AsyncRequestBodySplitConfiguration#builder()}.
557556 *
558- * @see #splitV2 (Consumer)
557+ * @see #splitClosable (Consumer)
559558 */
560- default SdkPublisher <ClosableAsyncRequestBody > splitV2 (
559+ default SdkPublisher <ClosableAsyncRequestBody > splitClosable (
561560 Consumer <AsyncRequestBodySplitConfiguration .Builder > splitConfiguration ) {
562561 Validate .notNull (splitConfiguration , "splitConfiguration" );
563- return splitV2 (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
562+ return splitClosable (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
564563 }
565564
566565 @ SdkProtectedApi
0 commit comments