james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [14/34] james-project git commit: JAMES-2085 Replace printStackTrace by logger when accurate
Date Wed, 05 Jul 2017 13:59:21 GMT
JAMES-2085 Replace printStackTrace by logger when accurate


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a3438cf6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a3438cf6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a3438cf6

Branch: refs/heads/master
Commit: a3438cf692997dbaa904302a706cbbb30951526d
Parents: 3f97dd7
Author: benwa <btellier@linagora.com>
Authored: Mon Jul 3 10:46:03 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jul 5 17:13:47 2017 +0700

----------------------------------------------------------------------
 .../mailbox/caching/CacheInvalidatingMailboxListener.java |  8 ++++++--
 .../james/mailbox/maildir/mail/MaildirMailboxMapper.java  |  5 ++++-
 .../james/transport/mailets/SMIMECheckSignature.java      |  1 -
 .../james/protocols/api/future/FutureResponseImpl.java    | 10 ++++------
 .../java/org/apache/james/protocols/imap/IMAPRequest.java |  6 +++++-
 .../james/user/jdbc/AbstractJdbcUsersRepository.java      |  5 -----
 6 files changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
index 3512fd3..1cd463b 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
@@ -3,12 +3,17 @@ package org.apache.james.mailbox.caching;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxListenerSupport;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * A MailboxListener that invalidates the configured caches in response to Events
  *
  */
 public class CacheInvalidatingMailboxListener implements MailboxListener {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CacheInvalidatingMailboxListener.class);
+
     private final MailboxByPathCache mailboxCacheByPath;
     private final MailboxMetadataCache mailboxMetadataCache;
 
@@ -48,8 +53,7 @@ public class CacheInvalidatingMailboxListener implements MailboxListener
{
             }
             invalidateMailbox(event);
         } catch (MailboxException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            LOGGER.error("Error while invalidation cache", e);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
index a59ab1f..5661b91 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
@@ -43,9 +43,12 @@ import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.mailbox.store.transaction.NonTransactionalMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MaildirMailboxMapper extends NonTransactionalMapper implements MailboxMapper
{
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(MaildirMailboxMapper.class);
     /**
      * The {@link MaildirStore} the mailboxes reside in
      */
@@ -99,7 +102,7 @@ public class MaildirMailboxMapper extends NonTransactionalMapper implements
Mail
                     FileUtils.forceDelete(file);
                 }
             } catch (IOException e) {
-                e.printStackTrace();
+                LOGGER.error("Error while deleting file " + file, e);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/mailet/crypto/src/main/java/org/apache/james/transport/mailets/SMIMECheckSignature.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/SMIMECheckSignature.java
b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/SMIMECheckSignature.java
index e016a60..887329b 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/SMIMECheckSignature.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/SMIMECheckSignature.java
@@ -182,7 +182,6 @@ public class SMIMECheckSignature extends GenericMailet {
             log("Error during the analysis of the signed message", e);
             signers = null;
         } catch (Exception e) {
-            e.printStackTrace();
             log("Generic error occured during the analysis of the message", e);
             signers = null;
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/protocols/api/src/main/java/org/apache/james/protocols/api/future/FutureResponseImpl.java
----------------------------------------------------------------------
diff --git a/protocols/api/src/main/java/org/apache/james/protocols/api/future/FutureResponseImpl.java
b/protocols/api/src/main/java/org/apache/james/protocols/api/future/FutureResponseImpl.java
index aa06a64..8987f82 100644
--- a/protocols/api/src/main/java/org/apache/james/protocols/api/future/FutureResponseImpl.java
+++ b/protocols/api/src/main/java/org/apache/james/protocols/api/future/FutureResponseImpl.java
@@ -25,6 +25,8 @@ import java.util.List;
 import org.apache.james.protocols.api.AbstractResponse;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.logger.Logger;
+import org.apache.james.protocols.api.logger.ProtocolLoggerAdapter;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link FutureResponse} implementation which wraps a {@link AbstractResponse} implementation
@@ -36,7 +38,7 @@ public class FutureResponseImpl implements FutureResponse{
     private final Logger logger;
 
     public FutureResponseImpl() {
-        this(null);
+        this(new ProtocolLoggerAdapter(LoggerFactory.getLogger(FutureResponseImpl.class)));
     }
     
     public FutureResponseImpl(Logger logger) {
@@ -154,11 +156,7 @@ public class FutureResponseImpl implements FutureResponse{
                 try {
                     listener.onResponse(this);
                 } catch (Throwable e) {
-                    if (logger != null) {
-                        logger.warn("An exception was thrown by the listener " + listener,
e);
-                    } else {
-                        e.printStackTrace();
-                    }
+                    logger.warn("An exception was thrown by the listener " + listener, e);
                 }
             }
             listeners = null;

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/protocols/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequest.java
b/protocols/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequest.java
index 5b55292..1994601 100644
--- a/protocols/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequest.java
+++ b/protocols/imap/src/main/java/org/apache/james/protocols/imap/IMAPRequest.java
@@ -26,9 +26,13 @@ import java.util.Iterator;
 import java.util.Locale;
 
 import org.apache.james.protocols.api.Request;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class IMAPRequest implements Request {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(IMAPRequest.class);
+
     private static final String US_ASCII = "US_ASCII";
     
     private static final String CRLF = "\r\n";
@@ -90,7 +94,7 @@ public class IMAPRequest implements Request {
                 sb.append(new String(buf, US_ASCII));
             } catch (UnsupportedEncodingException e) {
                 // Should never happend
-                e.printStackTrace();
+                LOGGER.error("Unupported encoding", e);
             }
             if (linesIt.hasNext()) {
                 sb.append(CRLF);

http://git-wip-us.apache.org/repos/asf/james-project/blob/a3438cf6/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/AbstractJdbcUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/AbstractJdbcUsersRepository.java
b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/AbstractJdbcUsersRepository.java
index 7478d58..f37fbf5 100644
--- a/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/AbstractJdbcUsersRepository.java
+++ b/server/data/data-jdbc/src/main/java/org/apache/james/user/jdbc/AbstractJdbcUsersRepository.java
@@ -469,7 +469,6 @@ public abstract class AbstractJdbcUsersRepository extends AbstractJamesUsersRepo
                 userList.add(user);
             }
         } catch (SQLException sqlExc) {
-            sqlExc.printStackTrace();
             throw new UsersRepositoryException("Error accessing database", sqlExc);
         } finally {
             theJDBCUtil.closeJDBCResultSet(rsUsers);
@@ -502,7 +501,6 @@ public abstract class AbstractJdbcUsersRepository extends AbstractJamesUsersRepo
 
             addUserStatement.execute();
         } catch (SQLException sqlExc) {
-            sqlExc.printStackTrace();
             throw new UsersRepositoryException("Error accessing database", sqlExc);
         } finally {
             theJDBCUtil.closeJDBCStatement(addUserStatement);
@@ -531,7 +529,6 @@ public abstract class AbstractJdbcUsersRepository extends AbstractJamesUsersRepo
             removeUserStatement.setString(1, username);
             removeUserStatement.execute();
         } catch (SQLException sqlExc) {
-            sqlExc.printStackTrace();
             throw new UsersRepositoryException("Error accessing database", sqlExc);
         } finally {
             theJDBCUtil.closeJDBCStatement(removeUserStatement);
@@ -557,7 +554,6 @@ public abstract class AbstractJdbcUsersRepository extends AbstractJamesUsersRepo
             setUserForUpdateStatement(user, updateUserStatement);
             updateUserStatement.execute();
         } catch (SQLException sqlExc) {
-            sqlExc.printStackTrace();
             throw new UsersRepositoryException("Error accessing database", sqlExc);
         } finally {
             theJDBCUtil.closeJDBCStatement(updateUserStatement);
@@ -642,7 +638,6 @@ public abstract class AbstractJdbcUsersRepository extends AbstractJamesUsersRepo
             }
             return user;
         } catch (SQLException sqlExc) {
-            sqlExc.printStackTrace();
             throw new UsersRepositoryException("Error accessing database", sqlExc);
         } finally {
             theJDBCUtil.closeJDBCResultSet(rsUsers);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message