Modern Backend - Range Values (2)

Modern Backend - Range Values (2)

This is the second lecture of the sixth session in Part 1 of the [Modern Backend] course, "Scoped Values (2)."
In this lecture, we will cover in detail the four core design principles of Scoped Values, an official Java 25 feature, practical API usage patterns, the dedicated caching mechanism, and the limitations and criteria that must be considered when applying them in practice.

📌 Key topics:

  • The four design principles of Scoped Values (Immutable, Dynamic Scope, One-way, Structured)

  • Comparison of the lifetime (Timeline) and shadowing behavior of ThreadLocal and ScopedValue

  • ScopedValue declaration and binding patterns (understanding where, run, call, and Carrier objects)

  • Protection against unbound paths and exception handling (get, isBound, orElse, orElseThrow)

  • Automatic inheritance of Scoped Values through integration with structured concurrency (StructuredTaskScope)

  • The mechanism of 16 thread-specific cache slots and the principles of performance optimization

  • Limitations of applying them in Servlet Filter vs HandlerInterceptor

  • Limitations of propagation across asynchronous thread boundaries (ExecutorService, @Async, Reactor) and alternatives

  • Three criteria for deciding whether to adopt them in practice and a step-by-step refactoring strategy

Take an in-depth look at how to apply and leverage the safe, high-performance Scoped Value provided by Java 25 in practical architectures.

Site footer