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 — Adaptive: Only use ThreadLocal if called from FastThreadLocalThread i… · netty/netty@4d1f98d

File tree

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

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

Copy file name to clipboardExpand all lines: buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.netty.util.Recycler.EnhancedHandle;
2323
import io.netty.util.ResourceLeakDetector;
2424
import io.netty.util.concurrent.FastThreadLocal;
25+
import io.netty.util.concurrent.FastThreadLocalThread;
2526
import io.netty.util.internal.MathUtil;
2627
import io.netty.util.internal.ObjectPool;
2728
import io.netty.util.internal.ObjectPool.Handle;
@@ -45,7 +46,6 @@
4546
import java.nio.charset.CoderResult;
4647
import java.nio.charset.CodingErrorAction;
4748
import java.util.Arrays;
48-
import java.util.Locale;
4949

5050
import static io.netty.util.internal.MathUtil.isOutOfBounds;
5151
import static io.netty.util.internal.ObjectUtil.checkNotNull;
@@ -110,8 +110,13 @@ protected byte[] initialValue() throws Exception {
110110
* Allocates a new array if minLength > {@link ByteBufUtil#MAX_TL_ARRAY_LEN}
111111
*/
112112
static byte[] threadLocalTempArray(int minLength) {
113-
return minLength <= MAX_TL_ARRAY_LEN ? BYTE_ARRAYS.get()
114-
: PlatformDependent.allocateUninitializedArray(minLength);
113+
// Only make use of ThreadLocal if we use a FastThreadLocalThread to make the implementation
114+
// Virtual Thread friendly.
115+
// See https://github.com/netty/netty/issues/14609
116+
if (minLength <= MAX_TL_ARRAY_LEN && Thread.currentThread() instanceof FastThreadLocalThread) {
117+
return BYTE_ARRAYS.get();
118+
}
119+
return PlatformDependent.allocateUninitializedArray(minLength);
115120
}
116121

117122
/**

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.