From f80472e082f9394bb49829df901f3a82558c93a7 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Fri, 16 Jun 2017 23:45:00 +0200 Subject: [PATCH 1/2] Fix reviewed points --- .../elements/JingleS5BTransport.java | 2 +- .../elements/JingleS5BTransportCandidate.java | 21 ++--- .../provider/JingleS5BTransportProvider.java | 89 ++++++++++--------- 3 files changed, 57 insertions(+), 55 deletions(-) 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 Date: Sun, 18 Jun 2017 12:08:47 +0200 Subject: [PATCH 2/2] Reorder imports --- .../jingle_s5b/elements/JingleS5BTransportCandidate.java | 1 + .../jingle_s5b/provider/JingleS5BTransportProvider.java | 1 + .../jingle/transports/jingle_s5b/JingleS5BTransportTest.java | 1 + 3 files changed, 3 insertions(+) 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 ac0d529e5..284fc72e9 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 @@ -23,6 +23,7 @@ import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate; + import org.jxmpp.jid.Jid; import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.stringprep.XmppStringprepException; 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 494e68aae..fcd99cfa9 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 @@ -32,6 +32,7 @@ import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo; + import org.xmlpull.v1.XmlPullParser; /** diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportTest.java index 057f622ea..d6504e4de 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transports/jingle_s5b/JingleS5BTransportTest.java @@ -26,6 +26,7 @@ import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTr import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.provider.JingleS5BTransportProvider; + import org.junit.Test; import org.jxmpp.jid.impl.JidCreate;