From 9c694a0a75e872071f585d8ab6a6d54b5935f9be Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 23 Sep 2015 23:21:37 +0200 Subject: [PATCH] Code cleanup: Fix some warnings --- .../org/jivesoftware/smack/proxy/ProxyException.java | 5 ----- .../smack/proxy/Socks5ProxySocketConnection.java | 11 +++-------- .../org/jivesoftware/smackx/amp/AMPExtensionTest.java | 4 ++-- .../socks5/Socks5ClientForInitiatorTest.java | 4 ++-- .../smackx/bytestreams/socks5/Socks5TestProxy.java | 2 +- .../jivesoftware/smackx/pubsub/ConfigureFormTest.java | 3 +-- .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 2 +- 7 files changed, 10 insertions(+), 21 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java index 66be3b7b6..ccf0f9b25 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java @@ -29,11 +29,6 @@ public class ProxyException extends IOException { */ private static final long serialVersionUID = 1L; - public ProxyException(ProxyInfo.ProxyType type, String ex, Throwable cause) - { - super("Proxy Exception " + type.toString() + " : "+ex+", "+cause); - } - public ProxyException(ProxyInfo.ProxyType type, String ex) { super("Proxy Exception " + type.toString() + " : "+ex); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java index 4d71559d3..85584ad2a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java @@ -305,17 +305,12 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { catch(Exception eee) { } - String message="ProxySOCKS5: "+e.toString(); - if(e instanceof Throwable) - { - throw new ProxyException(ProxyInfo.ProxyType.SOCKS5,message, - (Throwable)e); - } - throw new IOException(message); + // TODO convert to IOException(e) when minimum Android API level is 9 or higher + throw new IOException(e.getLocalizedMessage()); } } - private void fill(InputStream in, byte[] buf, int len) + private static void fill(InputStream in, byte[] buf, int len) throws IOException { int s=0; diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java index 9b343c5a4..f3ed17db4 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java @@ -37,7 +37,7 @@ public class AMPExtensionTest { private InputStream INCORRECT_RECEIVING_STANZA_STREAM; @Before - public void setUp() throws IOException { + public void setUp() { CORRECT_SENDING_STANZA_STREAM = getClass().getResourceAsStream("correct_stanza_test.xml"); INCORRECT_RECEIVING_STANZA_STREAM = getClass().getResourceAsStream("incorrect_stanza_test.xml"); } @@ -97,7 +97,7 @@ public class AMPExtensionTest { } - private String toString(InputStream stream) throws IOException { + private static String toString(InputStream stream) throws IOException { byte[] data = new byte[stream.available()]; stream.read(data); stream.close(); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiatorTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiatorTest.java index 216f30f4f..66b3f3713 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiatorTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiatorTest.java @@ -214,7 +214,7 @@ public class Socks5ClientForInitiatorTest { socks5Proxy.start(); StreamHost streamHost = new StreamHost(proxyJID, - socks5Proxy.getAddress(), socks5Proxy.getPort()); + Socks5TestProxy.getAddress(), socks5Proxy.getPort()); // create digest to get the socket opened by target String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); @@ -267,7 +267,7 @@ public class Socks5ClientForInitiatorTest { socks5Proxy.start(); StreamHost streamHost = new StreamHost(proxyJID, - socks5Proxy.getAddress(), socks5Proxy.getPort()); + Socks5TestProxy.getAddress(), socks5Proxy.getPort()); // create digest to get the socket opened by target String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5TestProxy.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5TestProxy.java index 53bfa3fb2..64d696f9b 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5TestProxy.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5TestProxy.java @@ -146,7 +146,7 @@ public final class Socks5TestProxy { * * @return the host address of the local SOCKS5 proxy server */ - public String getAddress() { + public static String getAddress() { try { return InetAddress.getLocalHost().getHostAddress(); } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index 6c116f643..f6b151f58 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -33,7 +33,6 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.junit.Assert; import org.junit.Test; -import org.jxmpp.stringprep.XmppStringprepException; /** * Configure form test. @@ -78,7 +77,7 @@ public class ConfigureFormTest } @Test (expected=SmackException.class) - public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException, XmppStringprepException + public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException { ThreadedDummyConnection con = new ThreadedDummyConnection(); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 4cc705fc6..0b1150fe5 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -746,7 +746,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { * @return a instance of XMPPInputOutputStream or null if no suitable instance was found * */ - private XMPPInputOutputStream maybeGetCompressionHandler(Compress.Feature compression) { + private static XMPPInputOutputStream maybeGetCompressionHandler(Compress.Feature compression) { for (XMPPInputOutputStream handler : SmackConfiguration.getCompresionHandlers()) { String method = handler.getCompressionMethod(); if (compression.getMethods().contains(method))