← Java / Spring · Contents

JAVA-067 / Advanced

Shared mutable state across threads (SimpleDateFormat or global fields)

A04:2021 · CWE-362 Race Condition

Why is this a problem?

Data becomes mixed across requests, exposing other users' information.

How to fix it

java
// Pass a request-scoped object or parameter; call remove() on ThreadLocal in finally

Further reading