james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1092720 - in /james/server/trunk: container-spring/src/main/java/org/apache/james/container/spring/mailbox/ data-library/src/main/java/org/apache/james/rrt/lib/ fetchmail/src/main/java/org/apache/james/fetchmail/ file/src/main/java/org/apa...
Date Fri, 15 Apr 2011 14:31:21 GMT
Author: felixk
Date: Fri Apr 15 14:31:20 2011
New Revision: 1092720

URL: http://svn.apache.org/viewvc?rev=1092720&view=rev
Log:
Performance improvements suggested by findbugs-report

Modified:
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
    james/server/trunk/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
    james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
    james/server/trunk/file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
    james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
    james/server/trunk/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
    james/server/trunk/util/src/main/java/org/apache/james/util/TimeConverter.java
    james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/BayesianAnalyzer.java
    james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
    james/server/trunk/util/src/main/java/org/apache/james/util/sql/SqlResources.java

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
Fri Apr 15 14:31:20 2011
@@ -20,7 +20,6 @@ package org.apache.james.container.sprin
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.annotation.Resource;
@@ -58,11 +57,9 @@ public class MailboxCopierManagement imp
 
         Map<String, MailboxManager> beans = context.getBeansOfType(MailboxManager.class);
 
-        Iterator<String> keys = beans.keySet().iterator();
-        while (keys.hasNext()) {
-            String key = keys.next();
-            String name = beans.get(key).getClass().getName();
-            bMap.put(key, name);
+        for (Map.Entry<String, MailboxManager> entry : beans.entrySet()) {
+            String name = entry.getValue().getClass().getName();
+            bMap.put(entry.getKey(), name);
         }
 
         return bMap;

Modified: james/server/trunk/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
(original)
+++ james/server/trunk/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
Fri Apr 15 14:31:20 2011
@@ -99,15 +99,11 @@ public class RecipientRewriteTableUtil {
     static public String replaceParameters(String str, Map<String, String> parameters)
{
         if (str != null && parameters != null) {
             // Do parameter replacements for this string resource.
-            Iterator<String> paramNames = parameters.keySet().iterator();
             StringBuffer replaceBuffer = new StringBuffer(64);
-            while (paramNames.hasNext()) {
-                String paramName = (String) paramNames.next();
-                String paramValue = (String) parameters.get(paramName);
-                replaceBuffer.append("${").append(paramName).append("}");
-                str = substituteSubString(str, replaceBuffer.toString(), paramValue);
-                if (paramNames.hasNext())
-                    replaceBuffer.setLength(0);
+            for (Map.Entry<String, String> entry : parameters.entrySet()) {
+                replaceBuffer.setLength(0);
+                replaceBuffer.append("${").append(entry.getKey()).append("}");
+                str = substituteSubString(str, replaceBuffer.toString(), entry.getValue());
             }
         }
 

Modified: james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
(original)
+++ james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
Fri Apr 15 14:31:20 2011
@@ -1257,7 +1257,7 @@ public class MessageProcessor extends Pr
             aMail.setAttribute(getAttributePrefix() + "isRecipientNotFound", true);
 
         if (isMaxMessageSizeExceeded().booleanValue())
-            aMail.setAttribute(getAttributePrefix() + "isMaxMessageSizeExceeded", new Integer(getMessageIn().getSize()).toString());
+            aMail.setAttribute(getAttributePrefix() + "isMaxMessageSizeExceeded", Integer.toString(getMessageIn().getSize()));
 
         if (isRemoteReceivedHeaderInvalid().booleanValue())
             aMail.setAttribute(getAttributePrefix() + "isRemoteReceivedHeaderInvalid", true);

Modified: james/server/trunk/file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
(original)
+++ james/server/trunk/file/src/main/java/org/apache/james/mailrepository/file/MBoxMailRepository.java
Fri Apr 15 14:31:20 2011
@@ -516,7 +516,7 @@ public class MBoxMailRepository implemen
                 public MimeMessage messageAction(String messageSeparator, String bodyText,
long messageStart) {
                     try {
                         String key = generateKeyValue(bodyText);
-                        mList.put(key, new Long(messageStart));
+                        mList.put(key, Long.valueOf(messageStart));
                         if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
                             getLogger().debug(this.getClass().getName() + " Key " + key +
" at " + messageStart);
                         }

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
(original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
Fri Apr 15 14:31:20 2011
@@ -64,6 +64,7 @@ import java.util.Date;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -593,15 +594,13 @@ public class RemoteDelivery extends Gene
             // Store the new message containers, organized by server, in the
             // outgoing mail repository
             String name = mail.getName();
-            for (Iterator<String> i = targets.keySet().iterator(); i.hasNext();) {
-                String host = i.next();
-                Collection<MailAddress> rec = targets.get(host);
+            for (Map.Entry<String, Collection<MailAddress>> entry : targets.entrySet())
{
                 if (isDebug) {
-                    StringBuilder logMessageBuffer = new StringBuilder(128).append("Sending
mail to ").append(rec).append(" on host ").append(host);
+                    StringBuilder logMessageBuffer = new StringBuilder(128).append("Sending
mail to ").append(entry.getValue()).append(" on host ").append(entry.getKey());
                     log(logMessageBuffer.toString());
                 }
-                mail.setRecipients(rec);
-                StringBuilder nameBuffer = new StringBuilder(128).append(name).append("-to-").append(host);
+                mail.setRecipients(entry.getValue());
+                StringBuilder nameBuffer = new StringBuilder(128).append(name).append("-to-").append(entry.getKey());
                 mail.setName(nameBuffer.toString());
                 try {
                     queue.enQueue(mail);

Modified: james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
(original)
+++ james/server/trunk/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueue.java
Fri Apr 15 14:31:20 2011
@@ -217,10 +217,8 @@ public class ActiveMQMailQueue extends J
                 Queue queue = session.createQueue(queuename);
 
                 producer = session.createProducer(queue);
-                Iterator<String> keys = props.keySet().iterator();
-                while (keys.hasNext()) {
-                    String key = keys.next();
-                    blobMessage.setObjectProperty(key, props.get(key));
+                for (Map.Entry<String, Object> entry : props.entrySet()) {
+                    blobMessage.setObjectProperty(entry.getKey(), entry.getValue());
                 }
                 producer.send(blobMessage, Message.DEFAULT_DELIVERY_MODE, msgPrio, Message.DEFAULT_TIME_TO_LIVE);
             } else {

Modified: james/server/trunk/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
(original)
+++ james/server/trunk/queue-jms/src/main/java/org/apache/james/queue/jms/JMSMailQueue.java
Fri Apr 15 14:31:20 2011
@@ -254,10 +254,8 @@ public class JMSMailQueue implements Man
             producer = session.createProducer(queue);
             ObjectMessage message = session.createObjectMessage();
 
-            Iterator<String> keys = props.keySet().iterator();
-            while (keys.hasNext()) {
-                String key = keys.next();
-                message.setObjectProperty(key, props.get(key));
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                message.setObjectProperty(entry.getKey(), entry.getValue());
             }
 
             long size = mail.getMessageSize();

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
Fri Apr 15 14:31:20 2011
@@ -282,7 +282,7 @@ public final class DataLineJamesMessageH
          */
         public int getSize() {
             try {
-                return new Long(mail.getMessageSize()).intValue();
+                return (int)mail.getMessageSize();
             } catch (MessagingException e) {
                 return -1;
             }

Modified: james/server/trunk/util/src/main/java/org/apache/james/util/TimeConverter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/main/java/org/apache/james/util/TimeConverter.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/util/src/main/java/org/apache/james/util/TimeConverter.java (original)
+++ james/server/trunk/util/src/main/java/org/apache/james/util/TimeConverter.java Fri Apr
15 14:31:20 2011
@@ -32,22 +32,22 @@ public class TimeConverter {
 
     static {
         // add allowed units and their respective multiplier
-        multipliers.put("msec", new Integer(1));
-        multipliers.put("msecs", new Integer(1));
-        multipliers.put("sec", new Integer(1000));
-        multipliers.put("secs", new Integer(1000));
-        multipliers.put("minute", new Integer(1000 * 60));
-        multipliers.put("minutes", new Integer(1000 * 60));
-        multipliers.put("hour", new Integer(1000 * 60 * 60));
-        multipliers.put("hours", new Integer(1000 * 60 * 60));
-        multipliers.put("day", new Integer(1000 * 60 * 60 * 24));
-        multipliers.put("days", new Integer(1000 * 60 * 60 * 24));
+        multipliers.put("msec", Integer.valueOf(1));
+        multipliers.put("msecs", Integer.valueOf(1));
+        multipliers.put("sec", Integer.valueOf(1000));
+        multipliers.put("secs", Integer.valueOf(1000));
+        multipliers.put("minute", Integer.valueOf(1000 * 60));
+        multipliers.put("minutes", Integer.valueOf(1000 * 60));
+        multipliers.put("hour", Integer.valueOf(1000 * 60 * 60));
+        multipliers.put("hours", Integer.valueOf(1000 * 60 * 60));
+        multipliers.put("day", Integer.valueOf(1000 * 60 * 60 * 24));
+        multipliers.put("days", Integer.valueOf(1000 * 60 * 60 * 24));
 
         PATTERN = Pattern.compile(PATTERN_STRING);
 
     }
 
-    // Get sure it can not be instanciated
+    // Get sure it can not be instantiated
     private TimeConverter() {
     }
 

Modified: james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/BayesianAnalyzer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/BayesianAnalyzer.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/BayesianAnalyzer.java
(original)
+++ james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/BayesianAnalyzer.java
Fri Apr 15 14:31:20 2011
@@ -387,9 +387,9 @@ public class BayesianAnalyzer {
                 Integer value = null;
 
                 if (target.containsKey(token)) {
-                    value = new Integer(((Integer) target.get(token)).intValue() + 1);
+                    value = Integer.valueOf(((Integer) target.get(token)).intValue() + 1);
                 } else {
-                    value = new Integer(1);
+                    value = Integer.valueOf(1);
                 }
 
                 target.put(token, value);

Modified: james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
(original)
+++ james/server/trunk/util/src/main/java/org/apache/james/util/bayesian/JDBCBayesianAnalyzer.java
Fri Apr 15 14:31:20 2011
@@ -168,7 +168,7 @@ abstract public class JDBCBayesianAnalyz
                 int count = rs.getInt(2);
                 // to reduce memory, use the token only if the count is > 1
                 if (count > 1) {
-                    ham.put(token, new Integer(count));
+                    ham.put(token, Integer.valueOf(count));
                 }
             }
             // Verbose.

Modified: james/server/trunk/util/src/main/java/org/apache/james/util/sql/SqlResources.java
URL: http://svn.apache.org/viewvc/james/server/trunk/util/src/main/java/org/apache/james/util/sql/SqlResources.java?rev=1092720&r1=1092719&r2=1092720&view=diff
==============================================================================
--- james/server/trunk/util/src/main/java/org/apache/james/util/sql/SqlResources.java (original)
+++ james/server/trunk/util/src/main/java/org/apache/james/util/sql/SqlResources.java Fri
Apr 15 14:31:20 2011
@@ -32,7 +32,6 @@ import java.io.InputStream;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.regex.Pattern;
 
@@ -223,15 +222,11 @@ public class SqlResources {
             String sqlString = sqlElement.getFirstChild().getNodeValue();
 
             // Do parameter replacements for this sql string.
-            Iterator<String> paramNames = parameters.keySet().iterator();
             StringBuilder replaceBuffer = new StringBuilder(64);
-            while (paramNames.hasNext()) {
-                String paramName = (String) paramNames.next();
-                String paramValue = (String) parameters.get(paramName);
-                replaceBuffer.append("${").append(paramName).append("}");
-                sqlString = substituteSubString(sqlString, replaceBuffer.toString(), paramValue);
-                if (paramNames.hasNext())
-                    replaceBuffer.setLength(0);
+            for (Map.Entry<String, String> entry : parameters.entrySet()) {
+                replaceBuffer.setLength(0);
+                replaceBuffer.append("${").append(entry.getKey()).append("}");
+                sqlString = substituteSubString(sqlString, replaceBuffer.toString(), entry.getValue());
             }
 
             // See if we already have registered a string of this value



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