This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 22a1d2ff5f8e8668187fea01aa022efa93a52fed
Author: Benoit Tellier <[email protected]>
AuthorDate: Mon Jan 9 10:21:26 2023 +0700

    [UPGRADE] MIME4J 0.8.7 -> 0.8.9
---
 .../mailbox/store/mail/model/impl/MessageParser.java | 20 ++++++++------------
 pom.xml                                              |  2 +-
 .../jmap/draft/methods/MIMEMessageConverterTest.java | 14 ++++++++------
 3 files changed, 17 insertions(+), 19 deletions(-)

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 b1d2166904..482685905b 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
@@ -91,19 +91,15 @@ public class MessageParser {
 
     public List<ParsedAttachment> retrieveAttachments(Message message) throws 
IOException {
         Body body = message.getBody();
-        try {
-            if (body instanceof Multipart) {
-                Multipart multipartBody = (Multipart) body;
-                return listAttachments(multipartBody, 
Context.fromSubType(multipartBody.getSubType()))
-                    .collect(ImmutableList.toImmutableList());
-            } else {
-                if (isAttachment(message, Context.BODY)) {
-                    return ImmutableList.of(retrieveAttachment(message));
-                }
-                return ImmutableList.of();
+        if (body instanceof Multipart) {
+            Multipart multipartBody = (Multipart) body;
+            return listAttachments(multipartBody, 
Context.fromSubType(multipartBody.getSubType()))
+                .collect(ImmutableList.toImmutableList());
+        } else {
+            if (isAttachment(message, Context.BODY)) {
+                return ImmutableList.of(retrieveAttachment(message));
             }
-        } finally {
-            body.dispose();
+            return ImmutableList.of();
         }
     }
 
diff --git a/pom.xml b/pom.xml
index 4c7ac572b4..1e1031f309 100644
--- a/pom.xml
+++ b/pom.xml
@@ -598,7 +598,7 @@
         <james.groupId>org.apache.james</james.groupId>
         
<james.protocols.groupId>${james.groupId}.protocols</james.protocols.groupId>
         <activemq.version>5.17.3</activemq.version>
-        <apache-mime4j.version>0.8.7</apache-mime4j.version>
+        <apache-mime4j.version>0.8.9</apache-mime4j.version>
         <apache.openjpa.version>3.2.0</apache.openjpa.version>
         <derby.version>10.14.2.0</derby.version>
         <log4j2.version>2.19.0</log4j2.version>
diff --git 
a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/methods/MIMEMessageConverterTest.java
 
b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/methods/MIMEMessageConverterTest.java
index 4c79709dbe..24feb19418 100644
--- 
a/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/methods/MIMEMessageConverterTest.java
+++ 
b/server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/draft/methods/MIMEMessageConverterTest.java
@@ -46,6 +46,7 @@ import org.apache.james.mime4j.codec.EncoderUtil.Usage;
 import org.apache.james.mime4j.dom.Entity;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.Multipart;
+import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.dom.field.ContentTypeField;
@@ -56,6 +57,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 
+import com.github.fge.lambdas.Throwing;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
@@ -741,16 +743,16 @@ class MIMEMessageConverterTest {
                 .hasSize(1)
                 .extracting(entity -> (Multipart) entity.getBody())
                 .flatExtracting(Multipart::getBodyParts)
-                .satisfies(part -> {
+                .satisfies(Throwing.consumer(part -> {
                     assertThat(part.getBody()).isInstanceOf(Multipart.class);
                     assertThat(part.isMultipart()).isTrue();
                     
assertThat(part.getMimeType()).isEqualTo("multipart/alternative");
                     
assertThat(((Multipart)part.getBody()).getBodyParts()).hasSize(2);
-                    Entity textPart = 
((Multipart)part.getBody()).getBodyParts().get(0);
-                    Entity htmlPart = 
((Multipart)part.getBody()).getBodyParts().get(1);
-                    
assertThat(textPart.getBody()).isEqualToComparingOnlyGivenFields(expectedTextBody,
 "content");
-                    
assertThat(htmlPart.getBody()).isEqualToComparingOnlyGivenFields(expectedHtmlBody,
 "content");
-                }, Index.atIndex(0))
+                    SingleBody textPart = (SingleBody) 
((Multipart)part.getBody()).getBodyParts().get(0).getBody();
+                    SingleBody htmlPart = (SingleBody) 
((Multipart)part.getBody()).getBodyParts().get(1).getBody();
+                    
assertThat(textPart.getInputStream()).hasBinaryContent("Hello all!".getBytes());
+                    
assertThat(htmlPart.getInputStream()).hasBinaryContent("Hello 
<b>all<b>!".getBytes());
+                }), Index.atIndex(0))
                 .satisfies(part -> {
                     
assertThat(part.getBody()).isEqualToComparingOnlyGivenFields(expectedAttachmentBody,
 "content");
                     assertThat(part.getDispositionType()).isEqualTo("inline");


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to