X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSoneShell.java;h=8d8690acefbb8815ffb9e86f001111d4b9fb5d03;hb=60e05f5839cc3c00610d861a24003781c3040e11;hp=cced1e5e631c4a3933d126cfbbf6526e988bf0e5;hpb=cd5e2259ab672c714a8fe2b632da670e30dee090;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/SoneShell.java b/src/main/java/net/pterodactylus/sone/data/SoneShell.java index cced1e5..8d8690a 100644 --- a/src/main/java/net/pterodactylus/sone/data/SoneShell.java +++ b/src/main/java/net/pterodactylus/sone/data/SoneShell.java @@ -23,7 +23,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; /** @@ -33,12 +36,15 @@ import freenet.keys.FreenetURI; */ public class SoneShell extends Sone implements Shell { + /** The logger. */ + private static final Logger logger = Logging.getLogger(SoneShell.class); + /** The shell creator. */ public static final ShellCreator creator = new ShellCreator() { @Override public Shell createShell(String id) { - return new SoneShell().setId(UUID.fromString(id)); + return new SoneShell().setId(id); } }; @@ -91,8 +97,13 @@ public class SoneShell extends Sone implements Shell { * The ID of the Sone * @return This Sone shell (for method chaining) */ - public SoneShell setId(UUID id) { - this.id = id; + public SoneShell setId(String id) { + try { + this.id = UUID.fromString(id); + } catch (IllegalArgumentException iae1) { + logger.log(Level.WARNING, "Invalid ID: “" + id + "”.", iae1); + this.id = UUID.randomUUID(); + } return this; }