james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r812240 - in /james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver: ./ core/ core/esmtp/
Date Mon, 07 Sep 2009 17:59:15 GMT
Author: rdonkin
Date: Mon Sep  7 17:59:15 2009
New Revision: 812240

URL: http://svn.apache.org/viewvc?rev=812240&view=rev
Log:
Switch from StringBuffer to StringBuilder, added some generics and corrected some documentation
typos

Modified:
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPResponse.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AddDefaultAttributesMessageHook.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SendMailHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SetMimeHeaderHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPResponse.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPResponse.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPResponse.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPResponse.java
Mon Sep  7 17:59:15 2009
@@ -34,7 +34,7 @@
     
 
     public SMTPResponse() {
-        //TODO: Should we remove this constructur to force the developers to specify all
needed informations ? 
+        //TODO: Should we remove this constructor to force the developers to specify all
needed informations ? 
     }
        
     /**

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AddDefaultAttributesMessageHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AddDefaultAttributesMessageHook.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AddDefaultAttributesMessageHook.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AddDefaultAttributesMessageHook.java
Mon Sep  7 17:59:15 2009
@@ -44,8 +44,9 @@
     public HookResult onMessage(SMTPSession session, Mail mail) {
         if (mail instanceof MailImpl) {
             
-            ((MailImpl) mail).setRemoteHost(session.getRemoteHost());
-            ((MailImpl) mail).setRemoteAddr(session.getRemoteIPAddress());
+            final MailImpl mailImpl = (MailImpl) mail;
+            mailImpl.setRemoteHost(session.getRemoteHost());
+            mailImpl.setRemoteAddr(session.getRemoteIPAddress());
             if (session.getUser() != null) {
                 mail.setAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME, session.getUser());
             }

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java
Mon Sep  7 17:59:15 2009
@@ -61,7 +61,7 @@
     public List<String> getHandlers() {
         List<String> commands = new LinkedList<String>();
         
-        // Insert the basecommands in the Map
+        // Insert the base commands in the Map
         commands.add(WELCOMEMESSAGEHANDLER);
         commands.add(COMMANDDISPATCHER);
         commands.add(AUTHCMDHANDLER);

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
Mon Sep  7 17:59:15 2009
@@ -137,6 +137,7 @@
      * @param session SMTP session object
      * @param argument the argument passed in with the command by the SMTP client
      */
+    @SuppressWarnings("unchecked")
     private SMTPResponse doDATA(SMTPSession session, String argument) {
 //        long maxMessageSize = session.getConfigurationData().getMaxMessageSize();
 //        if (maxMessageSize > 0) {
@@ -218,7 +219,7 @@
      * @throws MessagingException
      */
     private MailHeaders createNewReceivedMailHeaders(SMTPSession session) throws MessagingException
{
-        StringBuffer headerLineBuffer = new StringBuffer(512);
+        StringBuilder headerLineBuffer = new StringBuilder(512);
         MailHeaders newHeaders = new MailHeaders();
         
         String heloMode = (String) session.getConnectionState().get(SMTPSession.CURRENT_HELO_MODE);
@@ -251,7 +252,7 @@
      
         // Check if EHLO was used 
         if ("EHLO".equals(heloMode)) {
-            // Not succesfull auth
+            // Not successful auth
             if (session.getUser() == null) {
                 headerLineBuffer.append("ESMTP");  
             } else {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
Mon Sep  7 17:59:15 2009
@@ -119,7 +119,7 @@
             } else {
                 // TODO: maybe we should handle the Header/Body recognition here
                 // and if needed let a filter to cache the headers to apply some
-                // transormation before writing them to output.
+                // transformation before writing them to output.
                 out.write(line);
             }
             out.flush();
@@ -197,8 +197,8 @@
     /**
      * @see org.apache.james.smtpserver.ExtensibleHandler#getMarkerInterfaces()
      */
-    public List getMarkerInterfaces() {
-        List classes = new LinkedList();
+    public List<Class<?>> getMarkerInterfaces() {
+        List<Class<?>> classes = new LinkedList<Class<?>>();
         classes.add(MessageHook.class);
         classes.add(HookResultHook.class);
         return classes;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
Mon Sep  7 17:59:15 2009
@@ -204,7 +204,7 @@
                     } else {
                         // Unexpected option attached to the Mail command
                         if (session.getLogger().isDebugEnabled()) {
-                            StringBuffer debugBuffer = new StringBuffer(128)
+                            StringBuilder debugBuffer = new StringBuilder(128)
                                     .append(
                                             "MAIL command had unrecognized/unexpected option
")
                                     .append(mailOptionName).append(
@@ -218,7 +218,7 @@
             if (session.useAddressBracketsEnforcement()
                     && (!sender.startsWith("<") || !sender.endsWith(">")))
{
                 if (session.getLogger().isErrorEnabled()) {
-                    StringBuffer errorBuffer = new StringBuffer(128).append(
+                    StringBuilder errorBuffer = new StringBuilder(128).append(
                             "Error parsing sender address: ").append(sender)
                             .append(": did not start and end with < >");
                     session.getLogger().error(errorBuffer.toString());
@@ -250,7 +250,7 @@
                     senderAddress = new MailAddress(sender);
                 } catch (Exception pe) {
                     if (session.getLogger().isErrorEnabled()) {
-                        StringBuffer errorBuffer = new StringBuffer(256)
+                        StringBuilder errorBuffer = new StringBuilder(256)
                                 .append("Error parsing sender address: ")
                                 .append(sender).append(": ").append(
                                         pe.getMessage());

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
Mon Sep  7 17:59:15 2009
@@ -73,12 +73,13 @@
      * @param argument
      *            the argument passed in with the command by the SMTP client
      */
+    @SuppressWarnings("unchecked")
     protected SMTPResponse doCoreCmd(SMTPSession session, String command,
             String parameters) {
-        Collection rcptColl = (Collection) session.getState().get(
+        Collection<MailAddress> rcptColl = (Collection<MailAddress>) session.getState().get(
                 SMTPSession.RCPT_LIST);
         if (rcptColl == null) {
-            rcptColl = new ArrayList();
+            rcptColl = new ArrayList<MailAddress>();
         }
         MailAddress recipientAddress = (MailAddress) session.getState().get(
                 CURRENT_RECIPIENT);
@@ -142,7 +143,7 @@
         if (session.useAddressBracketsEnforcement()
                 && (!recipient.startsWith("<") || !recipient.endsWith(">")))
{
             if (session.getLogger().isErrorEnabled()) {
-                StringBuffer errorBuffer = new StringBuffer(192).append(
+                StringBuilder errorBuffer = new StringBuilder(192).append(
                         "Error parsing recipient address: ").append(
                         "Address did not start and end with < >").append(
                         getContext(session, null, recipient));
@@ -171,7 +172,7 @@
             recipientAddress = new MailAddress(recipient);
         } catch (Exception pe) {
             if (session.getLogger().isErrorEnabled()) {
-                StringBuffer errorBuffer = new StringBuffer(192).append(
+                StringBuilder errorBuffer = new StringBuilder(192).append(
                         "Error parsing recipient address: ").append(
                         getContext(session, recipientAddress, recipient))
                         .append(pe.getMessage());
@@ -203,7 +204,7 @@
                 }
                 // Unexpected option attached to the RCPT command
                 if (session.getLogger().isDebugEnabled()) {
-                    StringBuffer debugBuffer = new StringBuffer(128)
+                    StringBuilder debugBuffer = new StringBuilder(128)
                             .append(
                                     "RCPT command had unrecognized/unexpected option ")
                             .append(rcptOptionName).append(" with value ")
@@ -228,7 +229,7 @@
 
     private String getContext(SMTPSession session,
             MailAddress recipientAddress, String recipient) {
-        StringBuffer sb = new StringBuffer(128);
+        StringBuilder sb = new StringBuilder(128);
         if (null != recipientAddress) {
             sb
                     .append(" [to:"

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SendMailHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SendMailHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SendMailHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SendMailHandler.java
Mon Sep  7 17:59:15 2009
@@ -74,8 +74,8 @@
                 recipientString = theRecipients.toString();
             }
             if (session.getLogger().isInfoEnabled()) {
-                StringBuffer infoBuffer =
-                     new StringBuffer(256)
+                StringBuilder infoBuffer =
+                     new StringBuilder(256)
                          .append("Successfully spooled mail ")
                          .append(mail.getName())
                          .append(" from ")

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SetMimeHeaderHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SetMimeHeaderHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SetMimeHeaderHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SetMimeHeaderHandler.java
Mon Sep  7 17:59:15 2009
@@ -72,7 +72,7 @@
     /**
      * Set the header value
      * 
-     * @param headerValue String wich represetn the header value
+     * @param headerValue String which represents the header value
      */
     public void setHeaderValue(String headerValue) {
         this.headerValue = headerValue;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java
Mon Sep  7 17:59:15 2009
@@ -383,8 +383,8 @@
      */
     private SMTPResponse doUnknownAuth(SMTPSession session, String authType, String initialResponse)
{
         if (session.getLogger().isErrorEnabled()) {
-            StringBuffer errorBuffer =
-                new StringBuffer(128)
+            StringBuilder errorBuffer =
+                new StringBuilder(128)
                     .append("AUTH method ")
                         .append(authType)
                         .append(" is an unrecognized authentication type");
@@ -422,8 +422,8 @@
     /**
      * @see org.apache.james.smtpserver.ExtensibleHandler#getMarkerInterfaces()
      */
-    public List getMarkerInterfaces() {
-        List classes = new ArrayList(1);
+    public List<Class<?>> getMarkerInterfaces() {
+        List<Class<?>> classes = new ArrayList<Class<?>>(1);
         classes.add(AuthHook.class);
         return classes;
     }

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java?rev=812240&r1=812239&r2=812240&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/MailSizeEsmtpExtension.java
Mon Sep  7 17:59:15 2009
@@ -85,7 +85,7 @@
                             + " Syntactically incorrect value for SIZE parameter");
         }
         if (session.getLogger().isDebugEnabled()) {
-            StringBuffer debugBuffer = new StringBuffer(128).append(
+            StringBuilder debugBuffer = new StringBuilder(128).append(
                     "MAIL command option SIZE received with value ").append(
                     size).append(".");
             session.getLogger().debug(debugBuffer.toString());
@@ -93,7 +93,7 @@
         long maxMessageSize = session.getMaxMessageSize();
         if ((maxMessageSize > 0) && (size > maxMessageSize)) {
             // Let the client know that the size limit has been hit.
-            StringBuffer errorBuffer = new StringBuffer(256).append(
+            StringBuilder errorBuffer = new StringBuilder(256).append(
                     "Rejected message from ").append(
                     tempSender != null ? tempSender : null).append(
                     " from host ").append(session.getRemoteHost()).append(" (")
@@ -163,7 +163,7 @@
             HookResult response = new HookResult(HookReturnCode.DENY, SMTPRetCode.QUOTA_EXCEEDED,DSNStatus.getStatus(DSNStatus.PERMANENT,
                     DSNStatus.SYSTEM_MSG_TOO_BIG) + " Maximum message size exceeded");
   
-            StringBuffer errorBuffer = new StringBuffer(256).append(
+            StringBuilder errorBuffer = new StringBuilder(256).append(
                     "Rejected message from ").append(
                     session.getState().get(SMTPSession.SENDER).toString())
                     .append(" from host ").append(session.getRemoteHost())



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