It seems just fine to me. There is nothing in the GSON instance that makes it related to a specific instance of LoginSession
, so it should be static.
GSON instances should be thread-safe, and there was a bug regarding that which was fixed.
More Related Contents:
- Are non-synchronised static methods thread safe if they don’t modify static class variables?
- Use of Private static
- Why does my ArrayList contain N copies of the last item added to the list?
- Why doesn’t Java allow overriding of static methods?
- Why does Gson fromJson throw a JsonSyntaxException: Expected BEGIN_OBJECT but was BEGIN_ARRAY?
- Gson TypeToken with dynamic ArrayList item type
- How do I write a custom JSON deserializer for Gson?
- Are static fields open for garbage collection?
- When are static variables initialized?
- Is default no-args constructor mandatory for Gson?
- Parsing JSON array into java.util.List with Gson
- Thread safe multitons in Java
- Is a volatile int in Java thread-safe?
- Gson custom seralizer for one variable (of many) in an object using TypeAdapter
- How to stop a thread created by implementing runnable interface?
- GSON deserializing key-value to custom object
- ProGuard for Android and GSON
- When to use static variables/methods and when to use instance variables/methods in Java? [closed]
- @Autowired and static method
- Dealing with randomly generated and inconsistent JSON field/key names using GSON
- How to implement thread-safe lazy initialization?
- How to convert Json to Java object using Gson [duplicate]
- Gson – deserialization to specific object type based on field value
- final fields and thread-safety
- What is the use of a private static variable in Java?
- Why can’t a top level class be static in Java?
- Are arrays thread-safe in Java?
- How to serialize and deserialize Java 8’s java.time types with Gson? [closed]
- How to serialize Optional classes with Gson?
- Java : in what order are static final fields initialized?