Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-269

AvalonMailRepository emits spurious "so we're deleting it... good riddance" messages due to synchronization



    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0a3, 2.1.3, 2.2.0
    • Fix Version/s: 2.2.0
    • Labels:


      If you use AvalonMailRepository, especially if you use AvalonSpoolRepository, and you have a lot of active threads, you are likely to see quite a few:

      ERROR mailstore: Exception retrieving mail: java.lang.RuntimeException: Exception caught while retrieving an object, cause: java.io.FileNotFoundException: /path/xxx.Repository.FileObjectStore (No such file or directory), so we're deleting it... good riddance!

      People have seen, and asked, about this in the past, so I am going to document why this happens:

      AvalonSpoolRepository.accept() clones the key set and iterates over it. That method is synchronized, but remove(String key) is not. So one thread starts running in accept, clones the key set, and starts iterating over it. Meanwhile, another thread finishes processing that message and decides to remove it. Since remove is not synchronized, the file is removed from the repository and the live key set, but the key is still present in the cloned key set, and if the accept() method tries to retrieve(String) that message, it will find that it is removed.

      We could synchronize remove(String), but it does not appear that there is any point to doing so, and why would we want to hold up removing a message while waiting for another thread to find a message to process?

      The same situation occurs in the JDBC repository, and is logged at debug level rather than error level. AvalonMailRepository should also have the logging level changed.




            • Assignee:
              noel Noel J. Bergman
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: