Skip to content

API-2971: OutOfMemoryError: java heap space assetService.uploadFile - #158

Merged
ahongbynder merged 4 commits into
masterfrom
API-2971
Sep 23, 2026
Merged

ahongbynder merged 4 commits into
masterfrom
API-2971

Conversation

@ahongbynder

@ahongbynder ahongbynder commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Addresses #157

Fixes SocketTimeoutException and OutOfMemoryError on large file uploads:

  • Timeout: the S3 upload client ignored HttpConnectionSettings entirely and silently used OkHttp's default 10s timeouts. Now threaded through so it's configurable.
  • OOM: RXUtils.mapWithIndex used zipWith(Observable.range(...)), which (since Observable has no backpressure) drained the entire file into memory before uploading a single chunk. Replaced with a lazy map + counter so chunks are indexed and uploaded one at a time. (Affects large files, > 1GB)
  • Switched chunk upload to concatMapSingle (strictly sequential)

@coveralls

coveralls commented Sep 22, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 40.09% (+0.3%) from 39.819% — API-2971 into master

- Thread HttpConnectionSettings through the Amazon S3 upload client
  (ApiFactory, AmazonS3Service/Impl, FileUploader, AssetService/Impl,
  BynderClientImpl) so upload timeouts are configurable instead of
  silently defaulting to OkHttp's hardcoded 10s connect/read/write
  timeouts, which caused SocketTimeoutException on large file uploads.
- Fix RXUtils.mapWithIndex to pair chunks with their index via a lazy
  map instead of zipWith(Observable.range(...)), which greedily drained
  the entire file into memory before any chunk was uploaded, causing an
  OutOfMemoryError on multi-gigabyte files.
- Switch FileUploader's chunk upload from flatMapSingle to
  concatMapSingle to process chunks strictly one at a time.
- Update HttpConnectionSettingsTest to match the new default timeout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ahongbynder
ahongbynder marked this pull request as ready for review September 23, 2026 22:05
@ahongbynder
ahongbynder merged commit 5028be4 into master Sep 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants