Skip to content

Commit 99acf07

Browse files
author
Damian Staszewski
committed
fixing sessionId NullPointException
1 parent 0751e12 commit 99acf07

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/pl/stachu540/hirezstudios/games/HiRezGames.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HiRezGames extends API {
2121

2222
private final String devId;
2323
private final String authKey;
24-
private String sessionId;
24+
private String sessionId = "";
2525

2626
/**
2727
* Hi-Rez Studios API for Smite and Paladins games
@@ -74,6 +74,7 @@ private String getSignature(String method, String timestamp) {
7474
* @param args arguments in the correct order
7575
* @return data object in {@link JSONObject}
7676
*/
77+
// TODO: testSession() is looping while he throwing StackOverflowError exception
7778
JSONObject catchData(String endpoint, String... args) {
7879
if (!sessionId.isEmpty()) {
7980
JSONObject test = testSession();
@@ -93,7 +94,10 @@ private void createSession() {
9394
String timestamp = getTimestamp();
9495
String signature = getSignature("createsession", timestamp);
9596
JSONObject ses = getData(requestType.GET, "/createsessionJson/" + devId + "/" + signature + "/" + timestamp);
96-
if (ses.getJSONObject("data").getInt("responseCode") == 200 && ses.getJSONObject("content").getString("ret_msg").equals("Approved")) sessionId = ses.getJSONObject("content").getString("session_id");
97+
if (
98+
ses.getJSONObject("data").getInt("responseCode") == 200 &&
99+
ses.getJSONObject("content").getString("ret_msg").equals("Approved")
100+
) sessionId = ses.getJSONObject("content").getString("session_id");
97101
}
98102

99103
/**

0 commit comments

Comments
 (0)