Merge pull request #1442 from obfusk/usages-len

StocardImporter: check usages is not empty just in case
This commit is contained in:
Sylvia van Os
2023-07-23 21:57:48 +02:00
committed by GitHub

View File

@@ -230,16 +230,18 @@ public class StocardImporter implements Importer {
);
} else if (fileName.endsWith("usage-statistics/content.json")) {
JSONArray usages = ZipUtils.readJSON(zipInputStream).getJSONArray("usages");
JSONObject lastUsedObject = usages.getJSONObject(usages.length() - 1);
String lastUsedString = lastUsedObject.getJSONObject("time").getString("value");
long timeStamp = Instant.parse(lastUsedString).getEpochSecond();
if (usages.length() > 0) {
JSONObject lastUsedObject = usages.getJSONObject(usages.length() - 1);
String lastUsedString = lastUsedObject.getJSONObject("time").getString("value");
long timeStamp = Instant.parse(lastUsedString).getEpochSecond();
loyaltyCardHashMap = appendToHashMap(
loyaltyCardHashMap,
cardName,
"lastUsed",
timeStamp
);
loyaltyCardHashMap = appendToHashMap(
loyaltyCardHashMap,
cardName,
"lastUsed",
timeStamp
);
}
} else if (fileName.endsWith("/images/front.png") || fileName.endsWith("/images/front/front.jpg")) {
loyaltyCardHashMap = appendToHashMap(
loyaltyCardHashMap,