GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix adaptive allocator bug from not noticing failed allocation (#16200) · netty/netty@fe723f2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • buffer/src/main/java/io/netty/buffer
    • AdaptivePoolingAllocator.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java‎

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ private AdaptiveByteBuf allocateFallback(int size, int maxCapacity, Thread curre
309309
Chunk chunk = new Chunk(innerChunk, magazine, false, chunkSize -> true);
310310
chunkRegistry.add(chunk);
311311
try {
312-
chunk.readInitInto(buf, size, size, maxCapacity);
312+
boolean success = chunk.readInitInto(buf, size, size, maxCapacity);
313+
assert success: "Failed to initialize ByteBuf with dedicated chunk";
313314
} finally {
314315
// As the chunk is an one-off we need to always call release explicitly as readInitInto(...)
315316
// will take care of retain once when successful. Once The AdaptiveByteBuf is released it will
@@ -749,9 +750,10 @@ private boolean allocateWithoutLock(int size, int maxCapacity, AdaptiveByteBuf b
749750
int remainingCapacity = curr.remainingCapacity();
750751
int startingCapacity = chunkController.computeBufferCapacity(
751752
size, maxCapacity, true /* never update stats as we don't hold the magazine lock */);
752-
if (remainingCapacity >= size) {
753-
curr.readInitInto(buf, size, Math.min(remainingCapacity, startingCapacity), maxCapacity);
753+
if (remainingCapacity >= size &&
754+
curr.readInitInto(buf, size, Math.min(remainingCapacity, startingCapacity), maxCapacity)) {
754755
allocated = true;
756+
remainingCapacity = curr.remainingCapacity();
755757
}
756758
try {
757759
if (remainingCapacity >= RETIRE_CAPACITY) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.