FastThreadLocalTest Class — netty Architecture
Architecture documentation for the FastThreadLocalTest class in FastThreadLocalTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c9cb652b_4141_8af2_1f8b_c47765bb30f9["FastThreadLocalTest"] 8487d652_7084_0729_ca43_9b105405e7a0["FastThreadLocalTest.java"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|defined in| 8487d652_7084_0729_ca43_9b105405e7a0 3c75cfa5_4503_1c2b_2315_1765cf42c143["setUp()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 3c75cfa5_4503_1c2b_2315_1765cf42c143 1fffdee5_a395_00be_ff7c_9b0186ab26a1["testGetAndSetReturnsOldValue()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 1fffdee5_a395_00be_ff7c_9b0186ab26a1 518631b2_9296_ce00_f225_6d5c9549b95f["testGetIfExists()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 518631b2_9296_ce00_f225_6d5c9549b95f fca80ece_95ff_ff9f_ebc8_978fc1aab436["testRemoveAll()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| fca80ece_95ff_ff9f_ebc8_978fc1aab436 3f581515_c12c_d16f_0df0_8c5ca7e9a218["testRemoveAllFromFTLThread()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 3f581515_c12c_d16f_0df0_8c5ca7e9a218 74917990_4011_56b2_a6db_1ef007f7ba9f["testMultipleSetRemove()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 74917990_4011_56b2_a6db_1ef007f7ba9f 288bb74d_caad_9d5b_0139_522cfc079a4a["testMultipleSetRemove_multipleThreadLocal()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 288bb74d_caad_9d5b_0139_522cfc079a4a d316299d_1972_02a1_25b6_12a923156968["testWrappedProperties()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| d316299d_1972_02a1_25b6_12a923156968 6ab9cb4b_b38c_1251_6260_1991db795321["testWrapMany()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 6ab9cb4b_b38c_1251_6260_1991db795321 f1d8a426_b004_5ddf_cc05_0ca4720616cf["testOnRemoveCalledForFastThreadLocalGet()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| f1d8a426_b004_5ddf_cc05_0ca4720616cf 2477f800_af92_4ac4_8ad4_9b9231b884d9["testOnRemoveCalledForNonFastThreadLocalGet()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 2477f800_af92_4ac4_8ad4_9b9231b884d9 874ba961_e3a2_ab5c_db4f_84a905873081["testOnRemoveCalledForFastThreadLocalSet()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 874ba961_e3a2_ab5c_db4f_84a905873081 726732d5_35e5_86a7_07cf_73da84faf201["testOnRemoveCalledForNonFastThreadLocalSet()"] c9cb652b_4141_8af2_1f8b_c47765bb30f9 -->|method| 726732d5_35e5_86a7_07cf_73da84faf201
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java lines 46–454
public class FastThreadLocalTest {
@BeforeEach
public void setUp() {
FastThreadLocal.removeAll();
assertEquals(0, FastThreadLocal.size());
}
@Test
public void testGetAndSetReturnsOldValue() {
FastThreadLocal<Boolean> threadLocal = new FastThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return Boolean.TRUE;
}
};
assertNull(threadLocal.getAndSet(Boolean.FALSE));
assertEquals(Boolean.FALSE, threadLocal.get());
assertEquals(Boolean.FALSE, threadLocal.getAndSet(Boolean.TRUE));
assertEquals(Boolean.TRUE, threadLocal.get());
threadLocal.remove();
}
@Test
public void testGetIfExists() {
FastThreadLocal<Boolean> threadLocal = new FastThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return Boolean.TRUE;
}
};
assertNull(threadLocal.getIfExists());
assertTrue(threadLocal.get());
assertTrue(threadLocal.getIfExists());
FastThreadLocal.removeAll();
assertNull(threadLocal.getIfExists());
}
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testRemoveAll() throws Exception {
final AtomicBoolean removed = new AtomicBoolean();
final FastThreadLocal<Boolean> var = new FastThreadLocal<Boolean>() {
@Override
protected void onRemoval(Boolean value) {
removed.set(true);
}
};
// Initialize a thread-local variable.
assertNull(var.get());
assertEquals(1, FastThreadLocal.size());
// And then remove it.
FastThreadLocal.removeAll();
assertTrue(removed.get());
assertEquals(0, FastThreadLocal.size());
}
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testRemoveAllFromFTLThread() throws Throwable {
final AtomicReference<Throwable> throwable = new AtomicReference<Throwable>();
final Thread thread = new FastThreadLocalThread() {
@Override
public void run() {
try {
testRemoveAll();
} catch (Throwable t) {
throwable.set(t);
}
}
};
thread.start();
thread.join();
Throwable t = throwable.get();
if (t != null) {
Source
Frequently Asked Questions
What is the FastThreadLocalTest class?
FastThreadLocalTest is a class in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java.
Where is FastThreadLocalTest defined?
FastThreadLocalTest is defined in common/src/test/java/io/netty/util/concurrent/FastThreadLocalTest.java at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free