This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new e59ae4ccec [FIX] Back MessageParser and pasring results with LeakAware
(#2937)
e59ae4ccec is described below
commit e59ae4ccec5dbd4581f643cb58cbba4d083d2257
Author: Benoit TELLIER <[email protected]>
AuthorDate: Thu Feb 12 03:50:03 2026 +0100
[FIX] Back MessageParser and pasring results with LeakAware (#2937)
---
mailbox/store/pom.xml | 4 +++
.../store/mail/model/impl/MessageParser.java | 32 ++++++++++++++--------
.../store/mail/model/impl/MessageParserImpl.java | 2 ++
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml
index 5359fb43dd..97a78f8a20 100644
--- a/mailbox/store/pom.xml
+++ b/mailbox/store/pom.xml
@@ -55,6 +55,10 @@
<artifactId>james-mdn</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-lifecycle-api</artifactId>
+ </dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>james-server-testing</artifactId>
diff --git
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
index d7e11f6898..99644ce0e7 100644
---
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
+++
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
@@ -23,31 +23,39 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.List;
+import org.apache.james.lifecycle.api.Disposable;
import org.apache.james.mailbox.model.ParsedAttachment;
import org.apache.james.mime4j.dom.Message;
import com.google.common.collect.ImmutableList;
public interface MessageParser {
- class ParsingResult {
- public static final MessageParser.ParsingResult EMPTY = new
MessageParser.ParsingResult(ImmutableList.of(), () -> {
+ class ParsingResult extends Disposable.LeakAware<ParsingResult.Resource> {
- });
+ static class Resource extends Disposable.LeakAware.Resource {
+ private final List<ParsedAttachment> attachments;
- private final List<ParsedAttachment> attachments;
- private final Runnable dispose;
+ Resource(List<ParsedAttachment> attachments, Disposable cleanup) {
+ super(cleanup);
+ this.attachments = attachments;
+ }
+ }
+
+ public static final ParsingResult EMPTY = new ParsingResult(
+ new Resource(ImmutableList.of(), () -> {
+
+ }));
- public ParsingResult(List<ParsedAttachment> attachments, Runnable
dispose) {
- this.attachments = attachments;
- this.dispose = dispose;
+ public ParsingResult(Resource resource) {
+ super(resource);
}
- public List<ParsedAttachment> getAttachments() {
- return attachments;
+ public ParsingResult(List<ParsedAttachment> attachments, Disposable
cleanup) {
+ this(new Resource(attachments, cleanup));
}
- public void dispose() {
- dispose.run();
+ public List<ParsedAttachment> getAttachments() {
+ return getResource().attachments;
}
}
diff --git
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserImpl.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserImpl.java
index 2069986e4e..e75c29fd7c 100644
---
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserImpl.java
+++
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserImpl.java
@@ -28,6 +28,7 @@ import java.util.function.Predicate;
import java.util.stream.Stream;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
+import org.apache.james.lifecycle.api.Disposable;
import org.apache.james.mailbox.model.Cid;
import org.apache.james.mailbox.model.ContentType;
import org.apache.james.mailbox.model.ParsedAttachment;
@@ -81,6 +82,7 @@ public class MessageParserImpl implements MessageParser {
}
public ParsingResult retrieveAttachments(InputStream fullContent) throws
IOException {
+ Disposable.LeakAware.track();
DefaultMessageBuilder defaultMessageBuilder = new
DefaultMessageBuilder();
defaultMessageBuilder.setMimeEntityConfig(MimeConfig.PERMISSIVE);
defaultMessageBuilder.setDecodeMonitor(DecodeMonitor.SILENT);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]