Skip to content

Conversation

@Ndiritu
Copy link
Contributor

@Ndiritu Ndiritu commented Mar 20, 2024

  • Fixes issue with reading chunks to upload from the InputStream to a buffer that would throw IndexOutOfBoundsException
  • Fixes issue with checking for presence of a response body. Uses content-length header instead of okHttp's native Response contentLength() which is unreliable at times or checking if body() or Response is null since it'll always be non-null based on our use of Call.execute()
    This fixes Outlook LFU scenarios by preventing it from trying to parse a null body.
  • Updates tests to simulate reponse objects returned by Call.execute() which will always have non-null body().

closes #1543
closes microsoftgraph/msgraph-sdk-java#1818
closes microsoftgraph/msgraph-sdk-java#1806
closes microsoftgraph/msgraph-sdk-java#1943

ffcdf and others added 16 commits April 18, 2024 11:36
Suggested modification to the chunkInputStream method:

From the second pass through this method, the code in the line "int lengthAssert = stream.read(buffer, begin, length);" throws the exception java.lang.IndexOutOfBoundsException when trying to assign the read bytes to a non-existent position in the buffer.

The suggested change implies changing InputStream to FileInputStream throughout the LargeFileUploadTask class.
According to the documentation:

public int read(byte[] b, int off, int len) throws IOException

The first byte read is stored into element b[off], the next one into b[off+1], and so on.

However, from the second pass through the chunkInputStream method, off is greater than any position of b and therefore, b[off] does not exist.
Changed chunkInputStream method in LargeFileUploadTask to resolve IndexOutOfBoundsException when uploading large files
@Ndiritu Ndiritu changed the title WIP Fix large file upload Fix large file upload Apr 18, 2024
@Ndiritu Ndiritu marked this pull request as ready for review April 18, 2024 08:51
@Ndiritu Ndiritu requested a review from a team as a code owner April 18, 2024 08:51
@Ndiritu Ndiritu requested a review from baywet April 18, 2024 15:37
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants