[Modern Backend] This is the second lecture of the seventh session in Part 1 of the course, "Context Propagation Refactoring (2)."
In this lecture, we apply ScopedValue's automatic inheritance mechanism to the parallel execution section (StructuredTaskScope) of the bulletin board project, and cover binding patterns at asynchronous boundaries and refactoring strategies without side effects.
📌 Key topics:
-
The principle by which the parent thread's ScopedValue binding state is automatically inherited when fork() is called within a parallel execution section
-
Removing and simplifying the manual context-passing (set/clear) code in the existing asynchronous code
-
Preventing side effects without modifying the code of lower-level components (VirusScanClient, Thumbnailer) by keeping the RequestContext.get() signature unchanged
-
Reviewing the limitations of ScopedValue's automatic propagation and binding patterns for various execution boundaries (unit tests, @Scheduled batches, @Async, and more)
-
An advance introduction to verifying propagation by writing unit tests in 7.6 and intentionally triggering compiler errors
Explore a Modern Java architecture that safely inherits context in virtual-thread and structured-concurrency environments without requiring separate manual work.