Interface S3BorrowedBufferDelivery


public interface S3BorrowedBufferDelivery
Opts a response handler into zero-copy delivery, where each body chunk arrives as a view into the client's direct buffer pool rather than being copied into a heap byte[]. Implement it alongside S3MetaRequestResponseHandler:

 class MyHandler implements S3MetaRequestResponseHandler, S3BorrowedBufferDelivery {
     public int onResponseBodyBorrowed(S3BorrowedBuffer buffer,
                                       long objectRangeStart, long objectRangeEnd) {
         try (S3BorrowedBuffer b = buffer) {   // MUST be closed on every path
             // read b.asByteBuffer() here
         }
         return (int) (objectRangeEnd - objectRangeStart);
     }
 }
 

A direct buffer pool on the client and this interface on the handler are both required. With only one of the two, chunks keep arriving via S3MetaRequestResponseHandler.onResponseBody(java.nio.ByteBuffer, long, long). Because the opt-in is an interface, a wrong method name or signature fails the build rather than quietly reverting to heap delivery.

See Also: