RSS Amplifier

Engineering With Java · Aug 6, 2026

Spring Boot Interview Question - @Async Broke Our Audit Logs

0
Sign in to vote or save

Suraj Mishra · Engineering With Java

A payment service stores request metadata in MDC so every log line contains the request information.

The controller logs look correct:

But every log produced inside sendReceipt() shows:

Join 8100+ developers and get weekly, no-fluff content featuring practical coding tips, real-world backend insights, and interview questions based on production scenarios.

Founding Member Offer: Lock in founding member price at $50/year (~$4/month) for life. Limited spot left.

So far we have covered 70+ real world based interview questions and will add up to 100 by end of this year.

Testimonials

Why did the audit context disappear?

Most logging frameworks store MDC using ThreadLocal. The values belong only to the current thread.

The executor picks another thread from its pool. That thread has a completely different ThreadLocal map.

Hence MDC.get("requestId") returns null

Unlike method arguments, ThreadLocal state is never copied automatically. Even if the thread comes from the same executor every time, the context is not transferred.

How would you fix it without changing every @Async method in the application?

Read the original on javabulletin.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.