From c89121fc5fdc2999654ea9ad2f7a0c82d50ac74d Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Thu, 14 Jan 2021 15:08:50 +0100 Subject: [PATCH] Fix IllegalArgumentException fo UUID.fromString --- src/main/java/tsp/headdb/database/HeadDatabase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/tsp/headdb/database/HeadDatabase.java b/src/main/java/tsp/headdb/database/HeadDatabase.java index 1b75f49..d9b6190 100644 --- a/src/main/java/tsp/headdb/database/HeadDatabase.java +++ b/src/main/java/tsp/headdb/database/HeadDatabase.java @@ -126,9 +126,11 @@ public class HeadDatabase { JSONArray array = (JSONArray) parser.parse(response.toString()); for (Object o : array) { JSONObject obj = (JSONObject) o; + String uuid = obj.get("uuid").toString(); + Head head = new Head(id) .withName(obj.get("name").toString()) - .withUUID(UUID.fromString(obj.get("uuid").toString())) + .withUUID(uuid.isEmpty() ? UUID.randomUUID() : UUID.fromString(uuid)) .withValue(obj.get("value").toString()) .withCategory(category);