summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/isode/stroke/jid/JID.java13
-rw-r--r--test/com/isode/stroke/jid/JIDTest.java10
2 files changed, 15 insertions, 8 deletions
diff --git a/src/com/isode/stroke/jid/JID.java b/src/com/isode/stroke/jid/JID.java
index 59eef52..8b62ca1 100644
--- a/src/com/isode/stroke/jid/JID.java
+++ b/src/com/isode/stroke/jid/JID.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012, Isode Limited, London, England.
+ * Copyright (c) 2010-2016, Isode Limited, London, England.
* All rights reserved.
*/
/*
@@ -14,13 +14,13 @@
package com.isode.stroke.jid;
-import com.isode.stroke.idn.ICUConverter;
-import com.isode.stroke.idn.IDNConverter;
-import com.ibm.icu.text.StringPrepParseException;
-import com.isode.stroke.base.NotNull;
import java.util.Arrays;
import java.util.List;
+import com.isode.stroke.base.NotNull;
+import com.isode.stroke.idn.ICUConverter;
+import com.isode.stroke.idn.IDNConverter;
+
/**
* JID helper.
*
@@ -147,6 +147,9 @@ public class JID implements Comparable<JID> {
NotNull.exceptIfNull(domain, "domain");
valid_ = true;
hasResource_ = (resource != null);
+ if (hasResource_ && resource.isEmpty()) {
+ valid_ = false;
+ }
nameprepAndSetComponents(node, domain, resource);
}
diff --git a/test/com/isode/stroke/jid/JIDTest.java b/test/com/isode/stroke/jid/JIDTest.java
index 96de429..69bee05 100644
--- a/test/com/isode/stroke/jid/JIDTest.java
+++ b/test/com/isode/stroke/jid/JIDTest.java
@@ -12,12 +12,10 @@
package com.isode.stroke.jid;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
-import com.isode.stroke.jid.JID;
public class JIDTest {
@@ -155,6 +153,12 @@ public class JIDTest {
assertFalse(testling.isValid());
}
+
+ @Test
+ public void testConstructorWithStrings_EmptyResource() {
+ JID testling = new JID("foo","bar","");
+ assertFalse(testling.isValid());
+ }
@Test