james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1148688 - /james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java
Date Wed, 20 Jul 2011 10:29:52 GMT
Author: norman
Date: Wed Jul 20 10:29:51 2011
New Revision: 1148688

URL: http://svn.apache.org/viewvc?rev=1148688&view=rev
Log:
Fix possible IllegalArgumentException if try to delete a message while the messagecount of
the mailbox is 0. See MAILBOX-108

Modified:
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java?rev=1148688&r1=1148687&r2=1148688&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java
(original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java
Wed Jul 20 10:29:51 2011
@@ -711,7 +711,7 @@ public class MaildirFolder {
                         // the first line in the file contains the next uid and message count
                         if (line != null)
                             readUidListHeader(line);
-                        ArrayList<String> lines = new ArrayList<String>(messageCount);
+                        ArrayList<String> lines = new ArrayList<String>();
                         while ((line = reader.readLine()) != null)
                             lines.add(line);
                         uid = getNextUid();
@@ -728,7 +728,7 @@ public class MaildirFolder {
                         String[] curFiles = curFolder.list();
                         String[] newFiles = newFolder.list();
                         messageCount = curFiles.length + newFiles.length;
-                        ArrayList<String> lines = new ArrayList<String>(messageCount);
+                        ArrayList<String> lines = new ArrayList<String>();
                         String[] allFiles = (String[]) ArrayUtils.addAll(curFiles, newFiles);
                         for (String file : allFiles) {
                             long theUid = getNextUid();
@@ -780,7 +780,7 @@ public class MaildirFolder {
                     reader = new BufferedReader(fileReader);
                     String line = reader.readLine();
                     readUidListHeader(line);
-                    ArrayList<String> lines = new ArrayList<String>(messageCount);
+                    ArrayList<String> lines = new ArrayList<String>();
                     while ((line = reader.readLine()) != null) {
                         if (uid == Long.valueOf(line.substring(0, line.indexOf(" "))))
                             line = String.valueOf(uid) + " " + messageName;
@@ -824,7 +824,9 @@ public class MaildirFolder {
                     fileReader = new FileReader(uidList);
                     reader = new BufferedReader(fileReader);
                     readUidListHeader(reader.readLine());
-                    ArrayList<String> lines = new ArrayList<String>(messageCount-1);
+                    
+                    // It may be possible that message count is 0 so we should better not
try to calculate the size of the ArrayList
+                    ArrayList<String> lines = new ArrayList<String>();
                     String line;
                     int lineNumber = 1;
                     while ((line = reader.readLine()) != null) {



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