Skip to content

Fall back when the byte array buffer pool is exhausted - #515

Merged
em3s merged 1 commit into
kakao:mainfrom
poketopa:fix/byte-array-buffer-pool-exhaustion
Oct 22, 2026
Merged

em3s merged 1 commit into
kakao:mainfrom
poketopa:fix/byte-array-buffer-pool-exhaustion

Conversation

@poketopa

Copy link
Copy Markdown
Contributor

Summary

ByteArrayBufferPool.acquire() throws a NullPointerException when all pooled buffers are in use. This can be reproduced by nesting use calls on a pool with poolSize = 1. Allocate a buffer of the configured size when the pool is empty, following the approach used for codec-java in #506.

Changes

  • Preserve the configured buffer size for fallback allocation.
  • Add tests for nested encoding with an exhausted pool and for the fallback buffer size.

How to Test

  • ./gradlew :core:test --tests '*ByteArrayBufferPoolTest': both regression tests fail before the fix and pass afterward.
  • ./gradlew spotlessCheck build --continue: formatting checks passed. The full build did not pass because engine tests encountered local HBase mini-cluster startup failures.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Claude Opus 5.5)
    • Codex assisted with the PR draft and review.

acquire() returned pool.poll() directly, so once every pooled buffer was
in use the Kotlin null check threw "poll(...) must not be null". Keep the
pool's buffer size and allocate a fresh buffer of that size instead.
@poketopa
poketopa requested a review from em3s as a code owner October 20, 2026 04:13
@em3s

em3s commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @poketopa! Not reachable today since nothing nests use and the pool is 100, but it's cheap and matches #506 👍. Merging.

@em3s
em3s merged commit e0a0fb9 into kakao:main Oct 22, 2026
3 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.

2 participants