Add a JSR-305 @ThreadSafe annotation to the Gson class

- Add an optional dependency to com.google.code.findbugs:jsr305.
  The optional scope is used in order to avoid introducing a new
  transitive dependency to the jsr305 library. This is fine because the 
  @ThreadSafe annotation has only a documentary purpose and it is not
  retained at runtime.
- Annotate the Gson class as @ThreadSafe

Fixes Issue #613
This commit is contained in:
Stefan Ferstl 2015-07-13 18:34:38 +02:00
parent fcfd397d6f
commit 82edd57205
2 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,12 @@
<url>http://www.google.com</url>
</organization>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -31,6 +31,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.Excluder;
import com.google.gson.internal.Primitives;
@ -96,6 +98,7 @@ import com.google.gson.stream.MalformedJsonException;
* @author Joel Leitch
* @author Jesse Wilson
*/
@ThreadSafe
public final class Gson {
static final boolean DEFAULT_JSON_NON_EXECUTABLE = false;