commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1086063 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java
Date Sun, 27 Mar 2011 22:23:37 GMT
Author: sebb
Date: Sun Mar 27 22:23:37 2011
New Revision: 1086063

URL: http://svn.apache.org/viewvc?rev=1086063&view=rev
Log:
status() command needs to send the mailbox name; data items are not optional

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java?rev=1086063&r1=1086062&r2=1086063&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPClient.java Sun
Mar 27 22:23:37 2011
@@ -225,18 +225,24 @@ public class IMAPClient extends IMAP
      */
     public boolean status(String mailboxName, String[] itemNames) throws IOException
     {
-        String statusNames = "";
-        if (itemNames != null)
+        if (itemNames == null || itemNames.length < 1) {
+            throw new IllegalArgumentException("STATUS command requires at least one data
item name");
+        }
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(mailboxName);
+
+        sb.append(" (");
+        for ( int i = 0; i < itemNames.length; i++ )
         {
-            statusNames += " (";
-            for ( int i = 0; i < itemNames.length; i++ )
-            {
-                statusNames += itemNames[i];
-                if (i < itemNames.length-1) statusNames += " ";
+            if (i > 0) {
+                sb.append(" ");
             }
-            statusNames += ")";
+            sb.append(itemNames[i]);
         }
-        return doCommand (IMAPCommand.STATUS, statusNames);
+        sb.append(")");
+
+        return doCommand (IMAPCommand.STATUS, sb.toString());
     }
 
     /**



Mime
View raw message