33
33
import software .amazon .awssdk .annotations .SdkPublicApi ;
34
34
import software .amazon .awssdk .core .FileRequestBodyConfiguration ;
35
35
import software .amazon .awssdk .core .internal .async .ByteBuffersAsyncRequestBody ;
36
- import software .amazon .awssdk .core .internal .async .ClosableAsyncRequestBodyAdaptor ;
37
36
import software .amazon .awssdk .core .internal .async .FileAsyncRequestBody ;
38
37
import software .amazon .awssdk .core .internal .async .InputStreamWithExecutorAsyncRequestBody ;
39
38
import software .amazon .awssdk .core .internal .async .SplittingPublisher ;
@@ -501,22 +500,23 @@ static AsyncRequestBody empty() {
501
500
return fromBytes (new byte [0 ]);
502
501
}
503
502
504
-
505
503
/**
506
504
* Converts this {@link AsyncRequestBody} to a publisher of {@link AsyncRequestBody}s, each of which publishes a specific
507
505
* portion of the original data, based on the provided {@link AsyncRequestBodySplitConfiguration}. The default chunk size
508
506
* is 2MB and the default buffer size is 8MB.
509
507
*
510
508
* <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.
512
514
*
513
515
* @see AsyncRequestBodySplitConfiguration
514
- * @deprecated Use {@link #splitV2(AsyncRequestBodySplitConfiguration)} instead.
515
516
*/
516
- @ Deprecated
517
517
default SdkPublisher <AsyncRequestBody > split (AsyncRequestBodySplitConfiguration splitConfiguration ) {
518
518
Validate .notNull (splitConfiguration , "splitConfiguration" );
519
- return splitV2 ( splitConfiguration ).map (body -> new ClosableAsyncRequestBodyAdaptor ( body ) );
519
+ return new SplittingPublisher ( this , splitConfiguration , false ).map (r -> r );
520
520
}
521
521
522
522
/**
@@ -525,27 +525,26 @@ default SdkPublisher<AsyncRequestBody> split(AsyncRequestBodySplitConfiguration
525
525
* size is 2MB and the default buffer size is 8MB.
526
526
*
527
527
* <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 .
530
530
*
531
531
* <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.
533
534
*
534
535
* @see AsyncRequestBodySplitConfiguration
535
536
*/
536
- default SdkPublisher <ClosableAsyncRequestBody > splitV2 (AsyncRequestBodySplitConfiguration splitConfiguration ) {
537
+ default SdkPublisher <ClosableAsyncRequestBody > splitClosable (AsyncRequestBodySplitConfiguration splitConfiguration ) {
537
538
Validate .notNull (splitConfiguration , "splitConfiguration" );
538
- return new SplittingPublisher (this , splitConfiguration );
539
+ return new SplittingPublisher (this , splitConfiguration , false );
539
540
}
540
541
541
542
/**
542
543
* This is a convenience method that passes an instance of the {@link AsyncRequestBodySplitConfiguration} builder,
543
544
* avoiding the need to create one manually via {@link AsyncRequestBodySplitConfiguration#builder()}.
544
545
*
545
546
* @see #split(AsyncRequestBodySplitConfiguration)
546
- * @deprecated Use {@link #splitV2(Consumer)} instead.
547
547
*/
548
- @ Deprecated
549
548
default SdkPublisher <AsyncRequestBody > split (Consumer <AsyncRequestBodySplitConfiguration .Builder > splitConfiguration ) {
550
549
Validate .notNull (splitConfiguration , "splitConfiguration" );
551
550
return split (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
@@ -555,12 +554,12 @@ default SdkPublisher<AsyncRequestBody> split(Consumer<AsyncRequestBodySplitConfi
555
554
* This is a convenience method that passes an instance of the {@link AsyncRequestBodySplitConfiguration} builder,
556
555
* avoiding the need to create one manually via {@link AsyncRequestBodySplitConfiguration#builder()}.
557
556
*
558
- * @see #splitV2 (Consumer)
557
+ * @see #splitClosable (Consumer)
559
558
*/
560
- default SdkPublisher <ClosableAsyncRequestBody > splitV2 (
559
+ default SdkPublisher <ClosableAsyncRequestBody > splitClosable (
561
560
Consumer <AsyncRequestBodySplitConfiguration .Builder > splitConfiguration ) {
562
561
Validate .notNull (splitConfiguration , "splitConfiguration" );
563
- return splitV2 (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
562
+ return splitClosable (AsyncRequestBodySplitConfiguration .builder ().applyMutation (splitConfiguration ).build ());
564
563
}
565
564
566
565
@ SdkProtectedApi
0 commit comments