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 09e3803613 [FIX] RSpamD should not fail when reporting empty body
09e3803613 is described below

commit 09e3803613e8096e952712de646efa4829a38773
Author: Benoit TELLIER <[email protected]>
AuthorDate: Sun Mar 10 21:28:51 2024 +0100

    [FIX] RSpamD should not fail when reporting empty body
---
 .../java/org/apache/james/rspamd/client/RspamdHttpClient.java  |  4 ++++
 .../org/apache/james/rspamd/client/RspamdHttpClientTest.java   | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git 
a/third-party/rspamd/src/main/java/org/apache/james/rspamd/client/RspamdHttpClient.java
 
b/third-party/rspamd/src/main/java/org/apache/james/rspamd/client/RspamdHttpClient.java
index 427b2e4c4c..883bad3304 100644
--- 
a/third-party/rspamd/src/main/java/org/apache/james/rspamd/client/RspamdHttpClient.java
+++ 
b/third-party/rspamd/src/main/java/org/apache/james/rspamd/client/RspamdHttpClient.java
@@ -248,6 +248,10 @@ public class RspamdHttpClient {
                             LOGGER.debug(responseBody);
                             return Mono.empty();
                         }
+                        if (responseBody.contains("Empty body is not 
permitted")) {
+                            LOGGER.debug(responseBody);
+                            return Mono.empty();
+                        }
                         return Mono.error(() -> new 
RspamdUnexpectedException(responseBody));
                     });
         }
diff --git 
a/third-party/rspamd/src/test/java/org/apache/james/rspamd/client/RspamdHttpClientTest.java
 
b/third-party/rspamd/src/test/java/org/apache/james/rspamd/client/RspamdHttpClientTest.java
index eb2777db27..2f8e384b76 100644
--- 
a/third-party/rspamd/src/test/java/org/apache/james/rspamd/client/RspamdHttpClientTest.java
+++ 
b/third-party/rspamd/src/test/java/org/apache/james/rspamd/client/RspamdHttpClientTest.java
@@ -27,6 +27,7 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.core.Is.is;
 
+import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.Optional;
 
@@ -317,6 +318,15 @@ class RspamdHttpClientTest {
         
assertThat(client.ping().block().status()).isEqualTo(HttpResponseStatus.OK);
     }
 
+    @Test
+    void shouldNotFailOnEmptyContent() {
+        RspamdClientConfiguration configuration = new 
RspamdClientConfiguration(rspamdExtension.getBaseUrl(), PASSWORD, 
Optional.empty());
+        RspamdHttpClient client = new RspamdHttpClient(configuration);
+
+        client.reportAsSpam(ReactorUtils.toChunks(new 
ByteArrayInputStream("".getBytes()),
+            BUFFER_SIZE), RspamdHttpClient.Options.forUser(BOB)).block();
+    }
+
     private void reportAsSpam(RspamdHttpClient client, InputStream 
inputStream) {
         client.reportAsSpam(ReactorUtils.toChunks(inputStream, 
BUFFER_SIZE)).block();
     }


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

Reply via email to