testConstructionWithIndex() — netty Function Reference
Architecture documentation for the testConstructionWithIndex() function in FastThreadLocalTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b5fb11e1_1ebd_84c8_8c3a_129e46b8a02b["testConstructionWithIndex()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9["FastThreadLocalTest"] b5fb11e1_1ebd_84c8_8c3a_129e46b8a02b -->|defined in| c9cb652b_4141_8af2_1f8b_c47765bb30f9 style b5fb11e1_1ebd_84c8_8c3a_129e46b8a02b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java lines 339–368
@Test
public void testConstructionWithIndex() throws Exception {
int ARRAY_LIST_CAPACITY_MAX_SIZE = Integer.MAX_VALUE - 8;
Field nextIndexField =
InternalThreadLocalMap.class.getDeclaredField("nextIndex");
nextIndexField.setAccessible(true);
AtomicInteger nextIndex = (AtomicInteger) nextIndexField.get(AtomicInteger.class);
int nextIndex_before = nextIndex.get();
final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
try {
while (nextIndex.get() < ARRAY_LIST_CAPACITY_MAX_SIZE) {
new FastThreadLocal<Boolean>();
}
assertEquals(ARRAY_LIST_CAPACITY_MAX_SIZE - 1, InternalThreadLocalMap.lastVariableIndex());
try {
new FastThreadLocal<Boolean>();
} catch (Throwable t) {
throwable.set(t);
} finally {
// Assert the max index cannot greater than (ARRAY_LIST_CAPACITY_MAX_SIZE - 1).
assertInstanceOf(IllegalStateException.class, throwable.get());
// Assert the index was reset to ARRAY_LIST_CAPACITY_MAX_SIZE
// after it reaches ARRAY_LIST_CAPACITY_MAX_SIZE.
assertEquals(ARRAY_LIST_CAPACITY_MAX_SIZE - 1, InternalThreadLocalMap.lastVariableIndex());
}
} finally {
// Restore the index.
nextIndex.set(nextIndex_before);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testConstructionWithIndex() do?
testConstructionWithIndex() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java.
Where is testConstructionWithIndex() defined?
testConstructionWithIndex() is defined in common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java at line 339.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free