google / google/error-prone

Add built in support for using GuardedBy annotation with a StampedLock

Open
#1,495 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

### Description of the problem / feature request:
Add built in support for using [GuardedBy](https://github.com/google/error-prone/blob/master/docs/bugpattern/GuardedBy.md) annotation with a [StampedLock](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/locks/StampedLock.html).

### Feature requests: what underlying problem are you trying to solve with this feature?
Using error-prone compile-time checks to ensure that fields and methods are protected by a lock however error-prone doesn't support using the GuardedBy annotation with a StampedLock.

### What version of Error Prone are you using?
[v2.3.4](https://github.com/google/error-prone/releases/tag/v2.3.4)

###  Have you found anything relevant by searching the web?
I have done multiple searches on this and looked through the code base. From what I can see `StampedLock` is never mentioned.

----

#### Workaround:
For those reading that would like to use `GuardedBy` with a `StampedLock` it is currently possible to use `new StampedLock().asReadWriteLock();` to get around this issue, however, this is an imperfect solution as it prevents usage of the extra features such as optimistic reads which come with `StampedLock`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.