google / google/error-prone

Suggested Error Prone pattern: NumberFormatContstant (like existing DateFormatConstant)

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

Description

> ATTENTION! Please read and follow:
> - if this is a _question_ about Error Prone, send it to error-prone-discuss@googlegroups.com
> - if this is a _bug_ or _feature request_, fill the form below as best as you can.

### Description of the problem / feature request:

The existing pattern for DateFormatConstant (along with its fix, adding a ThreadLocal initializer) should be adapted to also support NumberFormat and DecimalFormat. There may also be other common thread-unsafe Format classes that would make sense to treat similarly.

### Feature requests: what underlying problem are you trying to solve with this feature?

Similar to DateFormat, NumberFormat is not threadsafe.

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
```java
class Foo {
public static NumberFormat FORMAT = NumberFormat.getInstance()
// call FORMAT.format() from multiple threads concurrently and wait for things to go wrong
}
```

### What version of Error Prone are you using?

2.3.3

### Have you found anything relevant by searching the web?

Here's a discussion on the java bugtracker https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4101500

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.