From 5b8fd5134598b98a39a2051d93640c20c75d67af Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 23 Apr 2014 09:37:16 +0200 Subject: [PATCH] Replace printStackTrace() with call to Logger --- .../org/jivesoftware/smack/DirectoryRosterStore.java | 7 +++++-- .../java/org/jivesoftware/smack/XMPPTCPConnection.java | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/jivesoftware/smack/DirectoryRosterStore.java b/core/src/main/java/org/jivesoftware/smack/DirectoryRosterStore.java index faaf1d57c..a540ab216 100644 --- a/core/src/main/java/org/jivesoftware/smack/DirectoryRosterStore.java +++ b/core/src/main/java/org/jivesoftware/smack/DirectoryRosterStore.java @@ -23,6 +23,8 @@ import java.io.StringReader; 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.packet.RosterPacket; import org.jivesoftware.smack.packet.RosterPacket.Item; @@ -47,6 +49,7 @@ public class DirectoryRosterStore implements RosterStore { private static final String ENTRY_PREFIX = "entry-"; private static final String VERSION_FILE_NAME = "__version__"; private static final String STORE_ID = "DEFAULT_ROSTER_STORE"; + private static final Logger LOGGER = Logger.getLogger(DirectoryRosterStore.class.getName()); private static final FileFilter rosterDirFilter = new FileFilter() { @@ -235,13 +238,13 @@ public class DirectoryRosterStore implements RosterStore { } } catch (IOException e) { - e.printStackTrace();; + LOGGER.log(Level.SEVERE, "readEntry()", e); return null; } catch (XmlPullParserException e) { log("Invalid group entry in store entry file " + file); - e.printStackTrace(); + LOGGER.log(Level.SEVERE, "readEntry()", e); return null; } diff --git a/tcp/src/main/java/org/jivesoftware/smack/XMPPTCPConnection.java b/tcp/src/main/java/org/jivesoftware/smack/XMPPTCPConnection.java index 4f836d863..885e1833d 100644 --- a/tcp/src/main/java/org/jivesoftware/smack/XMPPTCPConnection.java +++ b/tcp/src/main/java/org/jivesoftware/smack/XMPPTCPConnection.java @@ -55,6 +55,8 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Creates a socket connection to a XMPP server. This is the default connection @@ -65,6 +67,8 @@ import java.util.Locale; */ public class XMPPTCPConnection extends XMPPConnection { + private static final Logger LOGGER = Logger.getLogger(XMPPTCPConnection.class.getName()); + /** * The socket which is used for this connection. */ @@ -384,7 +388,7 @@ public class XMPPTCPConnection extends XMPPConnection { try { socket.close(); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "shutdown", e); } // In most cases the close() should be successful, so set // connected to false here. @@ -575,7 +579,7 @@ public class XMPPTCPConnection extends XMPPConnection { reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); } catch (Exception e) { - e.printStackTrace(); + LOGGER.log(Level.WARNING, "initReaderAndWriter()", e); compressionHandler = null; reader = new BufferedReader( new InputStreamReader(socket.getInputStream(), "UTF-8")); @@ -925,7 +929,7 @@ public class XMPPTCPConnection extends XMPPConnection { catch (Exception e) { // Catch and print any exception so we can recover // from a faulty listener - e.printStackTrace(); + LOGGER.log(Level.WARNING, "notifyReconnection()", e); } } }