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 49ad1cb6b8298ae5939f88582286f361fc8c0f29
Author: RĂ©mi KOWALSKI <rkowal...@linagora.com>
AuthorDate: Fri Nov 8 11:59:48 2019 +0100

    JAMES-2704 close smtp connection in tests
---
 .../java/org/apache/james/smtp/SmtpRandomStoringTest.java  | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpRandomStoringTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpRandomStoringTest.java
index 28287c4..3b032e6 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpRandomStoringTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/smtp/SmtpRandomStoringTest.java
@@ -142,13 +142,15 @@ public class SmtpRandomStoringTest {
     }
 
     private void sendMails() throws Exception {
-        SMTPMessageSender authenticatedSmtpConnection = 
messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
-            .authenticate(FROM, PASSWORD);
+        try (SMTPMessageSender authenticatedSmtpConnection = 
messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())) {
 
-        IntStream.range(0, NUMBER_OF_MAILS)
-            .forEach(Throwing.intConsumer(index ->
-                authenticatedSmtpConnection
-                    .sendMessage(buildMail("Message " + 
index))).sneakyThrow());
+            authenticatedSmtpConnection.authenticate(FROM, PASSWORD);
+
+            IntStream.range(0, NUMBER_OF_MAILS)
+                .forEach(Throwing.intConsumer(index ->
+                    authenticatedSmtpConnection
+                        .sendMessage(buildMail("Message " + 
index))).sneakyThrow());
+        }
     }
 
     @After


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to