From 405759cf67e95b3f856ef3b94e35482eb4d3c409 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 11:11:52 +0000 Subject: [PATCH] docs: Pick lock type per module in AGENTS.md and REVIEWS.md JVM and shared modules keep AutoClosableReentrantLock because synchronized pins virtual threads on JDK 21-23. Android-only modules use synchronized, since Android has no virtual threads. Co-Authored-By: Roman Zavarnitsyn --- AGENTS.md | 5 ++++- REVIEWS.md | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1cf3451198..35f4c7177f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -231,7 +231,10 @@ Two more rules that catch most of the rest: - **Read mutable shared state once per operation.** Re-reading the same field for several decisions in one pass lets it change mid-pass, so the results disagree with each other. -Prefer `AutoClosableReentrantLock` over `synchronized`, matching the rest of the codebase. +**Which lock to use depends on the module.** In JVM and shared modules, including `sentry` core, +use `AutoClosableReentrantLock`: `synchronized` pins virtual threads on JDK 21–23. In Android-only +modules (`sentry-android-*`), use `synchronized`, since Android has no virtual threads. Don't rewrite +existing locks only to switch between the two. ### Measuring Time diff --git a/REVIEWS.md b/REVIEWS.md index 3732a5785a..4fc27faebd 100644 --- a/REVIEWS.md +++ b/REVIEWS.md @@ -105,7 +105,9 @@ rule file in [`.cursor/rules/`](.cursor/rules) for the area the diff touches (`a plain field read is a data race, not merely a stale value. - Read mutable shared state once per operation. Re-reading the same field for several decisions in one pass lets it change mid-pass, so the results disagree with each other. -- Prefer the `synchronized` keyword. Existing code that uses `AutoClosableReentrantLock` is legacy. +- In JVM and shared modules, including `sentry` core, use `AutoClosableReentrantLock`, not + `synchronized`, which pins virtual threads on JDK 21–23. In Android-only modules + (`sentry-android-*`), use `synchronized`. Don't flag existing locks that predate this rule. - New classes have a clear and defined threading and concurrency model as part of the javadoc if needed.