Improve InvalidJidException handling in Jid class

Andreas Straub created

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.

Change summary

src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

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");
 		}
 	}