Java Code Examples for software.amazon.awssdk.utils.IoUtils#drainInputStream()
The following examples show how to use
software.amazon.awssdk.utils.IoUtils#drainInputStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonResponseHandler.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * @see HttpResponseHandler#handle(SdkHttpFullResponse, ExecutionAttributes) */ public T handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) throws Exception { SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response JSON."); SdkStandardLogger.REQUEST_ID_LOGGER.debug(() -> X_AMZN_REQUEST_ID_HEADER + " : " + response.firstMatchingHeader(X_AMZN_REQUEST_ID_HEADER) .orElse("not available")); SdkStandardLogger.REQUEST_ID_LOGGER.debug(() -> X_AMZ_ID_2_HEADER + " : " + response.firstMatchingHeader(X_AMZ_ID_2_HEADER) .orElse("not available")); try { T result = unmarshaller.unmarshall(pojoSupplier.apply(response), response); // Make sure we read all the data to get an accurate CRC32 calculation. // See https://github.com/aws/aws-sdk-java/issues/1018 if (shouldParsePayloadAsJson() && response.content().isPresent()) { IoUtils.drainInputStream(response.content().get()); } SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response."); return result; } finally { if (!needsConnectionLeftOpen) { response.content().ifPresent(i -> FunctionalUtils.invokeSafely(i::close)); } } }
Example 2
Source File: UploadLargeObjectIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
private void verifyResponse(String key) { ResponseInputStream<GetObjectResponse> responseInputStream = s3.getObject(b -> b.bucket(BUCKET).key(key)); IoUtils.drainInputStream(responseInputStream); }