From a7c7a421365dc637e44a956c2be112118a752bc3 Mon Sep 17 00:00:00 2001 From: Andreas Straub Date: Sun, 11 Oct 2015 16:01:03 +0200 Subject: [PATCH] Improve InvalidJidException handling in Jid class This code should never be triggered anway, so with this 'fix', we should at least get more meaningful stack traces. Plus, it makes the linter happy by preventing NullPointerExceptions. --- src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java index f989c0c25..a15abe14a 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java @@ -176,7 +176,7 @@ public final class Jid { return resourcepart.isEmpty() ? this : fromParts(localpart, domainpart, ""); } catch (final InvalidJidException e) { // This should never happen. - return null; + throw new AssertionError("Jid " + this.toString() + " invalid"); } } @@ -185,7 +185,7 @@ public final class Jid { return resourcepart.isEmpty() && localpart.isEmpty() ? this : fromString(getDomainpart()); } catch (final InvalidJidException e) { // This should never happen. - return null; + throw new AssertionError("Jid " + this.toString() + " invalid"); } }