diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java index 6aa93f1939..3204f7a1e3 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -556,7 +556,7 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl } @Override - public void destroy() throws Exception { + public void destroy() { synchronized (this.folderMonitor) { MailTransportUtils.closeFolder(this.folder, this.shouldDeleteMessages); MailTransportUtils.closeService(this.store); diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java index a207caea6f..3dfbe61f72 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java @@ -149,7 +149,7 @@ public class ImapMailReceiver extends AbstractMailReceiver { } @Override - public void destroy() throws Exception { + public void destroy() { super.destroy(); if (this.isInternalScheduler) { ((ThreadPoolTaskScheduler) this.scheduler).shutdown(); diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java index 705c2f052c..04efe5ac0f 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java @@ -237,6 +237,11 @@ public class TestMailServer { class ImapHandler extends MailHandler { + /** + * Time to wait while IDLE before returning a result. + */ + private static final int IDLE_WAIT_TIME = 1000; + ImapHandler(Socket socket) { super(socket); } @@ -348,7 +353,7 @@ public class TestMailServer { idleTag = tag; if (!idled) { try { - Thread.sleep(1000); + Thread.sleep(IDLE_WAIT_TIME); write("* 2 EXISTS"); seen = false; } @@ -392,9 +397,9 @@ public class TestMailServer { private final ExecutorService exec = Executors.newCachedThreadPool(); - protected final Set assertions = new HashSet<>(); + protected final Set assertions = new HashSet<>(); // NOSONAR protected - protected final List messages = new ArrayList<>(); + protected final List messages = new ArrayList<>(); // NOSONAR protected private volatile boolean listening; @@ -461,13 +466,13 @@ public class TestMailServer { + "Subject: Test Email\r\n" + "\r\n" + BODY; - protected final Socket socket; + protected final Socket socket; // NOSONAR protected private BufferedWriter writer; - StringBuilder sb = new StringBuilder(); + protected StringBuilder sb = new StringBuilder(); // NOSONAR protected - protected BufferedReader reader; + protected BufferedReader reader; // NOSONAR protected MailHandler(Socket socket) { this.socket = socket;