Source:
public void uploadPart(DataChannel channel, Part part, String objectId, String uploadId) throws IOException { retry.execute(new RetryCallback<Void, IOException>() { @Override public Void doWithRetry(RetryContext ctx) throws IOException { log.debug("Upload Part URL: {}", part.getUrl()); final RequestCallback callback = new RequestCallback() { @Override public void doWithRequest(final ClientHttpRequest request) throws IOException { HttpHeaders requestHeader = request.getHeaders(); requestHeader.setContentLength(channel.getLength()); try (OutputStream os = request.getBody()) { channel.writeTo(os); } } }; final ResponseExtractor<HttpHeaders> headersExtractor = new ResponseExtractor<HttpHeaders>() { @Override public HttpHeaders extractData(ClientHttpResponse response) throws IOException { return response.getHeaders(); } }; try { HttpHeaders headers = dataTemplate.execute(new URI(part.getUrl()), HttpMethod.PUT, callback, headersExtractor); try { finalizeUploadPart(objectId, uploadId, part.getPartNumber(), channel.getMd5(), cleanUpETag(headers.getETag()), disableChecksum(headers)); } catch (NotRetryableException e) { log.warn("Checksum failed for part: {}, MD5: {}, ETAG: {}", part, channel.getMd5(), headers.getETag(), e); throw new RetryableException(e); } } catch (NotResumableException | NotRetryableException e) { log.error("Could not proceed. Failed to send part for part number: {}", part.getPartNumber(), e); throw e; } catch (Throwable e) { log.warn("Failed to send part for part number: {}", part.getPartNumber(), e); channel.reset(); throw new RetryableException(e); } return null; } private boolean disableChecksum(HttpHeaders headers) { List<String> encryption = headers.get(Headers.SERVER_SIDE_ENCRYPTION); if (encryption != null && !encryption.isEmpty()) { return encryption.contains(SSEAlgorithm.KMS.getAlgorithm()); } return false; } }); }

Target:
public void uploadPart(DataChannel channel, Part part, String objectId, String uploadId) throws IOException { retry.execute(new RetryCallback<Void, IOException>() { @Override public Void doWithRetry(RetryContext ctx) throws IOException { log.debug("Upload Part URL: {}", part.getUrl()); final RequestCallback callback = new RequestCallback() { @Override public void doWithRequest(final ClientHttpRequest request) throws IOException { HttpHeaders requestHeader = request.getHeaders(); requestHeader.setContentLength(channel.getLength()); try (OutputStream os = request.getBody()) { channel.writeTo(os); } } }; final ResponseExtractor<HttpHeaders> headersExtractor = new ResponseExtractor<HttpHeaders>() { @Override public HttpHeaders extractData(ClientHttpResponse response) throws IOException { return response.getHeaders(); } }; try { HttpHeaders headers = dataTemplate.execute(new URI(part.getUrl()), HttpMethod.PUT, callback, headersExtractor); try { finalizeUploadPart(objectId, uploadId, part.getPartNumber(), channel.getMd5(), cleanUpETag(headers.getETag()), disableChecksum(headers)); } catch (NotRetryableException e) { log.warn("Checksum failed for part #{}, MD5={}, ETAG={} : {}", part, channel.getMd5(), headers.getETag(), e); throw new RetryableException(e); } } catch (NotResumableException | NotRetryableException e) { log.error("Could not proceed. Failed to send part for part number: {}", part.getPartNumber(), e); throw e; } catch (Throwable e) { log.warn("Failed to send part for part #{} : {}", part.getPartNumber(), e); channel.reset(); throw new RetryableException(e); } return null; } private boolean disableChecksum(HttpHeaders headers) { List<String> encryption = headers.get(Headers.SERVER_SIDE_ENCRYPTION); if (encryption != null && !encryption.isEmpty()) { return encryption.contains(SSEAlgorithm.KMS.getAlgorithm()); } return false; } }); }