From daea62266371578f1c9edf238935b2c14cd72180 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 6 Aug 2026 07:48:01 -0700 Subject: [PATCH 1/4] chore: Update `.codegen.json` with commit hash of `codegen` and `openapi` spec [skip ci] --- .codegen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index dac0bbf22..cb4b60274 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "7b5a612", "specHash": "86fcc6c", "version": "5.15.0" } +{ "engineHash": "fafa70b", "specHash": "86fcc6c", "version": "5.15.0" } From 8faef6b780829148d940b9c614b2c25bcc87e8af Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Fri, 21 Aug 2026 08:15:46 -0700 Subject: [PATCH 2/4] chore: Update `.codegen.json` with commit hash of `codegen` and `openapi` spec [skip ci] --- .codegen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index cb4b60274..78b6ca11c 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fafa70b", "specHash": "86fcc6c", "version": "5.15.0" } +{ "engineHash": "a50b08a", "specHash": "86fcc6c", "version": "5.15.0" } From 7f80e21601c3f148e16e34a52b5e4f6ca8e31796 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 25 Aug 2026 01:41:41 -0700 Subject: [PATCH 3/4] chore: Update `.codegen.json` with commit hash of `codegen` and `openapi` spec [skip ci] --- .codegen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codegen.json b/.codegen.json index 78b6ca11c..3cb1641d2 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "a50b08a", "specHash": "86fcc6c", "version": "5.15.0" } +{ "engineHash": "a50b08a", "specHash": "3599cec", "version": "5.15.0" } From 37cf7eab4b478d50315b5b01a9f39ee42ce86564 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 25 Aug 2026 01:43:42 -0700 Subject: [PATCH 4/4] fix: avoid null chunk when file size is a multiple of part size (box/box-codegen#980) --- .codegen.json | 2 +- .../sdkgen/internal/utils/UtilsManager.java | 46 ++++++++++++------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/.codegen.json b/.codegen.json index 3cb1641d2..e4cb3ac7c 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "a50b08a", "specHash": "3599cec", "version": "5.15.0" } +{ "engineHash": "1cfd1c4", "specHash": "3599cec", "version": "5.15.0" } diff --git a/src/main/java/com/box/sdkgen/internal/utils/UtilsManager.java b/src/main/java/com/box/sdkgen/internal/utils/UtilsManager.java index 665c23722..7832c8dcd 100644 --- a/src/main/java/com/box/sdkgen/internal/utils/UtilsManager.java +++ b/src/main/java/com/box/sdkgen/internal/utils/UtilsManager.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.Set; import java.util.UUID; @@ -311,15 +312,14 @@ public static String hexToBase64(String hex) { public static Iterator iterateChunks( InputStream stream, long chunkSize, long fileSize) { return new Iterator() { - private boolean streamIsFinished = false; + private InputStream nextChunk; + private boolean isNextChunkPrepared = false; - @Override - public boolean hasNext() { - return !streamIsFinished; - } - - @Override - public InputStream next() { + private void prepareNext() { + if (isNextChunkPrepared) { + return; + } + isNextChunkPrepared = true; try { byte[] buffer = new byte[(int) chunkSize]; int bytesRead = 0; @@ -327,25 +327,39 @@ public InputStream next() { while (bytesRead < chunkSize) { int read = stream.read(buffer, bytesRead, (int) (chunkSize - bytesRead)); if (read == -1) { - // End of stream - streamIsFinished = true; break; } bytesRead += read; } if (bytesRead == 0) { - // No more data to yield - streamIsFinished = true; - return null; + nextChunk = null; + return; } - // Return the chunk as a ByteArrayInputStream - return new ByteArrayInputStream(buffer, 0, bytesRead); - } catch (Exception e) { + nextChunk = new ByteArrayInputStream(buffer, 0, bytesRead); + } catch (IOException e) { throw new RuntimeException("Error reading from stream", e); } } + + @Override + public boolean hasNext() { + prepareNext(); + return nextChunk != null; + } + + @Override + public InputStream next() { + prepareNext(); + if (nextChunk == null) { + throw new NoSuchElementException(); + } + InputStream result = nextChunk; + nextChunk = null; + isNextChunkPrepared = false; + return result; + } }; }