james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1150550 - /james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java
Date Mon, 25 Jul 2011 05:32:40 GMT
Author: norman
Date: Mon Jul 25 05:32:40 2011
New Revision: 1150550

URL: http://svn.apache.org/viewvc?rev=1150550&view=rev
Log:
Just skip over corrupted entries in the uidlist file so we have some kind of self-healing.
see MAILBOX-111

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=1150550&r1=1150549&r2=1150550&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
Mon Jul 25 05:32:40 2011
@@ -285,7 +285,7 @@ public class MaildirFolder {
      * @return The {@link MaildirMessageName} that belongs to the uid
      * @throws IOException If the uidlist file cannot be found or read
      */
-    public MaildirMessageName getMessageNameByUid(MailboxSession session, final Long uid)
throws MailboxException {
+    public MaildirMessageName getMessageNameByUid(final MailboxSession session, final Long
uid) throws MailboxException {
        
         return locker.executeWithLock(session, path, new LockAwareExecution<MaildirMessageName>()
{
             
@@ -305,7 +305,8 @@ public class MaildirFolder {
                             int gap = line.indexOf(" ");
                             if (gap == -1) {
                                 // there must be some issues in the file if no gap can be
found
-                                throw new MailboxException("Corrupted entry in uid-file "
+ uidList + " line " + lineNumber++);
+                            	session.getLog().info("Corrupted entry in uid-file " + uidList
+ " line " + lineNumber++);
+                                continue;
                             }
                             
                             if (line.substring(0, gap).equals(uidString)) {
@@ -336,7 +337,7 @@ public class MaildirFolder {
      * @return a {@link Map} whith all uids in the given range and associated {@link MaildirMessageName}s
      * @throws MailboxException if there is a problem with the uid list file
      */
-    public SortedMap<Long, MaildirMessageName> getUidMap(MailboxSession session, final
long from, final long to)
+    public SortedMap<Long, MaildirMessageName> getUidMap(final MailboxSession session,
final long from, final long to)
     throws MailboxException {
         return locker.executeWithLock(session, path, new LockAwareExecution<SortedMap<Long,
MaildirMessageName>>() {
             
@@ -358,7 +359,7 @@ public class MaildirFolder {
                         }
                     } else {
                         // the uidList is up to date
-                        uidMap.putAll(readUidFile(from, to));
+                        uidMap.putAll(readUidFile(session, from, to));
                     }
                 } else {
                     // the uidList does not exist
@@ -417,7 +418,7 @@ public class MaildirFolder {
      * @return A {@link Map} with all uids and associated {@link MaildirMessageName}s of
recent messages
      * @throws MailboxException If there is a problem with the uid list file
      */
-    public SortedMap<Long, MaildirMessageName> getRecentMessages(MailboxSession session)
throws MailboxException {
+    public SortedMap<Long, MaildirMessageName> getRecentMessages(final MailboxSession
session) throws MailboxException {
         final String[] recentFiles = getNewFolder().list();
         final LinkedList<String> lines = new LinkedList<String>();
         final int theLimit = recentFiles.length;
@@ -475,7 +476,9 @@ public class MaildirFolder {
                             int gap = line.indexOf(" ");
                             if (gap == -1) {
                                 // there must be some issues in the file if no gap can be
found
-                                throw new IOException("Corrupted entry in uid-file " + uidList
+ " line " + lines.size());
+                                // there must be some issues in the file if no gap can be
found
+                            	session.getLog().info("Corrupted entry in uid-file " + uidList
+ " line " + lines.size());
+                                continue;
                             }
                             
                             Long uid = Long.valueOf(line.substring(0, gap));
@@ -582,7 +585,7 @@ public class MaildirFolder {
         return uidMap;
     }
 
-    private Map<Long, MaildirMessageName> readUidFile(final long from, final long to)
throws MailboxException {
+    private Map<Long, MaildirMessageName> readUidFile(MailboxSession session, final
long from, final long to) throws MailboxException {
         final Map<Long, MaildirMessageName> uidMap = new HashMap<Long, MaildirMessageName>();
 
         File uidList = uidFile;
@@ -602,9 +605,9 @@ public class MaildirFolder {
                     int gap = line.indexOf(" ");
 
                     if (gap == -1) {
-                        // there must be some issues in the file if no gap can
-                        // be found
-                        throw new MailboxException("Corrupted entry in uid-file " + uidList
+ " line " + lineNumber++);
+                        // there must be some issues in the file if no gap can be found
+                    	session.getLog().info("Corrupted entry in uid-file " + uidList + " line
" + lineNumber++);
+                        continue;
                     }
 
                     Long uid = Long.valueOf(line.substring(0, gap));
@@ -833,7 +836,8 @@ public class MaildirFolder {
                         int gap = line.indexOf(" ");
                         if (gap == -1) {
                             // there must be some issues in the file if no gap can be found
-                            throw new IOException("Corrupted entry in uid-file " + uidList
+ " line " + lineNumber++);
+                        	session.getLog().info("Corrupted entry in uid-file " + uidList +
" line " + lineNumber++);
+                            continue;
                         }
                         
                         if (uid == Long.valueOf(line.substring(0, line.indexOf(" ")))) {



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