linagora / tmail-backend

GNU Affero General Public License v3.0
30 stars 17 forks source link

[Bug] Leak resource at CalendarEventReplyPerformer #1020

Closed vttranlina closed 2 months ago

vttranlina commented 2 months ago

How to re-produce?

Running com.linagora.tmail.james.MemoryLinagoraCalendarEventAcceptMethodTest Log:

Dispose email:17:07:34.705 [ERROR] o.a.j.l.a.Disposable$LeakAwareFinalizer - Leak detected! Resource org.apache.james.server.core.MimeMessageInputStreamSource$Resource@6e500b8e was not released before its referent was garbage-collected. 
Resource management needs to be reviewed: ensure to always call dispose() for disposable objects you work with. 
Consider enabling advanced leak detection to further identify the problem.

Dod

No aware log

vttranlina commented 2 months ago

I still have not caught the where leak it. The LifecycleUtil.dispose already invoked after enqueue MailImpl

At the @chibenwa 's comment: https://github.com/linagora/tmail-backend/pull/970#discussion_r1521430370

Use MimeMessageInputStreamSource

The method MimeMessageInputStreamSource create(String key, InputStream in) was not used in prod code before CalendarEvent. Not sure if it is stable or not

vttranlina commented 2 months ago

Related to CalendarEvent, do you think we should "cache" the mimeMessage (mail template) that loads from the IO template file? And reuse it for each reply (just replace mustache when using)

chibenwa commented 2 months ago

do you think we should "cache" the mimeMessage (mail template) that loads from the IO template file? And reuse it for each reply (just replace mustache when using)

IMO we can load it again each time, just call "dispose"

vttranlina commented 2 months ago

pr: