Modern Backend - Refactoring Context Propagation (3)

Modern Backend - Refactoring Context Propagation (3)

This is the hands-on session for the third lecture of the seventh lesson in Part 1 of the [Modern Backend] course, "Refactoring Context Propagation (3)."
In this lecture, based on the design theory learned in Lessons 6 and 7, we will conduct a live coding exercise to directly convert the existing ThreadLocal code in the bulletin board practice project to Java 25's Scoped Value.

📌 Key topics:

  • Step 1: Refactoring the RequestContext holder class (removing ThreadLocal, declaring ScopedValue, defining the SYSTEM constant, and implementing runWith / callWith / getOrSystem / isBound)

  • Step 2: Modifying the request entry point, RequestContextFilter (binding ScopedValue in the Servlet Filter and resolving Checked Exception/generic type inference issues)

  • Step 3: Refactoring the business logic (PostCreationCoordinator) (removing unnecessary manual set/clear/finally management code within structured concurrency)

  • Completing a clean and safe Modern Java backend architecture by combining structured concurrency (StructuredTaskScope) with ScopedValue

See firsthand the entire live coding process of removing ThreadLocal from a real-world project and transitioning the code to Modern Java's concurrency paradigm.

Site footer