You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/03/28 05:09:26 UTC

[GitHub] [james-project] chibenwa commented on a change in pull request #940: JAMES-3724 - Fixing leak resource for MemoryMailRepository

chibenwa commented on a change in pull request #940:
URL: https://github.com/apache/james-project/pull/940#discussion_r836057550



##########
File path: server/mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepository.java
##########
@@ -26,16 +26,18 @@
 
 import javax.mail.MessagingException;
 
+import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.mailrepository.api.MailKey;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.mailet.Mail;
 
 public class MemoryMailRepository implements MailRepository {
 
-    private final ConcurrentHashMap<MailKey, Mail> mails;
+    private static final ConcurrentHashMap<MailKey, Mail> mails = new ConcurrentHashMap<>();

Review comment:
       No all mail repository should not share a common memory stucture
   
   And this static field cheats by preventing GC to find those.
   
   What we should likely do is:
   
    - Always dispose emails upon delete, clear
    - Call clear in our @AfterEach callbacks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org