Skip to content

Commit b39b6bf

Browse files
committed
- non-generated code sync with v1
1 parent 947a1f3 commit b39b6bf

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/main/java/com/microsoft/graph/concurrency/ChunkedUploadProvider.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,20 @@ public void upload(final List<Option> options,
168168
byte[] buffer = new byte[chunkSize];
169169

170170
while (this.readSoFar < this.streamSize) {
171-
int read = this.inputStream.read(buffer);
172-
173-
if (read == -1) {
174-
break;
171+
int buffRead = 0;
172+
173+
// inner loop is to work-around the case where read buffer size is limited to less than chunk size by a global setting
174+
while (buffRead < chunkSize) {
175+
int read = 0;
176+
read = this.inputStream.read(buffer, buffRead, chunkSize - buffRead);
177+
if (read == -1) {
178+
break;
179+
}
180+
buffRead += read;
175181
}
176182

177183
ChunkedUploadRequest request =
178-
new ChunkedUploadRequest(this.uploadUrl, this.client, options, buffer, read,
184+
new ChunkedUploadRequest(this.uploadUrl, this.client, options, buffer, buffRead,
179185
maxRetry, this.readSoFar, this.streamSize);
180186
ChunkedUploadResult<UploadType> result = request.upload(this.responseHandler);
181187

@@ -190,7 +196,7 @@ public void upload(final List<Option> options,
190196
break;
191197
}
192198

193-
this.readSoFar += read;
199+
this.readSoFar += buffRead;
194200
}
195201
}
196202

src/main/java/com/microsoft/graph/requests/extensions/ChunkedUploadRequest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ChunkedUploadRequest {
3131
/**
3232
* The seconds for retry delay.
3333
*/
34-
private static final int RETRY_DELAY = 2 * 1000;
34+
private static final long RETRY_DELAY = 2000L; // 2 seconds
3535

3636
/**
3737
* The chunk data sent to the server.
@@ -46,12 +46,12 @@ public class ChunkedUploadRequest {
4646
/**
4747
* The max retry for a single request.
4848
*/
49-
private final int maxRetry;
49+
private final long maxRetry;
5050

5151
/**
5252
* The retry counter.
5353
*/
54-
private int retryCount;
54+
private long retryCount;
5555

5656
/**
5757
* Construct the ChunkedUploadRequest
@@ -75,8 +75,8 @@ public ChunkedUploadRequest(final String requestUrl,
7575
final long totalLength) {
7676
this.data = new byte[chunkSize];
7777
System.arraycopy(chunk, 0, this.data, 0, chunkSize);
78-
this.retryCount = 0;
79-
this.maxRetry = maxRetry;
78+
this.retryCount = 0L;
79+
this.maxRetry = (long)maxRetry;
8080
this.baseRequest = new BaseRequest(requestUrl, client, options, ChunkedUploadResult.class) {
8181
};
8282
this.baseRequest.setHttpMethod(HttpMethod.PUT);

0 commit comments

Comments
 (0)