james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [20/34] james-project git commit: JAMES-2085 Use intellij inspection to remove empty catch blocks
Date Wed, 05 Jul 2017 13:59:27 GMT
JAMES-2085 Use intellij inspection to remove empty catch blocks


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

Branch: refs/heads/master
Commit: 73426233fe193517275814337a6c042c30040340
Parents: 154a740
Author: benwa <btellier@linagora.com>
Authored: Mon Jul 3 17:50:51 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jul 5 17:13:48 2017 +0700

----------------------------------------------------------------------
 .../mail/CassandraMailboxMapperTest.java        |  6 +-
 .../maildir/mail/MaildirMessageMapper.java      | 13 +--
 .../james/transport/mailets/ClamAVScan.java     | 85 +++-----------------
 .../james/transport/mailets/LogMessage.java     |  1 +
 .../core/MimeMessageCopyOnWriteProxyTest.java   |  6 +-
 .../james/core/MimeMessageWrapperTest.java      | 20 ++---
 .../org/apache/james/GuiceJamesServerTest.java  |  7 +-
 .../util/bayesian/JDBCBayesianAnalyzer.java     |  6 ++
 .../mailrepository/jcr/JCRMailRepository.java   | 17 ++--
 .../domainlist/lib/AbstractDomainListTest.java  |  8 +-
 .../AbstractMailRepositoryTest.java             |  9 +--
 .../dnsservice/dnsjava/DNSJavaServiceTest.java  |  4 +
 .../AbstractStateCompositeProcessorTest.java    |  2 +
 .../transport/mailets/BayesianAnalysis.java     |  1 +
 .../mailets/BayesianAnalysisFeeder.java         |  4 +-
 .../transport/mailets/WhiteListManager.java     |  3 +
 .../SenderAuthIdentifyVerificationRcptHook.java |  4 +-
 .../apache/james/smtpserver/SMTPServerTest.java |  9 ++-
 .../james/queue/api/mock/MockMailQueue.java     | 16 +---
 19 files changed, 82 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
index 22113d8..d163233 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
@@ -37,14 +37,15 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CassandraMailboxMapperTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CassandraMailboxMapperTest.class);
 
     public static final int MAX_RETRY = 10;
     public static final int UID_VALIDITY = 52;
     public static final MailboxPath MAILBOX_PATH = new MailboxPath("#private", "user", "name");
-    public static final int THREAD_COUNT = 10;
-    public static final int OPERATION_COUNT = 10;
     private CassandraCluster cassandra;
     private CassandraMailboxPathDAO mailboxPathDAO;
     private CassandraMailboxMapper testee;
@@ -75,6 +76,7 @@ public class CassandraMailboxMapperTest {
             testee.save(newMailbox);
             fail("TooLongMailboxNameException expected");
         } catch (TooLongMailboxNameException e) {
+            LOGGER.info("Ignored error", e);
         }
 
         Optional<CassandraIdAndPath> cassandraIdAndPath = mailboxPathDAO.retrieveId(MAILBOX_PATH).get();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/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 e6c3514..9a8e0db 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
@@ -35,6 +35,7 @@ import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -305,16 +306,8 @@ public class MaildirMessageMapper extends AbstractMessageMapper {
         } catch (IOException ioe) {
             throw new MailboxException("Failure while save MailboxMessage " + message + "
in Mailbox " + mailbox, ioe);
         } finally {
-            try {
-                if (fos != null)
-                    fos.close();
-            } catch (IOException e) {
-            }
-            try {
-                if (input != null)
-                    input.close();
-            } catch (IOException e) {
-            }
+            IOUtils.closeQuietly(fos);
+            IOUtils.closeQuietly(input);
         }
         File newMessageFile = null;
         // delivered via SMTP, goes to ./new without flags

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
b/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
index 3b86b88..e8fe602 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/ClamAVScan.java
@@ -20,6 +20,7 @@
 
 package org.apache.james.transport.mailets;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -703,85 +704,16 @@ public class ClamAVScan extends GenericMailet {
             log("Exception caught calling CLAMD on " + socket.getInetAddress() + ": " + ex.getMessage(),
ex);
             throw new MessagingException("Exception caught", ex);
         } finally {
-            shutdownReader(reader);
-            shutdownWriter(writer);
-            shutdownStream(bos);
-            shutdownSocket(streamSocket);
-            shutdownSocket(socket);
+            IOUtils.closeQuietly(reader);
+            IOUtils.closeQuietly(writer);
+            IOUtils.closeQuietly(bos);
+            IOUtils.closeQuietly(streamSocket);
+            IOUtils.closeQuietly(socket);
         }
 
     }
 
     /**
-     * Unconditionally close an <code>OutputStream</code>.
-     * Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored.
-     *
-     * @param output A (possibly null) OutputStream
-     */
-    private static void shutdownStream(OutputStream output) {
-        if (null == output) {
-            return;
-        }
-
-        try {
-            output.close();
-        } catch (IOException ignored) {
-        }
-    }
-
-    /**
-     * Unconditionally close an <code>Socket</code>.
-     * Equivalent to {@link Socket#close()}, except any exceptions will be ignored.
-     *
-     * @param socket A (possibly null) Socket
-     */
-    private static void shutdownSocket(Socket socket) {
-        if (null == socket) {
-            return;
-        }
-
-        try {
-            socket.close();
-        } catch (IOException ioe) {
-        }
-    }
-
-    /**
-     * Unconditionally close an <code>Writer</code>.
-     * Equivalent to {@link Writer#close()}, except any exceptions will be ignored.
-     *
-     * @param output A (possibly null) Writer
-     */
-    private void shutdownWriter(Writer output) {
-        if (null == output) {
-            return;
-        }
-
-        try {
-            output.close();
-        } catch (IOException ioe) {
-        }
-    }
-
-
-    /**
-     * Unconditionally close an <code>Reader</code>.
-     * Equivalent to {@link Reader#close()}, except any exceptions will be ignored.
-     *
-     * @param input A (possibly null) Reader
-     */
-    private void shutdownReader(Reader input) {
-        if (null == input) {
-            return;
-        }
-
-        try {
-            input.close();
-        } catch (IOException ioe) {
-        }
-    }
-
-    /**
      * Tries to "ping" all the CLAMD daemons to
      * check if they are up and accepting requests.
      */
@@ -872,10 +804,11 @@ public class ClamAVScan extends GenericMailet {
     protected final int getStreamPortFromAnswer(String answer) throws ConnectException {
         int port = -1;
         if (answer != null && answer.startsWith(STREAM_PORT_STRING)) {
+            String portSubstring = answer.substring(STREAM_PORT_STRING.length());
             try {
-                port = Integer.parseInt(answer.substring(STREAM_PORT_STRING.length()));
+                port = Integer.parseInt(portSubstring);
             } catch (NumberFormatException nfe) {
-
+                log("Can not parse port from substring " + portSubstring);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java
b/mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java
index c1c065f..ce71916 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/LogMessage.java
@@ -63,6 +63,7 @@ public class LogMessage extends GenericMailet {
             bodyMax = (getInitParameter("maxBody") == null) ? 0 : Integer.parseInt(getInitParameter("maxBody"));
             comment = getInitParameter("comment");
         } catch (Exception e) {
+            log("Caught exception while initializing LogMessage", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
b/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
index 431b1c5..c9c2e42 100644
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
+++ b/server/container/core/src/test/java/org/apache/james/core/MimeMessageCopyOnWriteProxyTest.java
@@ -40,11 +40,7 @@ public class MimeMessageCopyOnWriteProxyTest extends MimeMessageFromStreamTest
{
 
     @Override
     protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        MimeMessageInputStreamSource mmis = null;
-        try {
-            mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
-        } catch (MessagingException e) {
-        }
+        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new
SharedByteArrayInputStream(sources.getBytes()));
         return new MimeMessageCopyOnWriteProxy(mmis);
         // return new MimeMessage(Session.getDefaultInstance(new
         // Properties()),new ByteArrayInputStream(sources.getBytes()));

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
b/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
index 64c6723..75a29ba 100644
--- a/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
+++ b/server/container/core/src/test/java/org/apache/james/core/MimeMessageWrapperTest.java
@@ -40,7 +40,9 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.mailet.base.RFC2822Headers;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * Test the subject folding issue.
@@ -87,13 +89,12 @@ public class MimeMessageWrapperTest extends MimeMessageFromStreamTest
{
     final String sep = "\r\n\r\n";
     final String body = "bar\r\n";
 
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
     @Override
     protected MimeMessage getMessageFromSources(String sources) throws Exception {
-        MimeMessageInputStreamSource mmis = null;
-        try {
-            mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
-        } catch (MessagingException e) {
-        }
+        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test", new
SharedByteArrayInputStream(sources.getBytes()));
         return new TestableMimeMessageWrapper(mmis);
     }
 
@@ -130,11 +131,10 @@ public class MimeMessageWrapperTest extends MimeMessageFromStreamTest
{
     @Test
     public void testDeferredHeaderLoading() throws MessagingException, IOException {
         mw.setHeadersLoadable(false);
-        try {
-            assertEquals("foo", mw.getSubject());
-            fail("subject should not be loadable here, headers loading is disabled");
-        } catch (IllegalStateException e) {
-        }
+
+        expectedException.expect(IllegalStateException.class);
+
+        mw.getSubject();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/container/guice/memory-guice/src/test/java/org/apache/james/GuiceJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/GuiceJamesServerTest.java
b/server/container/guice/memory-guice/src/test/java/org/apache/james/GuiceJamesServerTest.java
index 59327bb..4bcc2b5 100644
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/GuiceJamesServerTest.java
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/GuiceJamesServerTest.java
@@ -11,11 +11,14 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableList;
 import com.google.inject.multibindings.Multibinder;
 
 public class GuiceJamesServerTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(GuiceJamesServerTest.class);
 
     public static final ConfigurationPerformer THROWING_CONFIGURATION_PERFORMER = new ConfigurationPerformer()
{
         @Override
@@ -109,7 +112,9 @@ public class GuiceJamesServerTest {
 
             try {
                 overWrittenServer.start();
-            } catch (RuntimeException e) {}
+            } catch (RuntimeException e) {
+                LOGGER.info("Ignored expected exception", e);
+            }
 
             assertThat(overWrittenServer.isStarted()).isFalse();
         } finally {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/container/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
b/server/container/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
index 4abe7e1..0987b73 100644
--- a/server/container/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
+++ b/server/container/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
@@ -21,6 +21,8 @@ package org.apache.james.util.bayesian;
 
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -47,6 +49,8 @@ import java.sql.DatabaseMetaData;
 
 abstract public class JDBCBayesianAnalyzer extends BayesianAnalyzer {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(JDBCBayesianAnalyzer.class);
+
     /** Public object representing a lock on database activity. */
     public final static String DATABASE_LOCK = "database lock";
 
@@ -213,6 +217,7 @@ abstract public class JDBCBayesianAnalyzer extends BayesianAnalyzer {
                 try {
                     rs.close();
                 } catch (java.sql.SQLException se) {
+                    LOGGER.info("Exception ignored", se);
                 }
 
                 rs = null;
@@ -222,6 +227,7 @@ abstract public class JDBCBayesianAnalyzer extends BayesianAnalyzer {
                 try {
                     pstmt.close();
                 } catch (java.sql.SQLException se) {
+                    LOGGER.info("Exception ignored", se);
                 }
 
                 pstmt = null;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
b/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
index a380c97..9e4c7bd 100644
--- a/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
+++ b/server/data/data-jcr/src/main/java/org/apache/james/mailrepository/jcr/JCRMailRepository.java
@@ -63,11 +63,15 @@ import org.apache.james.mailrepository.lib.AbstractMailRepository;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import sun.misc.IOUtils;
 
 /**
  * Mail repository that is backed by a JCR content repository.
  */
 public class JCRMailRepository extends AbstractMailRepository implements MailRepository {
+    private static final Logger LOGGER = LoggerFactory.getLogger(JCRMailRepository.class);
 
     private final static String MAIL_PATH = "mailrepository";
 
@@ -75,7 +79,6 @@ public class JCRMailRepository extends AbstractMailRepository implements
MailRep
     private SimpleCredentials creds;
     private String workspace;
 
-    private Logger logger;
 
     @Inject
     public void setRepository(Repository repository) {
@@ -526,11 +529,9 @@ public class JCRMailRepository extends AbstractMailRepository implements
MailRep
                 try {
                     message.writeTo(output);
                 } catch (Exception e) {
+                    LOGGER.info("Exception ignored", e);
                 } finally {
-                    try {
-                        output.close();
-                    } catch (IOException e) {
-                    }
+                    org.apache.commons.io.IOUtils.closeQuietly(output);
                 }
             }
         }.start();
@@ -617,9 +618,9 @@ public class JCRMailRepository extends AbstractMailRepository implements
MailRep
                         nodes.nextNode().remove();
                     }
                     session.save();
-                    logger.info("Mail " + key + " removed from repository");
+                    LOGGER.info("Mail " + key + " removed from repository");
                 } else {
-                    logger.warn("Mail " + key + " not found");
+                    LOGGER.warn("Mail " + key + " not found");
                 }
             } finally {
                 session.logout();
@@ -654,7 +655,7 @@ public class JCRMailRepository extends AbstractMailRepository implements
MailRep
                     setMail(node, mail);
                 }
                 session.save();
-                logger.info("Mail " + mail.getName() + " stored in repository");
+                LOGGER.info("Mail " + mail.getName() + " stored in repository");
             } finally {
                 session.logout();
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
index 511d9c0..2f4b66d 100644
--- a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListTest.java
@@ -32,11 +32,15 @@ import org.apache.james.domainlist.api.DomainListException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableList;
 
 public abstract class AbstractDomainListTest {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDomainListTest.class);
+
     private final String DOMAIN_1 = "domain1.tld";
     private final String DOMAIN_2 = "domain2.tld";
     private final String DOMAIN_3 = "domain3.tld";
@@ -110,7 +114,7 @@ public abstract class AbstractDomainListTest {
         try {
             domainList.removeDomain(DOMAIN_2);
         } catch (DomainListException e) {
-
+            LOGGER.info("Ignored error", e);
         }
         assertThat(domainList.getDomains()).containsOnly(DOMAIN_1);
     }
@@ -169,7 +173,7 @@ public abstract class AbstractDomainListTest {
         try {
             domainList.removeDomain(domain);
         } catch(DomainListException e) {
-
+            LOGGER.info("Ignored error", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
b/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
index 2b73354..8619229 100644
--- a/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/mailrepository/AbstractMailRepositoryTest.java
@@ -52,14 +52,9 @@ public abstract class AbstractMailRepositoryTest {
 
     @Before
     public void setUp() throws Exception {
-
         mailRepository = getMailRepository();
-        MimeMessageInputStreamSource mmis = null;
-        try {
-            mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream((content
+ sep + body).
-                    getBytes()));
-        } catch (MessagingException e) {
-        }
+        MimeMessageInputStreamSource mmis = new MimeMessageInputStreamSource("test",
+            new SharedByteArrayInputStream((content + sep + body).getBytes()));
         mimeMessage = new MimeMessageCopyOnWriteProxy(mmis);
         Collection<MailAddress> recipients = new ArrayList<MailAddress>();
         recipients.add(new MailAddress("rec1", "domain.com"));

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
----------------------------------------------------------------------
diff --git a/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
b/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
index 0a9f522..fa59ed8 100644
--- a/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
+++ b/server/dns-service/dnsservice-dnsjava/src/test/java/org/apache/james/dnsservice/dnsjava/DNSJavaServiceTest.java
@@ -32,6 +32,8 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
+
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xbill.DNS.Cache;
 import org.xbill.DNS.DClass;
@@ -47,6 +49,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 
 public class DNSJavaServiceTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(DNSJavaServiceTest.class);
 
     private TestableDNSServer dnsServer;
     private static final byte[] DNS_SERVER_CONFIG = ("<dnsserver>" +
@@ -142,6 +145,7 @@ public class DNSJavaServiceTest {
             res.add("");
             fail("MX Collection should not be modifiable");
         } catch (UnsupportedOperationException e) {
+            LOGGER.info("Ignored error", e);
         }
         assertEquals(1, res.size());
         assertEquals("mail.test-zone.com.", res.iterator().next());

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
index 2a70f36..a654b59 100644
--- a/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
+++ b/server/mailet/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
@@ -36,6 +36,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractStateCompositeProcessorTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractStateCompositeProcessorTest.class);
 
     @Test
     public void testChooseRightProcessor() throws Exception {
@@ -82,6 +83,7 @@ public abstract class AbstractStateCompositeProcessorTest {
         processor.service(mail4);
         fail("should fail because of no mapping to a processor for this state");
         } catch (MessagingException e) {
+            LOGGER.info("Ignored error", e);
         }
 
     } finally {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
index bc6a213..6f3d28d 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysis.java
@@ -397,6 +397,7 @@ public class BayesianAnalysis extends GenericMailet {
                 message.setSubject(toAppend + " " + subject, "iso-8859-1");
             }
         } catch (MessagingException ex) {
+            log("Ignored error while modifying subject", ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
index edab232..9bcbf3a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/BayesianAnalysisFeeder.java
@@ -325,6 +325,7 @@ public class BayesianAnalysisFeeder extends GenericMailet {
                     dbUpdated = false;
                 }
             } catch (Exception e) {
+                log("Ignored error while rolling back", e);
             }
             theJDBCUtil.closeJDBCConnection(conn);
         }
@@ -338,7 +339,8 @@ public class BayesianAnalysisFeeder extends GenericMailet {
             Header header = headers.nextElement();
             try {
                 message.removeHeader(header.getName());
-            } catch (javax.mail.MessagingException me) {
+            } catch (MessagingException me) {
+                log("Ignored error while removing header", me);
             }
         }
         message.saveChanges();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
index e17c6eb..2af44bd 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
@@ -372,6 +372,7 @@ public class WhiteListManager extends GenericMailet {
                     dbUpdated = false;
                 }
             } catch (Exception e) {
+                log("Ignored exception upon rollback", e);
             }
             theJDBCUtil.closeJDBCConnection(conn);
         }
@@ -540,6 +541,7 @@ public class WhiteListManager extends GenericMailet {
                     dbUpdated = false;
                 }
             } catch (Exception e) {
+                log("Ignored exception upon rollback", e);
             }
             theJDBCUtil.closeJDBCConnection(conn);
         }
@@ -660,6 +662,7 @@ public class WhiteListManager extends GenericMailet {
                     dbUpdated = false;
                 }
             } catch (Exception e) {
+                log("Ignored exception upon rollback", e);
             }
             theJDBCUtil.closeJDBCConnection(conn);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
index 721c698..8f9e027 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
@@ -32,6 +32,8 @@ import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 
+import com.google.common.base.Throwables;
+
 /**
  * Handler which check if the authenticated user is incorrect
  */
@@ -88,8 +90,8 @@ public class SenderAuthIdentifyVerificationRcptHook extends AbstractSenderAuthId
         try {
             return users.supportVirtualHosting();
         } catch (UsersRepositoryException e) {
+            throw Throwables.propagate(e);
         }
-        return false;
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 40afa1c..e0af73b 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -168,7 +168,7 @@ public class SMTPServerTest {
 
     private static final long HALF_SECOND = 500;
     private static final int MAX_ITERATIONS = 10;
-    private static final Logger log = LoggerFactory.getLogger(SMTPServerTest.class.getName());
+    private static final Logger LOGGER = LoggerFactory.getLogger(SMTPServerTest.class);
 
     protected SMTPTestConfiguration smtpConfiguration;
     protected final InMemoryUsersRepository usersRepository = new InMemoryUsersRepository();
@@ -370,6 +370,7 @@ public class SMTPServerTest {
             Thread.sleep(3000);
             fail("Shold disconnect connection 3");
         } catch (Exception e) {
+            LOGGER.info("Ignored error", e);
         }
 
         ensureIsDisconnected(smtpProtocol);
@@ -627,17 +628,17 @@ public class SMTPServerTest {
         SMTPClient smtp = new SMTPClient();
         InetSocketAddress bindedAddress = new ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtp.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort());
-        if (log.isDebugEnabled()) {
+        if (LOGGER.isDebugEnabled()) {
             smtp.addProtocolCommandListener(new ProtocolCommandListener() {
 
                 @Override
                 public void protocolCommandSent(ProtocolCommandEvent event) {
-                    log.debug("> " + event.getMessage().trim());
+                    LOGGER.debug("> " + event.getMessage().trim());
                 }
 
                 @Override
                 public void protocolReplyReceived(ProtocolCommandEvent event) {
-                    log.debug("< " + event.getMessage().trim());
+                    LOGGER.debug("< " + event.getMessage().trim());
                 }
             });
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73426233/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
index 9af5fae..4ff7d13 100644
--- a/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
+++ b/server/queue/queue-api/src/test/java/org/apache/james/queue/api/mock/MockMailQueue.java
@@ -28,6 +28,8 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import javax.mail.MessagingException;
+
+import org.apache.commons.io.IOUtils;
 import org.apache.james.core.MailImpl;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.mailet.Mail;
@@ -94,18 +96,8 @@ public class MockMailQueue implements MailQueue {
             log.error("", ex);
             throw new RuntimeException(ex);
         } finally {
-            try {
-                if (bais != null) {
-                    bais.close();
-                }
-            } catch (IOException ex) {
-            }
-            try {
-                if (baos != null) {
-                    baos.close();
-                }
-            } catch (IOException ex) {
-            }
+            IOUtils.closeQuietly(bais);
+            IOUtils.closeQuietly(baos);
         }
     }
 


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