Files
llm-wiki/raw/company-tech-blogs/threadlocal-capture-restore-att-israel.md
T

6.1 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 / AT&T Israel — TaskDecorator Pattern for ThreadLocal Context Propagation (2022) company-tech-blog https://medium.com/att-israel/dont-lose-your-thread-manage-and-decorate-your-concurrent-threads-391cf34e6bc6
feature-runtime-context-propagation-contract
ca-skeleton
ca-tmpl
company-tech-blog
threadlocal
capture-restore
task-decorator
spring-boot
async
att-israel
2026-06-09 2026-06-09 raw medium

AT&T Israel — TaskDecorator Pattern for ThreadLocal Context Propagation

Layer: raw/company-tech-blogs/ — AT&T Israel Tech Blog 의 ThreadLocal capture-restore 패턴 아티클. 출처 주의: company-tech-blog 이므로 공식 best practice 로 일반화 금지. Plain ThreadLocal + explicit capture-restore (Alt-3) 의 실용적 구현 패턴 사례 reference 로만 사용. WebFetch 성공. Author: Chaya Berezin-Chaimson (AT&T Israel), Published: April 6, 2022. 주의: 2022년 아티클이므로 Java 21 virtual threads 출시 이전 기준. Virtual thread 호환성 검증은 별도 필요.

Parent / 활용 branch

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-runtime-context-propagation-contract Alt-3 (Plain ThreadLocal + manual capture-restore) 의 TaskDecorator 기반 구현 패턴 사례 근거

출처 / Source

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

"The article describes implementing a CorrelationIdTaskDecorator that: Extracts the correlation ID from the parent thread's ThreadLocal variable; Returns a new runnable that assigns this value to the spawned thread's ThreadLocal before executing the original task."

"This decorator is attached to a custom Executor bean, ensuring automatic state transfer across all async operations."

"The solution uses plain ThreadLocal with explicit capture — not InheritableThreadLocal. The decorator manually copies values between parent and child thread contexts rather than relying on inheritance mechanisms."

(Pattern summary) Capture on parent thread → Store in closure → Restore before task execution → (implicit: clear after task in finally block for pooled threads)

Self-Grep 검증

Fragment: "CorrelationIdTaskDecorator"
→ WebFetch output 에서 확인 PASS

Fragment: "plain ThreadLocal with explicit capture — not InheritableThreadLocal"
→ WebFetch 분석 결과 (agent extraction) — 원문 exact phrase 아닐 수 있음 (INFERENCE 주의)
→ "not InheritableThreadLocal" 은 agent extraction. 실제 원문 verbatim 확인 권고.

검증한 인용 V: 2 / PASS P: 1 / INFERENCE P: 1 (InheritableThreadLocal 비사용 여부는 agent-inferred, not verbatim)

Claims Extracted

Claim ID Claim Evidence quote Strength Applies to Does not prove
ATT-TL-C1 Spring TaskDecorator 패턴으로 parent thread 의 ThreadLocal 값을 child thread 실행 전에 restore 할 수 있다 "implements a CorrelationIdTaskDecorator that Extracts the correlation ID from the parent thread's ThreadLocal variable; Returns a new runnable that assigns this value to the spawned thread's ThreadLocal before executing the original task." company-case-study Spring Boot + custom ThreadPoolTaskExecutor 환경 (2022 기준) virtual thread 환경 (Java 21+) 에서의 동작 안전성 — 이 아티클은 Java 21 이전 기준
ATT-TL-C2 TaskDecorator 를 custom Executor bean 에 attach 하면 모든 async operation 에 자동으로 context 전달된다 "This decorator is attached to a custom Executor bean, ensuring automatic state transfer across all async operations." company-case-study Spring @Async + ThreadPoolTaskExecutor 환경 Spring Boot 3.2+ 의 SimpleAsyncTaskExecutor (virtual threads) 에서의 동작 — 별도 검증 필요
ATT-TL-C3 InheritableThreadLocal 없이 plain ThreadLocal + explicit copy 로 context 전달 가능 Agent extraction: "uses plain ThreadLocal with explicit capture — not InheritableThreadLocal" company-case-study + INFERENCE (verbatim 확인 필요) InheritableThreadLocal 금지 환경에서 context propagation 이 필요한 경우 ca-tmpl 의 ArchUnit InheritableThreadLocal ban 이 이 패턴을 허용하는지 직접 증명하지 않음 (허용 — plain ThreadLocal 이므로)

Usage Boundaries

  • 이 자료가 지지하는 것:
    • TaskDecorator 기반 explicit capture-restore 가 실제 production 코드에서 사용됨 (AT&T Israel 사례)
    • InheritableThreadLocal 없이 plain ThreadLocal 으로 context 전달 가능
  • 이 자료가 증명하지 않는 것:
    • virtual thread 환경 (Java 21+) 에서의 동작 — 2022년 작성, Loom GA 이전
    • StructuredTaskScope 환경에서의 동작
    • domain/business context (tenantId, userId) 에 직접 적용 가능성 — 이 아티클은 correlationId (diagnostic) 에 집중
  • 내 프로젝트 적용 시 주의:
    • Java 21 virtual thread 환경에서 TaskDecorator 패턴이 SimpleAsyncTaskExecutor (virtual thread based) 와 호환되는지 별도 확인 필요
    • ca-tmpl 의 foundation branch 가 이미 MDC TaskDecorator 를 소유 (feature-background-job-async-contract) — 도메인 context 용 TaskDecorator 는 별도 추가 또는 기존 확장

메모 / Notes

  • AT&T Israel 은 AT&T 의 이스라엘 R&D 센터 — 대규모 Java 서비스 운영 컨텍스트.
  • 2022년 아티클이므로 Java 21 virtual thread, StructuredTaskScope 에 대한 고려 없음.
  • ca-tmpl 의 feature-background-job-async-contract branch 가 이미 MDC TaskDecorator 를 소유하므로 Alt-3 의 구현은 그 branch 와의 조율이 필요.
  • virtual thread 환경에서 SimpleAsyncTaskExecutor 에도 TaskDecorator 를 attach 할 수 있는지는 Spring Boot 3.2+ 문서 별도 확인 필요.