Skip to content

Commit eb149e2

Browse files
committed
use static gson object
1 parent 7c7096e commit eb149e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/de/labystudio/spotifyapi/open/OpenSpotifyAPI.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
public class OpenSpotifyAPI {
2626

27+
private static final Gson GSON = new Gson();
28+
2729
private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/71.0.3578.98";
2830

2931
private static final String URL_API_GEN_ACCESS_TOKEN = "https://open.spotify.com/get_access_token?reason=transport&productType=web_player";
@@ -113,7 +115,7 @@ public void requestImageUrlAsync(Track track, Consumer<String> callback) {
113115
* Request the track information of the given track asynchronously.
114116
* If the open track is already in the cache, it will be returned.
115117
*
116-
* @param track The track to lookup
118+
* @param track The track to lookup
117119
* @param callback Response with the open track. It won't be called on an error.
118120
*/
119121
public void requestOpenTrackAsync(Track track, Consumer<OpenTrack> callback) {
@@ -242,7 +244,7 @@ public <T> T request(String url, Class<?> clazz, boolean canGenerateNewAccessTok
242244

243245
// Read response
244246
JsonReader reader = new JsonReader(new InputStreamReader(connection.getInputStream()));
245-
return new Gson().fromJson(reader, clazz);
247+
return GSON.fromJson(reader, clazz);
246248
}
247249

248250
public Cache<BufferedImage> getImageCache() {

0 commit comments

Comments
 (0)