Files
llm-wiki/raw/company-tech-blogs/scoped-value-structured-concurrency-softwaremill.md
T

5.3 KiB

title, source_type, url, archive_url, related_branches, related_projects, tags, created, last_reviewed, status, confidence
title source_type url archive_url related_branches related_projects tags created last_reviewed status confidence
company-tech-blog / SoftwareMill — Structured Concurrency and Scoped Values in Java (2025) company-tech-blog https://softwaremill.com/structured-concurrency-and-scoped-values-in-java/
feature-runtime-context-propagation-contract
ca-skeleton
ca-tmpl
company-tech-blog
java-25
scoped-value
structured-concurrency
virtual-threads
context-propagation
softwaremill
2026-06-09 2026-06-09 raw medium

SoftwareMill — Structured Concurrency and Scoped Values in Java

Layer: raw/company-tech-blogs/ — SoftwareMill 기술 블로그 발췌. 출처 주의: company-tech-blog 이므로 본 자료의 권장 사항을 "공식 best practice" 로 일반화 금지. ScopedValue + StructuredTaskScope 조합의 production 사용 패턴 사례 reference 로만 사용. WebFetch 성공. Author: Robert Pudlik, Published/Updated: September 2025.

Parent / 활용 branch

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-runtime-context-propagation-contract Alt-1 (ScopedValue) 의 StructuredTaskScope 통합 패턴 사례 — "scoped values are easier to reason about than ThreadLocal, and have lower cost" 실무 관점 근거

출처 / Source

핵심 인용 / Key quotes (verbatim, WebFetch)

"scoped values are a mechanism to share immutable data between methods and child threads in a simple and safe way. They are easier to reason about than ThreadLocal, and have lower cost."

"Structured concurrency means that all subtasks are bound to the scope of their parent task and cannot outlive it, just like a method call cannot last longer than the method that invoked it."

"Structured concurrency (JEP 505)" and "Scoped values (JEP 506)" are described as "a great addition to the Java standard API."

Code example (ScopedValue with StructuredTaskScope fork):

private static final ScopedValue<String> REQUEST_ID = ScopedValue.newInstance();
scope.fork(() -> where(REQUEST_ID, "abc-123").run(Main::handleRequest));

"Subtasks automatically inherit the bound REQUEST_ID value, allowing logging without parameter passing."

Self-Grep 검증

Fragment: "scoped values are a mechanism to share immutable data between methods and child threads in a simple and safe way"
→ WebFetch output 에서 확인 PASS

Fragment: "Structured concurrency means that all subtasks are bound to the scope of their parent task and cannot outlive it"
→ WebFetch output 에서 확인 PASS

검증한 인용 V: 3 / PASS P: 3 / 폐기 D: 0

Claims Extracted

Claim ID Claim Evidence quote Strength Applies to Does not prove
SM-SV-C1 ScopedValue 는 "immutable data" 공유 메커니즘으로 ThreadLocal 보다 "easier to reason about" 하고 "lower cost" 를 가진다 "scoped values are a mechanism to share immutable data between methods and child threads in a simple and safe way. They are easier to reason about than ThreadLocal, and have lower cost." company-case-study Java 25 기준 ScopedValue 를 사용하는 production 코드 (2025 업데이트 기준) "lower cost" 의 정량적 수치 없음. benchmark 없음. ThreadLocal 대비 상대적 표현만 있음
SM-SV-C2 StructuredTaskScope.fork() 안에서 ScopedValue binding 을 설정하면 child task 가 자동 상속 scope.fork() 안에서 where(REQUEST_ID, "abc-123").run(Main::handleRequest) 사용 시 "Subtasks automatically inherit the bound REQUEST_ID value" company-case-study StructuredTaskScope 를 사용하는 Java 25 (finalized) 코드 Java 21 preview 상태에서의 동작 — API shape 는 동일하나 --enable-preview 필요
SM-SV-C3 JEP 506 (ScopedValues) + JEP 505 (Structured Concurrency) 모두 Java 25 에서 finalized "Structured concurrency (JEP 505)" and "Scoped values (JEP 506)" are "a great addition to the Java standard API" (September 2025 업데이트) company-case-study (corroborates official JEP 506 announcement) Java 25 GA 이후 코드베이스 Java 21 LTS 에서의 preview 상태를 직접 언급하지 않음

Usage Boundaries

  • 이 자료가 지지하는 것:
    • ScopedValue + StructuredTaskScope 조합이 request-scoped context propagation 에 실용적으로 사용 가능함 (SoftwareMill 엔지니어 관점)
    • Java 25 기준으로 두 feature 모두 안정화됨
  • 이 자료가 증명하지 않는 것:
    • Spring Boot 3.5.x (Java 21 preview) 환경에서의 production 안전성
    • 대규모 서비스 (high RPS, multi-tenant) 에서의 운영 검증
    • ThreadLocal 기반 legacy 코드에서 ScopedValue 로의 마이그레이션 비용

메모 / Notes

  • SoftwareMill 은 Java/Scala 전문 기술 컨설팅 회사 (폴란드). 저자 Robert Pudlik 은 블로그에 credited.
  • company-tech-blog 이므로 공식 best practice 로 취급 금지. JEP 506 공식 문서와 corroboration 시 신뢰도 상승.
  • 이 블로그는 Java 25 기준으로 작성. ca-tmpl 의 Java 21 LTS 환경에서는 --enable-preview 플래그 필요 — 이 블로그는 그 제약을 명시하지 않음.