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 — Reject negative maxOrder in PooledByteBufAllocator (#17093) · netty/netty@101e286

File tree

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

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

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private static int validateAndCalculatePageShifts(int pageSize, int alignment) {
360360
}
361361

362362
private static int validateAndCalculateChunkSize(int pageSize, int maxOrder) {
363-
if (maxOrder > 14) {
363+
if (maxOrder < 0 || maxOrder > 14) {
364364
throw new IllegalArgumentException("maxOrder: " + maxOrder + " (expected: 0-14)");
365365
}
366366

Collapse file

‎buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java‎

Copy file name to clipboardExpand all lines: buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.netty.util.internal.ThrowableUtil;
2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.Timeout;
26+
import org.junit.jupiter.api.function.Executable;
2627

2728
import java.nio.ByteBuffer;
2829
import java.util.ArrayList;
@@ -45,6 +46,7 @@
4546
import static org.junit.jupiter.api.Assertions.assertEquals;
4647
import static org.junit.jupiter.api.Assertions.assertFalse;
4748
import static org.junit.jupiter.api.Assertions.assertNotNull;
49+
import static org.junit.jupiter.api.Assertions.assertThrows;
4850
import static org.junit.jupiter.api.Assertions.assertTrue;
4951
import static org.junit.jupiter.api.Assumptions.assumeTrue;
5052

@@ -78,6 +80,18 @@ protected void trimCaches(PooledByteBufAllocator allocator) {
7880
allocator.trimCurrentThreadCache();
7981
}
8082

83+
@Test
84+
public void testRejectNegativeMaxOrder() {
85+
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, new Executable() {
86+
@Override
87+
public void execute() throws Throwable {
88+
new PooledByteBufAllocator(true, 1, 1, 8192, -1, 0, 0, false);
89+
}
90+
});
91+
92+
assertEquals("maxOrder: -1 (expected: 0-14)", exception.getMessage());
93+
}
94+
8195
@Test
8296
public void testTrim() {
8397
PooledByteBufAllocator allocator = newAllocator(true);

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.