oracle / oracle/oci-java-sdk

Truncated response data for operations that return binary data in versions 2.0.0 to 2.13.0 (Fixed in 2.13.1 and later)

Open
#357 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

SDK
Dominant language
Java
Stars
243
Forks
171
Avg merge
30m
Merged PRs (30d)
4

Description

If you're using the OCI Java SDK for calling any of the below listed API operations that return a stream of data but don't return the content-length header in the response, then you are most-likely affected by truncated data issue, caused due the SDK prematurely auto closing the stream before reading all the data.

Affected operations

This happens for both synchronous and asynchronous clients for the following operations :
getJobTfConfig
getJobTfState
getStackTfConfig
getStackTfState
getTemplateLogo
getTemplateTfConfig
exportQueryResult
synchronousExportDataAsset
And possibly for the following API operations :
getJobOutputContent
getCpeDeviceConfigContent
getIpsecCpeDeviceConfigContent
getTunnelCpeDeviceConfigContent
downloadPdfContent

Affected versions

This issue only occurs in OCI SDK versions >= 2.0.0 and <= 2.13.0. The fix has been released in version 2.13.1 and later versions.

Detailed Explanation

This issue occurs due to this bug in the Jersey library's ApacheConnector which results in -1 content-length when the service does not respond back with a content-length header. This causes the wrapped response stream to close before the entire data has been read from the stream.

Workaround

If you're using any of the versions between 2.0.0 and 2.13.0, you can avoid hitting the above issue by switching back to the Jersey default HttpUrlConnector for the OCI SDK by following any of the methods mentioned here.

Since the fix has been released in the versions 2.13.1 and later, you can alternatively choose to upgrade to the fixed versions. However, for the above API operations, make sure to explicitly close the response stream for purposes mentioned here

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the affected client methods listed in the issue and read bmc-common/src/main/java/com/oracle/bmc/io/internal/AutoCloseableContentLengthVerifyingInputStream.java, then review ApacheConnector-README.md. Compare versions 2.13.0 and 2.13.1 for responses without a content-length header; done means binary data is no longer truncated and response streams are explicitly closed as documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.