Replace printStackTrace() with call to Logger

This commit is contained in:
Florian Schmaus 2014-04-23 09:37:16 +02:00
parent cf6076ce43
commit 5b8fd51345
2 changed files with 12 additions and 5 deletions

View File

@ -23,6 +23,8 @@ import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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;
import org.jivesoftware.smack.packet.RosterPacket.Item; 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 ENTRY_PREFIX = "entry-";
private static final String VERSION_FILE_NAME = "__version__"; private static final String VERSION_FILE_NAME = "__version__";
private static final String STORE_ID = "DEFAULT_ROSTER_STORE"; 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() { private static final FileFilter rosterDirFilter = new FileFilter() {
@ -235,13 +238,13 @@ public class DirectoryRosterStore implements RosterStore {
} }
} }
catch (IOException e) { catch (IOException e) {
e.printStackTrace();; LOGGER.log(Level.SEVERE, "readEntry()", e);
return null; return null;
} }
catch (XmlPullParserException e) { catch (XmlPullParserException e) {
log("Invalid group entry in store entry file " log("Invalid group entry in store entry file "
+ file); + file);
e.printStackTrace(); LOGGER.log(Level.SEVERE, "readEntry()", e);
return null; return null;
} }

View File

@ -55,6 +55,8 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; 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 * 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 { public class XMPPTCPConnection extends XMPPConnection {
private static final Logger LOGGER = Logger.getLogger(XMPPTCPConnection.class.getName());
/** /**
* The socket which is used for this connection. * The socket which is used for this connection.
*/ */
@ -384,7 +388,7 @@ public class XMPPTCPConnection extends XMPPConnection {
try { try {
socket.close(); socket.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOGGER.log(Level.WARNING, "shutdown", e);
} }
// In most cases the close() should be successful, so set // In most cases the close() should be successful, so set
// connected to false here. // connected to false here.
@ -575,7 +579,7 @@ public class XMPPTCPConnection extends XMPPConnection {
reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); LOGGER.log(Level.WARNING, "initReaderAndWriter()", e);
compressionHandler = null; compressionHandler = null;
reader = new BufferedReader( reader = new BufferedReader(
new InputStreamReader(socket.getInputStream(), "UTF-8")); new InputStreamReader(socket.getInputStream(), "UTF-8"));
@ -925,7 +929,7 @@ public class XMPPTCPConnection extends XMPPConnection {
catch (Exception e) { catch (Exception e) {
// Catch and print any exception so we can recover // Catch and print any exception so we can recover
// from a faulty listener // from a faulty listener
e.printStackTrace(); LOGGER.log(Level.WARNING, "notifyReconnection()", e);
} }
} }
} }