diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransport.java index 644234fc5..f39248eea 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransport.java @@ -41,6 +41,7 @@ public class JingleS5BTransport extends JingleContentTransport { protected JingleS5BTransport(List candidates, List infos, String streamId, String dstAddr, Bytestream.Mode mode) { super(candidates, infos); + StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty."); this.streamId = streamId; this.dstAddr = dstAddr; this.mode = mode; @@ -137,7 +138,6 @@ public class JingleS5BTransport extends JingleContentTransport { } public JingleS5BTransport build() { - StringUtils.requireNotNullOrEmpty(streamId, "sid MUST be neither null, nor empty."); return new JingleS5BTransport(candidates, infos, streamId, dstAddr, mode); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransportCandidate.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransportCandidate.java index 6b5ae329f..ac0d529e5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransportCandidate.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/elements/JingleS5BTransportCandidate.java @@ -49,6 +49,14 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan private final Type type; public JingleS5BTransportCandidate(String candidateId, String host, Jid jid, int port, int priority, Type type) { + + Objects.requireNonNull(candidateId); + Objects.requireNonNull(host); + Objects.requireNonNull(jid); + if (priority < 0) { + throw new IllegalArgumentException("Priority MUST be present and NOT less than 0."); + } + this.cid = candidateId; this.host = host; this.jid = jid; @@ -58,12 +66,7 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan } public JingleS5BTransportCandidate(Bytestream.StreamHost streamHost, int priority) { - this.cid = StringUtils.randomString(24); - this.host = streamHost.getAddress(); - this.jid = streamHost.getJID(); - this.port = streamHost.getPort(); - this.priority = priority; - this.type = Type.proxy; + this(StringUtils.randomString(24), streamHost.getAddress(), streamHost.getJID(), streamHost.getPort(), priority, Type.proxy); } public enum Type { @@ -190,12 +193,6 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan } public JingleS5BTransportCandidate build() { - Objects.requireNonNull(cid); - Objects.requireNonNull(host); - Objects.requireNonNull(jid); - if (priority < 0) { - throw new IllegalArgumentException("Priority MUST be present and NOT less than 0."); - } return new JingleS5BTransportCandidate(cid, host, jid, port, priority, type); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/provider/JingleS5BTransportProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/provider/JingleS5BTransportProvider.java index 7eae12861..494e68aae 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/provider/JingleS5BTransportProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/provider/JingleS5BTransportProvider.java @@ -55,58 +55,63 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider