From 82edd57205fe48015f81b2986f27856cb9f7fb29 Mon Sep 17 00:00:00 2001 From: Stefan Ferstl Date: Mon, 13 Jul 2015 18:34:38 +0200 Subject: [PATCH] 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 --- gson/pom.xml | 6 ++++++ gson/src/main/java/com/google/gson/Gson.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/gson/pom.xml b/gson/pom.xml index 66c302b5..3b1190d3 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -49,6 +49,12 @@ http://www.google.com + + com.google.code.findbugs + jsr305 + 3.0.0 + true + junit junit diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 844188ac..9d5d6ffd 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -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;