Skip to content

Commit

Permalink
Add a JSR-305 @threadsafe annotation to the Gson class
Browse files Browse the repository at this point in the history
- 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 google#613
  • Loading branch information
ferstl committed Jul 13, 2015
1 parent fcfd397 commit 82edd57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions gson/src/main/java/com/google/gson/Gson.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
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;
Expand Down Expand Up @@ -96,6 +98,7 @@
* @author Joel Leitch
* @author Jesse Wilson
*/
@ThreadSafe
public final class Gson {
static final boolean DEFAULT_JSON_NON_EXECUTABLE = false;

Expand Down

0 comments on commit 82edd57

Please sign in to comment.