james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [29/34] james-project git commit: JAMES-2085 Remove System.out calls in code we rely on
Date Wed, 05 Jul 2017 13:59:36 GMT
JAMES-2085 Remove System.out calls in code we rely on


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

Branch: refs/heads/master
Commit: e75585843cffa645722a37db8162ff4a261350e1
Parents: 635e8e2
Author: benwa <btellier@linagora.com>
Authored: Tue Jul 4 11:13:41 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jul 5 17:13:49 2017 +0700

----------------------------------------------------------------------
 .../hbase/HBaseNonTransactionalMapper.java      |  1 -
 .../maildir/mail/MaildirMessageMapper.java      |  6 ----
 .../apache/mailet/base/FlowedMessageUtils.java  | 12 ++++++--
 .../org/apache/mailet/base/StringUtils.java     |  2 +-
 .../james/mpt/protocol/ProtocolSession.java     | 29 ++++++++------------
 .../AbstractLoaderBeanFactory.java              |  9 +-----
 .../org/apache/james/smtpserver/TLDLookup.java  |  9 ++++--
 .../james/queue/activemq/EmbeddedActiveMQ.java  |  6 +++-
 8 files changed, 34 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseNonTransactionalMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseNonTransactionalMapper.java
b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseNonTransactionalMapper.java
index 93c4e77..bea36b8 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseNonTransactionalMapper.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseNonTransactionalMapper.java
@@ -34,6 +34,5 @@ public class HBaseNonTransactionalMapper extends NonTransactionalMapper
{
     @Override
     public void endRequest() {
         //TODO: maybe do some thing more wise here?
-        //System.out.println("Bye!");
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
index 9a8e0db..1e77933 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
@@ -166,8 +166,6 @@ public class MaildirMessageMapper extends AbstractMessageMapper {
                 MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession,
member.getUid());
                 if (messageName != null) {
                     File messageFile = messageName.getFile();
-                    // System.out.println("save existing " + message +
-                    // " as " + messageFile.getName());
                     messageName.setFlags(member.createFlags());
                     // this automatically moves messages from new to cur if
                     // needed
@@ -314,16 +312,12 @@ public class MaildirMessageMapper extends AbstractMessageMapper {
         if (message.isRecent()) {
             messageName.setFlags(message.createFlags());
             newMessageFile = new File(folder.getNewFolder(), messageName.getFullName());
-            // System.out.println("save new recent " + message + " as " +
-            // newMessageFile.getName());
         }
         // appended via IMAP (might already have flags etc, goes to ./cur
         // directly)
         else {
             messageName.setFlags(message.createFlags());
             newMessageFile = new File(folder.getCurFolder(), messageName.getFullName());
-            // System.out.println("save new not recent " + message + " as "
-            // + newMessageFile.getName());
         }
         try {
             FileUtils.moveFile(messageFile, newMessageFile);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/mailet/base/src/main/java/org/apache/mailet/base/FlowedMessageUtils.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/FlowedMessageUtils.java b/mailet/base/src/main/java/org/apache/mailet/base/FlowedMessageUtils.java
index 86b29bd..105607d 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/FlowedMessageUtils.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/FlowedMessageUtils.java
@@ -25,6 +25,9 @@ import javax.mail.internet.ContentType;
 
 import java.io.IOException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * <p>Manages texts encoded as <code>text/plain; format=flowed</code>.</p>
  * <p>As a reference see:</p>
@@ -48,6 +51,8 @@ import java.io.IOException;
  * </ul>
  */
 public final class FlowedMessageUtils {
+    private static final Logger LOGGER = LoggerFactory.getLogger(FlowedMessageUtils.class);
+
     public static final char RFC2646_SPACE = ' ';
     public static final char RFC2646_QUOTE = '>';
     public static final String RFC2646_SIGNATURE = "-- ";
@@ -157,9 +162,10 @@ public final class FlowedMessageUtils {
             ct.getParameterList().remove("format");
             ct.getParameterList().remove("delsp");
             
-            if (ct.toString().contains("flowed"))
-                System.out.println("\n\n*************************\n* ERROR!!! FlowedMessageUtils
dind't remove the flowed correctly!\n******************\n\n" + ct.toString() + " \n " + ct.toString()
+ "\n");
-            
+            if (ct.toString().contains("flowed")) {
+                LOGGER.error("FlowedMessageUtils dind't remove the flowed correctly");
+            }
+
             m.setContent(deflowed, ct.toString());
             m.saveChanges();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/mailet/base/src/main/java/org/apache/mailet/base/StringUtils.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/StringUtils.java b/mailet/base/src/main/java/org/apache/mailet/base/StringUtils.java
index 9c50591..703726e 100644
--- a/mailet/base/src/main/java/org/apache/mailet/base/StringUtils.java
+++ b/mailet/base/src/main/java/org/apache/mailet/base/StringUtils.java
@@ -77,7 +77,7 @@ public final class StringUtils {
             StringBuilder sb = new StringBuilder();
             byte buf[] = message.getBytes();
             byte[] md5 = md.digest(buf);
-            //System.out.println(message);
+
             for (byte aMd5 : md5) {
                 String tmpStr = "0" + Integer.toHexString((0xff & aMd5));
                 sb.append(tmpStr.substring(tmpStr.length() - 2));

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/mpt/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
----------------------------------------------------------------------
diff --git a/mpt/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java b/mpt/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
index bd26549..21ee26c 100644
--- a/mpt/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
+++ b/mpt/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
@@ -348,12 +348,7 @@ public class ProtocolSession implements ProtocolInteractor {
             if (!match(expectedLine, testLine)) {
                 String errMsg = "\nLocation: " + location + "\nLastClientMsg: " + lastClientMessage
+ "\nExpected: '"
                         + expectedLine + "'\nActual   : '" + testLine + "'";
-                if (continueAfterFailure) {
-                    System.out.println(errMsg);
-                }
-                else {
-                    throw new InvalidServerResponseException(errMsg);
-                }
+                handleFailure(continueAfterFailure, errMsg);
             }
         }
 
@@ -467,12 +462,7 @@ public class ProtocolSession implements ProtocolInteractor {
                         errMsg.append(iter.next());
                     }
                     errMsg.append("\nActual: ").append(actualLine);
-                    if (continueAfterFailure) {
-                        System.out.println(errMsg.toString());
-                    }
-                    else {
-                        throw new InvalidServerResponseException(errMsg.toString());
-                    }
+                    handleFailure(continueAfterFailure, errMsg.toString());
                 }
             }
         }
@@ -493,12 +483,7 @@ public class ProtocolSession implements ProtocolInteractor {
             String testLine = session.readLine();
             if (!"+".equals(testLine) || !continued) {
                 final String message = "Expected continuation";
-                if (continueAfterFailure) {
-                    System.out.print(message);
-                }
-                else {
-                    throw new InvalidServerResponseException(message);
-                }
+                handleFailure(continueAfterFailure, message);
             }
             continuationExpected = false;
             continued = false;
@@ -513,6 +498,14 @@ public class ProtocolSession implements ProtocolInteractor {
         }
     }
 
+    private void handleFailure(boolean continueAfterFailure, String message) throws InvalidServerResponseException
{
+        if (continueAfterFailure) {
+            LOGGER.warn(message);
+        } else {
+            throw new InvalidServerResponseException(message);
+        }
+    }
+
     private class ReinitElement implements ProtocolElement {
 
         private final int sessionNumber;

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/AbstractLoaderBeanFactory.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/AbstractLoaderBeanFactory.java
b/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/AbstractLoaderBeanFactory.java
index 3b37bf6..babee80 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/AbstractLoaderBeanFactory.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factory/mailetcontainer/AbstractLoaderBeanFactory.java
@@ -45,12 +45,6 @@ public abstract class AbstractLoaderBeanFactory<T> extends AbstractBeanFactory
{
         Class<T> c = (Class<T>) getBeanFactory().getBeanClassLoader().loadClass(fullName);
         @SuppressWarnings("deprecation")
         T t = (T) getBeanFactory().createBean(c, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT,
true);
-        if (name.equals("LocalDelivery")) {
-            System.out.println(t);
-        }
-        if (name.equals("SieveMailet")) {
-            System.out.println(t);
-        }
         return t;
 
     }
@@ -65,8 +59,7 @@ public abstract class AbstractLoaderBeanFactory<T> extends AbstractBeanFactory
{
      * @return not null
      */
     protected MailetException loadFailed(String name, String type, Exception e) {
-        final String builder = "Could not load " + type + " (" + name + ")";
-        return new MailetException(builder.toString(), e);
+        return new MailetException("Could not load " + type + " (" + name + ")", e);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/TLDLookup.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/TLDLookup.java
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/TLDLookup.java
index 31ba869..1c12b43 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/TLDLookup.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/TLDLookup.java
@@ -21,12 +21,17 @@ package org.apache.james.smtpserver;
 
 import java.util.HashSet;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * A utility class that caches sets of multi-part top level domains (TLDs) for
  * quick lookup.
  */
 public class TLDLookup {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(TLDLookup.class);
+
     /**
      * Simple regular expression to match strings in the cache. Note: if the
      * collection of known mult-part TLDs change to contain characters other
@@ -168,7 +173,7 @@ public class TLDLookup {
      */
     private static void debugOut(String msg) {
         if (testing) {
-            System.out.println(msg);
+            LOGGER.debug(msg);
         }
     }
 
@@ -177,7 +182,7 @@ public class TLDLookup {
      */
     private static void debugOut(Throwable th) {
         if (testing) {
-            System.out.println(th);
+            LOGGER.debug("Error caught", th);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e7558584/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
index f62108a..6e6b7bf 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
@@ -32,11 +32,15 @@ import org.apache.activemq.broker.jmx.ManagementContext;
 import org.apache.activemq.plugin.StatisticsBrokerPlugin;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.james.filesystem.api.FileSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Throwables;
 
 public class EmbeddedActiveMQ {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedActiveMQ.class);
+
     private final ActiveMQConnectionFactory activeMQConnectionFactory;
     private final PersistenceAdapter persistenceAdapter;
     private BrokerService brokerService;
@@ -102,6 +106,6 @@ public class EmbeddedActiveMQ {
         String[] transportConnectorsURIs = {"tcp://localhost:0"};
         brokerService.setTransportConnectorURIs(transportConnectorsURIs);
         brokerService.start();
-        System.out.println("Started : " + brokerService.isStarted());
+        LOGGER.info("Started embedded activeMq");
     }
 }


---------------------------------------------------------------------
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