From b2221d548306fad68d00e7e2ea61745118969632 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 17 Mar 2015 21:19:06 +0100 Subject: [PATCH] Add more checkstyle tests - Lines containing tab(s) after space - Usage of printStackTrace - Usage of println - Add SupressionCommentFilter module SuppressionCommentFilter can be enabled with // CHECKSTYLE:OFF and disabled with // CHECKSTYLE:ON --- config/checkstyle.xml | 16 ++++++++ .../debugger/android/AndroidDebugger.java | 5 +++ .../jivesoftware/smack/PacketCollector.java | 2 + .../smack/debugger/AbstractDebugger.java | 8 ++-- .../smack/debugger/ConsoleDebugger.java | 14 +++++++ .../smack/debugger/JulDebugger.java | 5 +++ .../smack/util/PacketParserUtils.java | 6 +++ .../jivesoftware/smack/DummyConnection.java | 10 ----- .../smack/ThreadedDummyConnection.java | 8 +++- .../smack/util/PacketParserUtilsTest.java | 6 +++ .../smackx/debugger/EnhancedDebugger.java | 6 ++- .../smackx/privacy/packet/Privacy.java | 35 +++++++++++++++- .../smackx/privacy/packet/PrivacyItem.java | 27 +++++++++++++ .../privacy/provider/PrivacyProvider.java | 8 ++++ .../org/jivesoftware/smackx/pubsub/Item.java | 2 + .../bytestreams/socks5/Socks5TestProxy.java | 13 +++--- .../java/org/jivesoftware/util/Protocol.java | 2 + .../jivesoftware/smack/chat/ChatManager.java | 2 + .../rosterstore/DirectoryRosterStore.java | 16 +++----- .../jivesoftware/smack/roster/RosterTest.java | 19 --------- .../smackx/jingle/mediaimpl/demo/Demo.java | 4 +- .../smackx/jingle/JingleManagerTest.java | 36 ++++++++--------- .../smackx/jingle/JingleMediaTest.java | 40 +++++++++---------- .../jingle/nat/BridgedResolverTest.java | 2 +- .../smackx/jingle/nat/STUNResolverTest.java | 10 ++--- .../jingle/nat/TransportResolverTest.java | 2 +- .../smackx/jingleold/JingleManager.java | 13 +++--- .../smackx/jingleold/JingleNegotiator.java | 3 +- .../smackx/jingleold/JingleSession.java | 15 +++++-- .../jingleold/JingleSessionStateActive.java | 7 +++- .../jingleold/JingleSessionStatePending.java | 7 +++- .../jingleold/JingleSessionStateUnknown.java | 9 ++++- .../jingleold/mediaimpl/jmf/AudioChannel.java | 21 +++++----- .../mediaimpl/jmf/AudioMediaSession.java | 5 ++- .../mediaimpl/jmf/JmfMediaManager.java | 4 +- .../mediaimpl/jspeex/AudioMediaSession.java | 15 +++---- .../mediaimpl/jspeex/SpeexMediaManager.java | 4 +- .../mediaimpl/sshare/ScreenShareSession.java | 9 +++-- .../mediaimpl/sshare/api/DefaultEncoder.java | 6 ++- .../mediaimpl/sshare/api/ImageReceiver.java | 11 +++-- .../sshare/api/ImageTransmitter.java | 9 +++-- .../smackx/jingleold/nat/BasicResolver.java | 9 +++-- .../smackx/jingleold/nat/BridgedResolver.java | 7 +++- .../smackx/jingleold/nat/HttpServer.java | 4 +- .../smackx/jingleold/nat/ICECandidate.java | 5 ++- .../smackx/jingleold/nat/ICEResolver.java | 21 +++++----- .../jingleold/nat/ICETransportManager.java | 8 +++- .../smackx/jingleold/nat/RTPBridge.java | 3 +- .../jingleold/nat/STUNTransportManager.java | 9 ++++- .../jingleold/nat/TcpUdpBridgeClient.java | 7 ++-- .../jingleold/nat/TcpUdpBridgeServer.java | 7 ++-- .../jingleold/nat/TransportCandidate.java | 21 ++++++---- .../jingleold/nat/TransportNegotiator.java | 9 +++-- .../jingleold/nat/TransportResolver.java | 7 ++-- .../workgroup/ext/macros/MacroGroup.java | 4 +- .../smackx/workgroup/ext/macros/Macros.java | 11 ++++- .../smackx/workgroup/user/Workgroup.java | 4 ++ .../provider/RosterExchangeProvider.java | 4 +- .../provider/ParseStreamManagementTest.java | 2 - 59 files changed, 382 insertions(+), 202 deletions(-) diff --git a/config/checkstyle.xml b/config/checkstyle.xml index 41dfb16cf..26c368ba2 100644 --- a/config/checkstyle.xml +++ b/config/checkstyle.xml @@ -6,6 +6,7 @@ + @@ -22,6 +23,10 @@ + + + + + @@ -40,5 +46,15 @@ + + + + + + + + + + diff --git a/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java b/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java index d164c943d..201f4e6fb 100644 --- a/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java +++ b/smack-android/src/main/java/org/jivesoftware/smackx/debugger/android/AndroidDebugger.java @@ -45,4 +45,9 @@ public class AndroidDebugger extends AbstractDebugger { protected void log(String logMessage) { Log.d("SMACK", logMessage); } + + @Override + protected void log(String logMessage, Throwable throwable) { + Log.d("SMACK", logMessage, throwable); + } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java index 7130489f7..c82bc713f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java @@ -244,10 +244,12 @@ public class PacketCollector { */ protected void processPacket(Stanza packet) { if (packetFilter == null || packetFilter.accept(packet)) { + // CHECKSTYLE:OFF while (!resultQueue.offer(packet)) { // Since we know the queue is full, this poll should never actually block. resultQueue.poll(); } + // CHECKSTYLE:ON if (collectorToReset != null) { collectorToReset.waitStart = System.currentTimeMillis(); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java index 8909eae92..3315ac2ae 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java @@ -98,15 +98,13 @@ public abstract class AbstractDebugger implements SmackDebugger { log( "XMPPConnection closed due to an exception (" + connection.getConnectionCounter() + - ")"); - e.printStackTrace(); + ")", e); } public void reconnectionFailed(Exception e) { log( "Reconnection failed due to an exception (" + connection.getConnectionCounter() + - ")"); - e.printStackTrace(); + ")", e); } public void reconnectionSuccessful() { log( @@ -125,6 +123,8 @@ public abstract class AbstractDebugger implements SmackDebugger { protected abstract void log(String logMessage); + protected abstract void log(String logMessage, Throwable throwable); + public Reader newConnectionReader(Reader newReader) { reader.removeReaderListener(readerListener); ObservableReader debugReader = new ObservableReader(newReader); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java index 871a2b454..1889ea3bc 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java @@ -18,7 +18,9 @@ package org.jivesoftware.smack.debugger; import org.jivesoftware.smack.XMPPConnection; +import java.io.PrintWriter; import java.io.Reader; +import java.io.StringWriter; import java.io.Writer; import java.text.SimpleDateFormat; import java.util.Date; @@ -47,7 +49,19 @@ public class ConsoleDebugger extends AbstractDebugger { synchronized (dateFormatter) { formatedDate = dateFormatter.format(new Date()); } + // CHECKSTYLE:OFF System.out.println(formatedDate + ' ' + logMessage); + // CHECKSTYLE:ON + } + + @Override + protected void log(String logMessage, Throwable throwable) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + // CHECKSTYLE:OFF + throwable.printStackTrace(pw); + // CHECKSTYLE:ON + log(logMessage + sw); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/JulDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/JulDebugger.java index defc1d4a9..d1eddbd38 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/JulDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/JulDebugger.java @@ -20,6 +20,7 @@ import org.jivesoftware.smack.XMPPConnection; import java.io.Reader; import java.io.Writer; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -46,4 +47,8 @@ public class JulDebugger extends AbstractDebugger { LOGGER.fine(logMessage); } + @Override + protected void log(String logMessage, Throwable throwable) { + LOGGER.log(Level.FINE, logMessage, throwable); + } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index c2fc7a49b..6556cc7a3 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -528,7 +528,9 @@ public class PacketParserUtils { String language = getLanguageAttribute(parser); if (language != null && !"".equals(language.trim())) { + // CHECKSTYLE:OFF presence.setLanguage(language); + // CHECKSTYLE:ON } // Parse sub-elements @@ -993,15 +995,19 @@ public class PacketParserUtils { } private static String getLanguageAttribute(XmlPullParser parser) { + // CHECKSTYLE:OFF for (int i = 0; i < parser.getAttributeCount(); i++) { + // CHECKSTYLE:ON String attributeName = parser.getAttributeName(i); if ( "xml:lang".equals(attributeName) || ("lang".equals(attributeName) && "xml".equals(parser.getAttributePrefix(i)))) { + // CHECKSTYLE:OFF return parser.getAttributeValue(i); } } return null; + // CHECKSTYLE:ON } @Deprecated diff --git a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java index b6354ff11..c6596d509 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java @@ -134,17 +134,11 @@ public class DummyConnection extends AbstractXMPPConnection { @Override public void send(PlainStreamElement element) { - if (SmackConfiguration.DEBUG) { - System.out.println("[SEND]: " + element.toXML()); - } queue.add(element); } @Override protected void sendStanzaInternal(Stanza packet) { - if (SmackConfiguration.DEBUG) { - System.out.println("[SEND]: " + packet.toXML()); - } queue.add(packet); } @@ -194,10 +188,6 @@ public class DummyConnection extends AbstractXMPPConnection { * @param packet the packet to process. */ public void processPacket(Stanza packet) { - if (SmackConfiguration.DEBUG) { - System.out.println("[RECV]: " + packet.toXML()); - } - invokePacketCollectorsAndNotifyRecvListeners(packet); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java b/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java index eca491d10..eed8bec30 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import java.util.logging.Level; +import java.util.logging.Logger; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.packet.IQ; @@ -33,6 +35,8 @@ import org.jivesoftware.smack.packet.IQ.Type; * */ public class ThreadedDummyConnection extends DummyConnection { + private static final Logger LOGGER = Logger.getLogger(ThreadedDummyConnection.class.getName()); + private BlockingQueue replyQ = new ArrayBlockingQueue(1); private BlockingQueue messageQ = new LinkedBlockingQueue(5); private volatile boolean timeout = false; @@ -82,7 +86,7 @@ public class ThreadedDummyConnection extends DummyConnection { if (!messageQ.isEmpty()) new ProcessQueue(messageQ).start(); else - System.out.println("No messages to process"); + LOGGER.warning("No messages to process"); } class ProcessQueue extends Thread { @@ -97,7 +101,7 @@ public class ThreadedDummyConnection extends DummyConnection { try { processPacket(processQ.take()); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java index d74cade34..2ee340ccd 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java @@ -754,25 +754,30 @@ public class PacketParserUtilsTest { @Test public void validateSimplePresence() throws Exception { + // CHECKSTYLE:OFF String stanza = ""; Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); assertXMLEqual(stanza, presence.toXML().toString()); + // CHECKSTYLE:ON } @Test public void validatePresenceProbe() throws Exception { + // CHECKSTYLE:OFF String stanza = ""; Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); assertXMLEqual(stanza, presence.toXML().toString()); assertEquals(Presence.Type.unsubscribed, presence.getType()); + // CHECKSTYLE:ON } @Test public void validatePresenceOptionalElements() throws Exception { + // CHECKSTYLE:OFF String stanza = "" + "dnd" + "Wooing Juliet" @@ -786,6 +791,7 @@ public class PacketParserUtilsTest { assertEquals("en", presence.getLanguage()); assertEquals("Wooing Juliet", presence.getStatus()); assertEquals(1, presence.getPriority()); + // CHECKSTYLE:ON } @Test diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java index 50aa52fd3..b7cd1d69a 100644 --- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java +++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java @@ -289,8 +289,10 @@ public class EnhancedDebugger implements SmackDebugger { new DefaultTableModel( new Object[]{"Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From"}, 0) { + // CHECKSTYLE:OFF private static final long serialVersionUID = 8136121224474217264L; public boolean isCellEditable(int rowIndex, int mColIndex) { + // CHECKSTYLE:ON return false; } @@ -583,7 +585,7 @@ public class EnhancedDebugger implements SmackDebugger { connection.sendStanza(packetToSend); } catch (InterruptedException | NotConnectedException e1) { - e1.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -704,8 +706,10 @@ public class EnhancedDebugger implements SmackDebugger { new DefaultTableModel(new Object[][]{{"IQ", 0, 0}, {"Message", 0, 0}, {"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}}, new Object[]{"Type", "Received", "Sent"}) { + // CHECKSTYLE:OFF private static final long serialVersionUID = -6793886085109589269L; public boolean isCellEditable(int rowIndex, int mColIndex) { + // CHECKSTYLE:ON return false; } }; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/Privacy.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/Privacy.java index b4ec7edc5..be45b3992 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/Privacy.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/Privacy.java @@ -93,11 +93,15 @@ public class Privacy extends IQ { */ public void deletePrivacyList(String listName) { // Remove the list from the cache + // CHECKSTYLE:OFF this.getItemLists().remove(listName); + // CHECKSTYLE:ON // Check if deleted list was the default list if (this.getDefaultName() != null && listName.equals(this.getDefaultName())) { + // CHECKSTYLE:OFF this.setDefaultName(null); + // CHECKSTYLE:ON } } @@ -108,11 +112,13 @@ public class Privacy extends IQ { */ public List getActivePrivacyList() { // Check if we have the default list + // CHECKSTYLE:OFF if (this.getActiveName() == null) { return null; } else { return this.getItemLists().get(this.getActiveName()); } + // CHECKSTYLE:ON } /** @@ -122,11 +128,13 @@ public class Privacy extends IQ { */ public List getDefaultPrivacyList() { // Check if we have the default list + // CHECKSTYLE:OFF if (this.getDefaultName() == null) { return null; } else { return this.getItemLists().get(this.getDefaultName()); } + // CHECKSTYLE:ON } /** @@ -147,6 +155,7 @@ public class Privacy extends IQ { * @return a List with {@link PrivacyItem} */ public PrivacyItem getItem(String listName, int order) { + // CHECKSTYLE:OFF Iterator values = getPrivacyList(listName).iterator(); PrivacyItem itemFound = null; while (itemFound == null && values.hasNext()) { @@ -156,6 +165,7 @@ public class Privacy extends IQ { } } return itemFound; + // CHECKSTYLE:ON } /** @@ -169,7 +179,9 @@ public class Privacy extends IQ { this.setDefaultName(newDefault); return true; } else { + // CHECKSTYLE:OFF return false; + // CHECKSTYLE:ON } } @@ -179,7 +191,9 @@ public class Privacy extends IQ { * @param listName name of the list to remove. */ public void deleteList(String listName) { + // CHECKSTYLE:OFF this.getItemLists().remove(listName); + // CHECKSTYLE:ON } /** @@ -188,9 +202,11 @@ public class Privacy extends IQ { * * @return the name of the active list. */ + // CHECKSTYLE:OFF public String getActiveName() { return activeName; } + // CHECKSTYLE:ON /** * Sets the name associated with the active list set for the session. Communications @@ -198,9 +214,11 @@ public class Privacy extends IQ { * * @param activeName is the name of the active list. */ + // CHECKSTYLE:OFF public void setActiveName(String activeName) { this.activeName = activeName; } + // CHECKSTYLE:ON /** * Returns the name of the default list that applies to the user as a whole. Default list is @@ -209,9 +227,11 @@ public class Privacy extends IQ { * * @return the name of the default list. */ + // CHECKSTYLE:OFF public String getDefaultName() { return defaultName; } + // CHECKSTYLE:ON /** * Sets the name of the default list that applies to the user as a whole. Default list is @@ -222,9 +242,11 @@ public class Privacy extends IQ { * * @param defaultName is the name of the default list. */ + // CHECKSTYLE:OFF public void setDefaultName(String defaultName) { this.defaultName = defaultName; } + // CHECKSTYLE:ON /** * Returns the collection of privacy list that the user holds. A Privacy List contains a set of @@ -234,42 +256,51 @@ public class Privacy extends IQ { * @return a map where the key is the name of the list and the value the * collection of privacy items. */ + // CHECKSTYLE:OFF public Map> getItemLists() { return itemLists; } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or declines the use of an active list. * * @return the decline status of the list. */ + // CHECKSTYLE:OFF public boolean isDeclineActiveList() { return declineActiveList; } + // CHECKSYTLE:ON /** * Sets whether the receiver allows or declines the use of an active list. * * @param declineActiveList indicates if the receiver declines the use of an active list. */ + // CHECKSTYLE:OFF public void setDeclineActiveList(boolean declineActiveList) { this.declineActiveList = declineActiveList; } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or declines the use of a default list. * * @return the decline status of the list. */ + // CHECKSTYLE:OFF public boolean isDeclineDefaultList() { return declineDefaultList; } + // CHECKSTYLE:ON /** * Sets whether the receiver allows or declines the use of a default list. * * @param declineDefaultList indicates if the receiver declines the use of a default list. */ + // CHECKSTYLE:OFF public void setDeclineDefaultList(boolean declineDefaultList) { this.declineDefaultList = declineDefaultList; } @@ -282,10 +313,12 @@ public class Privacy extends IQ { public Set getPrivacyListNames() { return this.itemLists.keySet(); } + // CHECKSTYLE:ON @Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) { buf.rightAngleBracket(); + // CHECKSTYLE:OFF // Add the active tag if (this.isDeclineActiveList()) { @@ -323,7 +356,7 @@ public class Privacy extends IQ { buf.append(""); } } - + // CHECKSTYLE:ON return buf; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java index 93a38dee8..07d1b959c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/PrivacyItem.java @@ -131,8 +131,10 @@ public class PrivacyItem { * @return the allow communication status. */ public boolean isAllow() { + // CHECKSTYLE:OFF return allow; } + // CHECKSTYLE:ON /** * Returns whether the receiver allow or deny incoming IQ stanzas or not. @@ -140,8 +142,10 @@ public class PrivacyItem { * @return the iq filtering status. */ public boolean isFilterIQ() { + // CHECKSTYLE:OFF return filterIQ; } + // CHECKSTYLE:ON /** * Sets whether the receiver allows or denies incoming IQ stanzas or not. @@ -149,8 +153,11 @@ public class PrivacyItem { * @param filterIQ indicates if the receiver allows or denies incoming IQ stanzas. */ public void setFilterIQ(boolean filterIQ) { + // CHECKSTYLE:OFF + this.filterIQ = filterIQ; } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or denies incoming messages or not. @@ -158,8 +165,10 @@ public class PrivacyItem { * @return the message filtering status. */ public boolean isFilterMessage() { + // CHECKSTYLE:OFF return filterMessage; } + // CHECKSTYLE:ON /** * Sets wheather the receiver allows or denies incoming messages or not. @@ -167,8 +176,10 @@ public class PrivacyItem { * @param filterMessage indicates if the receiver allows or denies incoming messages or not. */ public void setFilterMessage(boolean filterMessage) { + // CHECKSTYLE:OFF this.filterMessage = filterMessage; } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or denies incoming presence or not. @@ -176,8 +187,10 @@ public class PrivacyItem { * @return the iq filtering incoming presence status. */ public boolean isFilterPresenceIn() { + // CHECKSTYLE:OFF return filterPresenceIn; } + // CHECKSTYLE:ON /** * Sets whether the receiver allows or denies incoming presence or not. @@ -185,8 +198,10 @@ public class PrivacyItem { * @param filterPresenceIn indicates if the receiver allows or denies filtering incoming presence. */ public void setFilterPresenceIn(boolean filterPresenceIn) { + // CHECKSTYLE:OFF this.filterPresenceIn = filterPresenceIn; } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or denies incoming presence or not. @@ -194,8 +209,10 @@ public class PrivacyItem { * @return the iq filtering incoming presence status. */ public boolean isFilterPresenceOut() { + // CHECKSTYLE:OFF return filterPresenceOut; } + // CHECKSTYLE:ON /** * Sets whether the receiver allows or denies outgoing presence or not. @@ -203,8 +220,10 @@ public class PrivacyItem { * @param filterPresenceOut indicates if the receiver allows or denies filtering outgoing presence */ public void setFilterPresenceOut(boolean filterPresenceOut) { + // CHECKSTYLE:OFF this.filterPresenceOut = filterPresenceOut; } + // CHECKSTYLE:ON /** * Returns the order where the receiver is processed. List items are processed in @@ -216,8 +235,10 @@ public class PrivacyItem { * @return the order number. */ public long getOrder() { + // CHECKSTYLE:OFF return order; } + // CHECKSTYLE:ON /** * Returns the type hold the kind of communication it will allow or block. @@ -227,7 +248,9 @@ public class PrivacyItem { */ public Type getType() { return type; + // CHECKSTYLE:OFF } + // CHECKSTYLE:ON /** * Returns the element identifier to apply the action. @@ -242,7 +265,9 @@ public class PrivacyItem { */ public String getValue() { return value; + // CHECKSTYLE:OFF } + // CHECKSTYLE:ON /** * Returns whether the receiver allows or denies every kind of communication. @@ -253,6 +278,7 @@ public class PrivacyItem { * @return the all communications status. */ public boolean isFilterEverything() { + // CHECKSTYLE:OFF return !(this.isFilterIQ() || this.isFilterMessage() || this.isFilterPresenceIn() || this.isFilterPresenceOut()); } @@ -295,6 +321,7 @@ public class PrivacyItem { } buf.append(""); } + // CHECKSTYLE:ON return buf.toString(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java index 8a54c9347..ac6a8e523 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java @@ -45,6 +45,7 @@ public class PrivacyProvider extends IQProvider { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { + // CHECKSTYLE:OFF if (parser.getName().equals("active")) { String activeName = parser.getAttributeValue("", "name"); if (activeName == null) { @@ -61,6 +62,7 @@ public class PrivacyProvider extends IQProvider { privacy.setDefaultName(defaultName); } } + // CHECKSTYLE:ON else if (parser.getName().equals("list")) { parseList(parser, privacy); } @@ -84,7 +86,9 @@ public class PrivacyProvider extends IQProvider { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("item")) { + // CHECKSTYLE:OFF items.add(parseItem(parser)); + // CHECKSTYLE:ON } } else if (eventType == XmlPullParser.END_TAG) { @@ -95,10 +99,12 @@ public class PrivacyProvider extends IQProvider { } privacy.setPrivacyList(listName, items); + // CHECKSTYLE:OFF } // Parse the list complex type private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { + // CHECKSTYLE:ON // Retrieves the required attributes String actionValue = parser.getAttributeValue("", "action"); // Set the order number, this attribute is required @@ -135,7 +141,9 @@ public class PrivacyProvider extends IQProvider { } parseItemChildElements(parser, item); return item; + // CHECKSTYLE:OFF } + // CHECKSTYLE:ON private static void parseItemChildElements(XmlPullParser parser, PrivacyItem privacyItem) throws XmlPullParserException, IOException { final int initialDepth = parser.getDepth(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java index 0b658877b..456d0acd4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java @@ -85,7 +85,9 @@ public class Item extends NodeExtension */ public Item(String itemId, String nodeId) { + // CHECKSTYLE:OFF super(PubSubElementType.ITEM_EVENT, nodeId); + // CHECKSTYLE:ON id = itemId; } 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 4f64b37e7..d24dea498 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 @@ -26,6 +26,8 @@ import java.net.SocketException; import java.net.UnknownHostException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; @@ -36,6 +38,7 @@ import org.jivesoftware.smack.SmackException; * @author Henning Staib */ public class Socks5TestProxy { + private static final Logger LOGGER = Logger.getLogger(Socks5TestProxy.class.getName()); /* SOCKS5 proxy singleton */ private static Socks5TestProxy socks5Server; @@ -102,7 +105,7 @@ public class Socks5TestProxy { this.serverThread.start(); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "exception", e); // do nothing } } @@ -120,7 +123,7 @@ public class Socks5TestProxy { } catch (IOException e) { // do nothing - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "exception", e); } if (this.serverThread != null && this.serverThread.isAlive()) { @@ -130,7 +133,7 @@ public class Socks5TestProxy { } catch (InterruptedException e) { // do nothing - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "exception", e); } } this.serverThread = null; @@ -176,7 +179,7 @@ public class Socks5TestProxy { try { wait(5000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "exception", e); } finally { if (!startupComplete) { throw new IllegalStateException("Startup of Socks5TestProxy failed within 5 seconds"); @@ -230,7 +233,7 @@ public class Socks5TestProxy { } catch (Exception e) { try { - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "exception", e); socket.close(); } catch (IOException e1) { diff --git a/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java b/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java index c96fd215e..d49a9131c 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java +++ b/smack-extensions/src/test/java/org/jivesoftware/util/Protocol.java @@ -124,6 +124,7 @@ public class Protocol { */ @SuppressWarnings("unchecked") public void verifyAll() { + // CHECKSTYLE:OFF assertEquals(requests.size(), responsesList.size()); if (printProtocol) @@ -154,6 +155,7 @@ public class Protocol { } if (printProtocol) System.out.println("=================== End =================\n"); + // CHECKSTYLE:ON } /** diff --git a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java index 6244748c5..9b22695cb 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java @@ -153,7 +153,9 @@ public class ChatManager extends Manager{ Message message = (Message) packet; Chat chat; if (message.getThread() == null) { + // CHECKSTYLE:OFF chat = getUserChat(message.getFrom()); + // CHECKSTYLE:ON } else { chat = getThreadChat(message.getThread()); diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java index 279e47b60..a89e33848 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java @@ -122,7 +122,7 @@ public class DirectoryRosterStore implements RosterStore { for (File file : fileDir.listFiles(rosterDirFilter)) { Item entry = readEntry(file); if (entry == null) { - log("Roster store file '" + file + "' is invalid."); + LOGGER.severe("Roster store file '" + file + "' is invalid."); } else { entries.add(entry); @@ -228,7 +228,7 @@ public class DirectoryRosterStore implements RosterStore { groupNames.add(group); } else { - log("Invalid group entry in store entry file " + LOGGER.severe("Invalid group entry in store entry file " + file); } } @@ -245,9 +245,7 @@ public class DirectoryRosterStore implements RosterStore { return null; } catch (XmlPullParserException e) { - log("Invalid group entry in store entry file " - + file); - LOGGER.log(Level.SEVERE, "readEntry()", e); + LOGGER.log(Level.SEVERE, "Invalid group entry in store entry file", e); return null; } @@ -264,14 +262,14 @@ public class DirectoryRosterStore implements RosterStore { item.setItemType(RosterPacket.ItemType.valueOf(type)); } catch (IllegalArgumentException e) { - log("Invalid type in store entry file " + file); + LOGGER.log(Level.SEVERE, "Invalid type in store entry file " + file, e); return null; } if (status != null) { RosterPacket.ItemStatus itemStatus = RosterPacket.ItemStatus .fromString(status); if (itemStatus == null) { - log("Invalid status in store entry file " + file); + LOGGER.severe("Invalid status in store entry file " + file); return null; } item.setItemStatus(itemStatus); @@ -304,8 +302,4 @@ public class DirectoryRosterStore implements RosterStore { String encodedJid = Base32.encode(bareJid.toString()); return new File(fileDir, ENTRY_PREFIX + encodedJid); } - - private void log(String error) { - System.err.println(error); - } } diff --git a/smack-im/src/test/java/org/jivesoftware/smack/roster/RosterTest.java b/smack-im/src/test/java/org/jivesoftware/smack/roster/RosterTest.java index fe6f80d63..b4210a2fa 100644 --- a/smack-im/src/test/java/org/jivesoftware/smack/roster/RosterTest.java +++ b/smack-im/src/test/java/org/jivesoftware/smack/roster/RosterTest.java @@ -31,7 +31,6 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.jivesoftware.smack.DummyConnection; -import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.im.InitSmackIm; @@ -716,38 +715,20 @@ public class RosterTest extends InitSmackIm { public synchronized void entriesAdded(Collection addresses) { addressesAdded.addAll(addresses); - if (SmackConfiguration.DEBUG) { - for (Jid address : addresses) { - System.out.println("Roster entry for " + address + " added."); - } - } reportInvoked(); } public synchronized void entriesDeleted(Collection addresses) { addressesDeleted.addAll(addresses); - if (SmackConfiguration.DEBUG) { - for (Jid address : addresses) { - System.out.println("Roster entry for " + address + " deleted."); - } - } reportInvoked(); } public synchronized void entriesUpdated(Collection addresses) { addressesUpdated.addAll(addresses); - if (SmackConfiguration.DEBUG) { - for (Jid address : addresses) { - System.out.println("Roster entry for " + address + " updated."); - } - } reportInvoked(); } public void presenceChanged(Presence presence) { - if (SmackConfiguration.DEBUG) { - System.out.println("Roster presence changed: " + presence.toXML()); - } reportInvoked(); } diff --git a/smack-jingle-old/src/demo/java/org/jivesoftware/smackx/jingle/mediaimpl/demo/Demo.java b/smack-jingle-old/src/demo/java/org/jivesoftware/smackx/jingle/mediaimpl/demo/Demo.java index 2317e1ced..f6e72c26c 100644 --- a/smack-jingle-old/src/demo/java/org/jivesoftware/smackx/jingle/mediaimpl/demo/Demo.java +++ b/smack-jingle-old/src/demo/java/org/jivesoftware/smackx/jingle/mediaimpl/demo/Demo.java @@ -73,7 +73,7 @@ public class Demo extends JFrame { initialize(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -100,7 +100,7 @@ public class Demo extends JFrame { incoming.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java index 70ccd43dc..d48aafbe5 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleManagerTest.java @@ -233,7 +233,7 @@ public class JingleManagerTest extends SmackTestCase { assertTrue(valCounter() > 0); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } @@ -278,7 +278,7 @@ public class JingleManagerTest extends SmackTestCase { JingleSession session1 = request.accept(); session1.startIncoming(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }); @@ -293,7 +293,7 @@ public class JingleManagerTest extends SmackTestCase { assertTrue(valCounter() > 0); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } @@ -369,7 +369,7 @@ public class JingleManagerTest extends SmackTestCase { session1.startIncoming(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }); @@ -384,7 +384,7 @@ public class JingleManagerTest extends SmackTestCase { assertTrue(valCounter() == 1); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } @@ -456,7 +456,7 @@ public class JingleManagerTest extends SmackTestCase { session1.startIncoming(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }); @@ -498,7 +498,7 @@ public class JingleManagerTest extends SmackTestCase { assertTrue(valCounter() == 2); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } @@ -542,7 +542,7 @@ public class JingleManagerTest extends SmackTestCase { session.startIncoming(); session.terminate(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -588,7 +588,7 @@ public class JingleManagerTest extends SmackTestCase { assertTrue(valCounter() > 0); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } @@ -625,7 +625,7 @@ public class JingleManagerTest extends SmackTestCase { incCounter(); } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -666,11 +666,11 @@ public class JingleManagerTest extends SmackTestCase { ds1.close(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -737,7 +737,7 @@ public class JingleManagerTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -783,7 +783,7 @@ public class JingleManagerTest extends SmackTestCase { Thread.sleep(3000); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } System.out.println(valCounter()); @@ -871,7 +871,7 @@ public class JingleManagerTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -893,7 +893,7 @@ public class JingleManagerTest extends SmackTestCase { Thread.sleep(15000); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -941,7 +941,7 @@ public class JingleManagerTest extends SmackTestCase { // // ses.startIncoming(); // } catch (Exception e) { -// e.printStackTrace(); +// LOGGER.log(Level.WARNING, "exception", e); // } // } // }); @@ -984,7 +984,7 @@ public class JingleManagerTest extends SmackTestCase { // assertTrue(valCounter() > 0); // // } catch (Exception e) { -// e.printStackTrace(); +// LOGGER.log(Level.WARNING, "exception", e); // fail("An error occured with Jingle"); // } // } diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java index 2b691884a..b9a2ca495 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/JingleMediaTest.java @@ -96,7 +96,7 @@ public class JingleMediaTest extends SmackTestCase { // }); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -122,7 +122,7 @@ public class JingleMediaTest extends SmackTestCase { Thread.sleep(60000); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -165,11 +165,11 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(12000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -203,7 +203,7 @@ public class JingleMediaTest extends SmackTestCase { } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -238,7 +238,7 @@ public class JingleMediaTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -257,7 +257,7 @@ public class JingleMediaTest extends SmackTestCase { x1.disconnect(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -293,7 +293,7 @@ public class JingleMediaTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -312,7 +312,7 @@ public class JingleMediaTest extends SmackTestCase { x1.disconnect(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -355,7 +355,7 @@ public class JingleMediaTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -381,7 +381,7 @@ public class JingleMediaTest extends SmackTestCase { x1.disconnect(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }); @@ -392,7 +392,7 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(250000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -429,7 +429,7 @@ public class JingleMediaTest extends SmackTestCase { session.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -459,7 +459,7 @@ public class JingleMediaTest extends SmackTestCase { x1.disconnect(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -480,7 +480,7 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(10000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } audioChannel0.stop(); @@ -489,10 +489,10 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(3000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -515,7 +515,7 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(10000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } audioChannel0.stop(); @@ -524,11 +524,11 @@ public class JingleMediaTest extends SmackTestCase { try { Thread.sleep(3000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java index 9f9ff32e4..c2cb5a284 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java @@ -106,7 +106,7 @@ public class BridgedResolverTest extends SmackTestCase { Thread.sleep(1000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } assertTrue(valCounter() == 1); diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java index 11c3d0caa..732cb7122 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java @@ -175,9 +175,9 @@ public class STUNResolverTest extends SmackTestCase { System.out.println("C: " + candidate.getAddress().getInetAddress() + "|" + candidate.getBase().getAddress().getInetAddress() + " p:" + candidate.getPriority()); } catch (UtilityException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } catch (UnknownHostException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } Candidate candidate = cc.getSortedCandidates().get(0); @@ -251,7 +251,7 @@ public class STUNResolverTest extends SmackTestCase { Thread.sleep(55000); assertTrue(valCounter() > 0); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -353,7 +353,7 @@ public class STUNResolverTest extends SmackTestCase { }); session1.startIncoming(); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }); @@ -395,7 +395,7 @@ public class STUNResolverTest extends SmackTestCase { assertTrue(valCounter() == 2); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("An error occured with Jingle"); } } diff --git a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/TransportResolverTest.java b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/TransportResolverTest.java index f506a0bf2..af2a14cf7 100644 --- a/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/TransportResolverTest.java +++ b/smack-jingle-old/src/integration-test/java/org/jivesoftware/smackx/jingle/nat/TransportResolverTest.java @@ -52,7 +52,7 @@ public class TransportResolverTest extends SmackTestCase { try { tr.resolve(null); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); fail("Error resolving"); } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java index db1a6e2c8..f39a607c2 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java @@ -19,6 +19,7 @@ package org.jivesoftware.smackx.jingleold; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.ConnectionCreationListener; @@ -125,7 +126,7 @@ import org.jxmpp.jid.Jid; * // Start the call * session.start(); * } catch (XMPPException e) { - * e.printStackTrace(); + * LOGGER.log(Level.WARNING, "exception", e); * } *

* } @@ -134,7 +135,7 @@ import org.jxmpp.jid.Jid; * Thread.sleep(15000); *

* } catch (Exception e) { - * e.printStackTrace(); + * LOGGER.log(Level.WARNING, "exception", e); * } *

* To create an Outgoing Jingle Session: @@ -168,7 +169,7 @@ import org.jxmpp.jid.Jid; * Thread.sleep(3000); *

* } catch (Exception e) { - * e.printStackTrace(); + * LOGGER.log(Level.WARNING, "exception", e); * } * * @@ -239,7 +240,7 @@ public class JingleManager implements JingleSessionListener { try { aux.terminate(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -404,7 +405,7 @@ public class JingleManager implements JingleSessionListener { try { createdJingleSessionListener.sessionCreated(jingleSession); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -482,7 +483,7 @@ public class JingleManager implements JingleSessionListener { try { jingleSession.terminate(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } sessions.clear(); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java index f6aebfb2b..ee51b246b 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java @@ -236,7 +236,7 @@ public abstract class JingleNegotiator { */ public abstract List dispatchIncomingPacket(IQ iq, String id) throws XMPPException, SmackException, InterruptedException; - + // CHECKSTYLE:OFF public void start() { isStarted = true; doStart(); @@ -245,6 +245,7 @@ public abstract class JingleNegotiator { public boolean isStarted() { return isStarted; } + // CHECKSTYLE:ON /** * Each of the negotiators has their individual behavior when they start. diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java index 8c1c9b913..e69447327 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.AbstractConnectionClosedListener; @@ -296,7 +297,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList // Send the IQ to each of the content negotiators for further processing. // Each content negotiator may pass back a list of JingleContent for addition to the response packet. - + // CHECKSTYLE:OFF for (ContentNegotiator contentNegotiator : contentNegotiators) { // If at this point the content negotiator isn't started, it's because we sent a session-init jingle // packet from startOutgoing() and we're waiting for the other side to let us know they're ready @@ -307,6 +308,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } responses.addAll(contentNegotiator.dispatchIncomingPacket(iq, responseId)); } + // CHECKSTYLE:ON } // Acknowledge the IQ reception @@ -471,8 +473,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } // The the packet. + // CHECKSTYLE:OFF if ((getConnection() != null) && (getConnection().isConnected())) getConnection().sendStanza(jout); + // CHECKSTYLE:ON } return jout; } @@ -644,11 +648,13 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList } private void removeConnectionListener() { + // CHECKSTYLE:OFF if (connectionListener != null) { getConnection().removeConnectionListener(connectionListener); LOGGER.fine("JINGLE SESSION: REMOVE CONNECTION LISTENER"); } + // CHECKSTYLE:ON } /** @@ -676,7 +682,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList try { receivePacketAndRespond((IQ) packet); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }; @@ -823,11 +829,12 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList public void transportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException { if (isFullyEstablished()) { - + // CHECKSTYLE:OFF // Indicate that this session is active. setSessionState(JingleSessionStateActive.getInstance()); for (ContentNegotiator contentNegotiator : contentNegotiators) { + // CHECKSTYLE:ON if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) contentNegotiator.triggerContentEstablished(); } @@ -1081,7 +1088,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList try { resolver = transportManager.getResolver(this); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } if (resolver.getType().equals(TransportResolver.Type.rawupd)) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateActive.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateActive.java index 78adbe8b8..6b085c2bc 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateActive.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateActive.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.jingleold; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smackx.jingleold.packet.Jingle; import org.jivesoftware.smackx.jingleold.packet.JingleError; @@ -25,6 +28,8 @@ import org.jivesoftware.smackx.jingleold.packet.JingleError; * @see JingleSessionState */ public class JingleSessionStateActive extends JingleSessionState { + private static final Logger LOGGER = Logger.getLogger(JingleSessionStateActive.class.getName()); + private static JingleSessionStateActive INSTANCE = null; protected JingleSessionStateActive() { @@ -98,7 +103,7 @@ public class JingleSessionStateActive extends JingleSessionState { try { session.terminate("Closed remotely"); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return response; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStatePending.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStatePending.java index 11958d3d6..860bab8ee 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStatePending.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStatePending.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.jingleold; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smackx.jingleold.packet.Jingle; @@ -25,6 +28,8 @@ import org.jivesoftware.smackx.jingleold.packet.Jingle; */ public class JingleSessionStatePending extends JingleSessionState { + private static final Logger LOGGER = Logger.getLogger(JingleSessionStatePending.class.getName()); + private static JingleSessionStatePending INSTANCE = null; protected JingleSessionStatePending() { @@ -124,7 +129,7 @@ public class JingleSessionStatePending extends JingleSessionState { try { session.terminate("Closed remotely"); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return response; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateUnknown.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateUnknown.java index 08002b3c4..2c29fe7b8 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateUnknown.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionStateUnknown.java @@ -16,6 +16,9 @@ */ package org.jivesoftware.smackx.jingleold; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; @@ -36,6 +39,8 @@ import org.jivesoftware.smackx.jingleold.packet.JingleTransport; * @see JingleSessionState */ public class JingleSessionStateUnknown extends JingleSessionState { + private static final Logger LOGGER = Logger.getLogger(JingleSessionStateUnknown.class.getName()); + private static JingleSessionStateUnknown INSTANCE = null; protected JingleSessionStateUnknown() { @@ -171,7 +176,7 @@ public class JingleSessionStateUnknown extends JingleSessionState { try { resolver = transportManager.getResolver(session); } catch (XMPPException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } if (resolver.getType().equals(TransportResolver.Type.rawupd)) { @@ -205,7 +210,7 @@ public class JingleSessionStateUnknown extends JingleSessionState { try { session.terminate("Closed remotely"); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return response; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioChannel.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioChannel.java index 8f4e6b881..1418d9f88 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioChannel.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioChannel.java @@ -21,6 +21,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import javax.media.Codec; @@ -173,7 +174,7 @@ public class AudioChannel { } } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -202,11 +203,11 @@ public class AudioChannel { processor = javax.media.Manager.createProcessor(ds); } catch (NoProcessorException npe) { - npe.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", npe); return "Couldn't create processor"; } catch (IOException ioe) { - ioe.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", ioe); return "IOException creating processor"; } @@ -277,7 +278,7 @@ public class AudioChannel { tracks[i].setCodecChain(codec); } catch (UnsupportedPlugInException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -394,7 +395,7 @@ public class AudioChannel { } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); return e.getMessage(); } } @@ -421,7 +422,7 @@ public class AudioChannel { } } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -514,7 +515,7 @@ public class AudioChannel { Thread.sleep(5000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } audioChannel0.setTrasmit(false); @@ -524,7 +525,7 @@ public class AudioChannel { Thread.sleep(5000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } audioChannel0.setTrasmit(true); @@ -534,7 +535,7 @@ public class AudioChannel { Thread.sleep(5000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } audioChannel0.stop(); @@ -542,7 +543,7 @@ public class AudioChannel { } catch (UnknownHostException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java index ed2abfa69..d8f74a0f7 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java @@ -18,6 +18,7 @@ package org.jivesoftware.smackx.jingleold.mediaimpl.jmf; import java.io.IOException; import java.net.ServerSocket; +import java.util.logging.Level; import java.util.logging.Logger; import javax.media.MediaLocator; @@ -144,7 +145,7 @@ public class AudioMediaSession extends JingleMediaSession { return freePort; } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } try { @@ -153,7 +154,7 @@ public class AudioMediaSession extends JingleMediaSession { ss.close(); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return freePort; } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java index 346fdff11..bd4bb5e01 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smackx.jingleold.JingleSession; @@ -141,8 +142,7 @@ public class JmfMediaManager extends JingleMediaManager { jmfProperties.createNewFile(); } catch (IOException ex) { - LOGGER.fine("Failed to create jmf.properties"); - ex.printStackTrace(); + LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex); } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java index 14f343a66..1ac18bda1 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java @@ -21,6 +21,7 @@ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.ServerSocket; import java.security.GeneralSecurityException; +import java.util.logging.Level; import java.util.logging.Logger; import javax.media.NoProcessorException; @@ -138,16 +139,16 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio mediaSession = createSession(localIp, localPort, ip, remotePort, this, 2, false, true); } catch (NoProcessorException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } catch (UnsupportedFormatException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } catch (GeneralSecurityException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -161,7 +162,7 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio this.mediaReceived(""); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -225,7 +226,7 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio return freePort; } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } try { @@ -234,7 +235,7 @@ public class AudioMediaSession extends JingleMediaSession implements MediaSessio ss.close(); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return freePort; } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java index e9c74214f..ffd53f85e 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smackx.jingleold.JingleSession; @@ -106,8 +107,7 @@ public class SpeexMediaManager extends JingleMediaManager { jmfProperties.createNewFile(); } catch (IOException ex) { - LOGGER.fine("Failed to create jmf.properties"); - ex.printStackTrace(); + LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex); } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java index a7fd41c2e..644e9d3f1 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java @@ -24,6 +24,7 @@ import java.net.DatagramSocket; import java.net.InetAddress; import java.net.ServerSocket; import java.net.UnknownHostException; +import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; @@ -83,7 +84,7 @@ public class ScreenShareSession extends JingleMediaSession { transmitter = new ImageTransmitter(new DatagramSocket(getLocal().getPort()), remote, getRemote().getPort(), new Rectangle(0, 0, width, height)); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } else { @@ -106,7 +107,7 @@ public class ScreenShareSession extends JingleMediaSession { height); LOGGER.fine("Receiving on:" + receiver.getLocalPort()); } catch (UnknownHostException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } jp.add(receiver); @@ -176,7 +177,7 @@ public class ScreenShareSession extends JingleMediaSession { ss.close(); return freePort; } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } try { @@ -184,7 +185,7 @@ public class ScreenShareSession extends JingleMediaSession { freePort = ss.getLocalPort(); ss.close(); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return freePort; } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/DefaultEncoder.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/DefaultEncoder.java index aa78f7b5c..53e21d13f 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/DefaultEncoder.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/DefaultEncoder.java @@ -17,14 +17,18 @@ package org.jivesoftware.smackx.jingleold.mediaimpl.sshare.api; import javax.imageio.ImageIO; + import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Implements a default PNG Encoder */ public class DefaultEncoder implements ImageEncoder{ + private static final Logger LOGGER = Logger.getLogger(DefaultEncoder.class.getName()); public ByteArrayOutputStream encode(BufferedImage bufferedImage) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -32,7 +36,7 @@ public class DefaultEncoder implements ImageEncoder{ ImageIO.write(bufferedImage, "png", baos); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); baos = null; } return baos; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageReceiver.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageReceiver.java index 3ef5d6f0b..a6d9682d5 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageReceiver.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageReceiver.java @@ -25,6 +25,8 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketException; +import java.util.logging.Level; +import java.util.logging.Logger; /** * UDP Image Receiver. @@ -33,6 +35,7 @@ import java.net.SocketException; * @author Thiago Rocha Camargo */ public class ImageReceiver extends Canvas { + private static final Logger LOGGER = Logger.getLogger(ImageReceiver.class.getName()); private static final long serialVersionUID = -7000112305305269025L; private boolean on = true; @@ -81,7 +84,7 @@ public class ImageReceiver extends Canvas { } } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }).start(); @@ -101,20 +104,20 @@ public class ImageReceiver extends Canvas { Thread.sleep(1000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } }).start(); } catch (SocketException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } this.setSize(width, height); } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageTransmitter.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageTransmitter.java index d625e6efb..0de0e60f6 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageTransmitter.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/ImageTransmitter.java @@ -27,6 +27,7 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.util.Arrays; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -77,7 +78,7 @@ public class ImageTransmitter implements Runnable { } catch (AWTException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -141,7 +142,7 @@ public class ImageTransmitter implements Runnable { socket.send(p); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } tiles[i][j] = pixels; @@ -157,7 +158,7 @@ public class ImageTransmitter implements Runnable { } } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -170,7 +171,7 @@ public class ImageTransmitter implements Runnable { Thread.sleep(500 - trace); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BasicResolver.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BasicResolver.java index c0c9a70e2..fc3fbf968 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BasicResolver.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BasicResolver.java @@ -24,6 +24,8 @@ import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Basic Resolver takes all IP addresses of the interfaces and uses the @@ -31,6 +33,7 @@ import java.util.Enumeration; * A very simple and easy to use resolver. */ public class BasicResolver extends TransportResolver { + private static final Logger LOGGER = Logger.getLogger(BasicResolver.class.getName()); /** * Constructor. @@ -58,7 +61,7 @@ public class BasicResolver extends TransportResolver { try { ifaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } while (ifaces.hasMoreElements()) { @@ -81,7 +84,7 @@ public class BasicResolver extends TransportResolver { try { ifaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } while (ifaces.hasMoreElements()) { @@ -106,7 +109,7 @@ public class BasicResolver extends TransportResolver { tr.setLocalIp(InetAddress.getLocalHost().getHostAddress() != null ? InetAddress.getLocalHost().getHostAddress() : InetAddress.getLocalHost().getHostName()); addCandidate(tr); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } setResolveEnd(); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java index 76edad7b3..8b38f9d0e 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java @@ -29,6 +29,8 @@ import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Bridged Resolver use a RTPBridge Service to add a relayed candidate. @@ -39,6 +41,7 @@ import java.util.Random; * The resolver adds this candidate */ public class BridgedResolver extends TransportResolver { + private static final Logger LOGGER = Logger.getLogger(BridgedResolver.class.getName()); XMPPConnection connection; @@ -122,7 +125,7 @@ public class BridgedResolver extends TransportResolver { ifaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } while (ifaces.hasMoreElements()) { @@ -142,7 +145,7 @@ public class BridgedResolver extends TransportResolver { return InetAddress.getLocalHost().getHostAddress(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return "127.0.0.1"; diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/HttpServer.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/HttpServer.java index c4b1991e6..5973ce262 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/HttpServer.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/HttpServer.java @@ -93,7 +93,7 @@ public class HttpServer { processRequest(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -139,7 +139,7 @@ public class HttpServer { } catch (Exception e) { // Do Nothing - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java index 336a46202..7ba4e8cb5 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java @@ -19,6 +19,7 @@ package org.jivesoftware.smackx.jingleold.nat; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -258,7 +259,7 @@ public class ICECandidate extends TransportCandidate implements Comparable " + transportCandidate.getIp() + ":" + transportCandidate.getPort()); TestResult testResult = new TestResult(); testResult.setResult(true); @@ -770,7 +775,7 @@ public abstract class TransportCandidate { } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } LOGGER.fine("ECHO Wrong Data: " + datagramPacket.getAddress().getHostAddress() + ":" + datagramPacket.getPort()); @@ -785,7 +790,7 @@ public abstract class TransportCandidate { content = new String(password + ";" + getIp() + ":" + getPort()).getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } DatagramPacket packet = new DatagramPacket(content, content.length); @@ -794,7 +799,7 @@ public abstract class TransportCandidate { packet.setAddress(InetAddress.getByName(transportCandidate.getIp())); } catch (UnknownHostException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } packet.setPort(transportCandidate.getPort()); @@ -808,7 +813,7 @@ public abstract class TransportCandidate { Thread.sleep(delay); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } @@ -820,7 +825,7 @@ public abstract class TransportCandidate { Thread.sleep(2000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } removeListener(listener); diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportNegotiator.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportNegotiator.java index 21a362321..b06b48cba 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportNegotiator.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportNegotiator.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; @@ -164,7 +165,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { setNegotiatorState(JingleNegotiatorState.PENDING); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -302,7 +303,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { try { Thread.sleep(1000); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } // Once we are in pending state, look for any valid remote @@ -397,7 +398,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { try { Thread.sleep(500); } catch (InterruptedException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } bestRemote = getBestRemoteCandidate(); @@ -431,7 +432,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { session .terminate("Unable to negotiate session. This may be caused by firewall configuration problems."); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } } diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java index 0026bf3a1..ac6ddd6a5 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; @@ -372,7 +373,7 @@ public abstract class TransportResolver { LOGGER.fine("Transport resolved"); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } @@ -395,7 +396,7 @@ public abstract class TransportResolver { return freePort; } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } } try { @@ -404,7 +405,7 @@ public abstract class TransportResolver { ss.close(); } catch (IOException e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "exception", e); } return freePort; } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/MacroGroup.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/MacroGroup.java index 6b71e972b..221651877 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/MacroGroup.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/MacroGroup.java @@ -113,6 +113,7 @@ public class MacroGroup { } public String toXML() { + // CHECKSTYLE:OFF StringBuilder buf = new StringBuilder(); buf.append(""); buf.append("" + getTitle() + ""); @@ -136,6 +137,7 @@ public class MacroGroup { buf.append(""); } buf.append(""); - return buf.toString(); + return buf.toString(); + // CHECKSTYLE:ON } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java index e648d8860..1e60fc28a 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/macros/Macros.java @@ -82,10 +82,12 @@ public class Macros extends IQ { if (isPersonal()) { buf.append("true"); } - if (getPersonalMacroGroup() != null) { + if (getPersonalMacroGroup() != null) { + // CHECKSTYLE:OFF buf.append(""); buf.append(StringUtils.escapeForXML(getPersonalMacroGroup().toXML())); buf.append(""); + // CHECKSTYLE:ON } return buf; @@ -123,6 +125,7 @@ public class Macros extends IQ { } public Macro parseMacro(XmlPullParser parser) throws XmlPullParserException, IOException { + // CHECKSTYLE:OFF Macro macro = new Macro(); boolean done = false; while (!done) { @@ -149,9 +152,11 @@ public class Macros extends IQ { } } return macro; + // CHECKSTYLE:ON } public MacroGroup parseMacroGroup(XmlPullParser parser) throws XmlPullParserException, IOException { + // CHECKSTYLE:OFF MacroGroup group = new MacroGroup(); boolean done = false; @@ -175,10 +180,11 @@ public class Macros extends IQ { } } return group; + // CHECKSTYLE:ON } public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException { - + // CHECKSTYLE:OFF MacroGroup group = null; XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setInput(new StringReader(macros)); @@ -192,6 +198,7 @@ public class Macros extends IQ { } } return group; + // CHECKSTYLE:ON } } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java index 8e1cf06e0..c91e06415 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java @@ -469,13 +469,17 @@ public class Workgroup { private void fireInvitationEvent(WorkgroupInvitation invitation) { for (WorkgroupInvitationListener listener : invitationListeners ){ + // CHECKSTYLE:OFF listener.invitationReceived(invitation); + // CHECKSTYLE:ON } } private void fireQueueJoinedEvent() { for (QueueListener listener : queueListeners){ + // CHECKSTYLE:OFF listener.joinedQueue(); + // CHECKSTYLE:ON } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java index 8e63377cd..e2ceec261 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java @@ -47,7 +47,7 @@ public class RosterExchangeProvider extends ExtensionElementProvider