mirror of https://github.com/apache/nifi.git
NIFI-2692
- Removing problematic timeout for SMTP Listen - Converting anonymous method to lambda - Adding debug and error logging Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #1924.
This commit is contained in:
parent
490e1da5db
commit
2800df30d3
|
@ -177,6 +177,7 @@ public class ListenSMTP extends AbstractSessionFactoryProcessor {
|
|||
try {
|
||||
final SMTPServer server = prepareServer(context, sessionFactory);
|
||||
server.start();
|
||||
getLogger().debug("Started SMTP Server on port " + server.getPort());
|
||||
smtp = server;
|
||||
} catch (final Exception ex) {//have to catch exception due to awkward exception handling in subethasmtp
|
||||
smtp = null;
|
||||
|
@ -190,6 +191,9 @@ public class ListenSMTP extends AbstractSessionFactoryProcessor {
|
|||
public void stop() {
|
||||
try {
|
||||
smtp.stop();
|
||||
getLogger().debug("Stopped SMTP server on port " + smtp.getPort());
|
||||
}catch (Exception ex){
|
||||
getLogger().error("Error stopping SMTP server: " + ex.getMessage());
|
||||
}finally {
|
||||
smtp = null;
|
||||
}
|
||||
|
|
|
@ -56,16 +56,13 @@ public class TestListenSMTP {
|
|||
TestRunner runner = TestRunners.newTestRunner(ListenSMTP.class);
|
||||
runner.setProperty(ListenSMTP.SMTP_PORT, String.valueOf(port));
|
||||
runner.setProperty(ListenSMTP.SMTP_MAXIMUM_CONNECTIONS, "3");
|
||||
runner.setProperty(ListenSMTP.SMTP_TIMEOUT, "10 seconds");
|
||||
|
||||
runner.assertValid();
|
||||
runner.run(5, false);
|
||||
final int numMessages = 5;
|
||||
CountDownLatch latch = new CountDownLatch(numMessages);
|
||||
|
||||
this.executor.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
this.executor.schedule(() -> {
|
||||
for (int i = 0; i < numMessages; i++) {
|
||||
try {
|
||||
Email email = new SimpleEmail();
|
||||
|
@ -83,7 +80,6 @@ public class TestListenSMTP {
|
|||
latch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1500, TimeUnit.MILLISECONDS);
|
||||
|
||||
boolean complete = latch.await(5000, TimeUnit.MILLISECONDS);
|
||||
|
@ -102,7 +98,6 @@ public class TestListenSMTP {
|
|||
TestRunner runner = TestRunners.newTestRunner(ListenSMTP.class);
|
||||
runner.setProperty(ListenSMTP.SMTP_PORT, String.valueOf(port));
|
||||
runner.setProperty(ListenSMTP.SMTP_MAXIMUM_CONNECTIONS, "3");
|
||||
runner.setProperty(ListenSMTP.SMTP_TIMEOUT, "10 seconds");
|
||||
|
||||
// Setup the SSL Context
|
||||
SSLContextService sslContextService = new StandardSSLContextService();
|
||||
|
@ -124,9 +119,7 @@ public class TestListenSMTP {
|
|||
CountDownLatch latch = new CountDownLatch(messageCount);
|
||||
runner.run(messageCount, false);
|
||||
|
||||
this.executor.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
this.executor.schedule(() -> {
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
try {
|
||||
Email email = new SimpleEmail();
|
||||
|
@ -149,7 +142,6 @@ public class TestListenSMTP {
|
|||
latch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1500, TimeUnit.MILLISECONDS);
|
||||
|
||||
boolean complete = latch.await(5000, TimeUnit.MILLISECONDS);
|
||||
|
@ -165,7 +157,6 @@ public class TestListenSMTP {
|
|||
TestRunner runner = TestRunners.newTestRunner(ListenSMTP.class);
|
||||
runner.setProperty(ListenSMTP.SMTP_PORT, String.valueOf(port));
|
||||
runner.setProperty(ListenSMTP.SMTP_MAXIMUM_CONNECTIONS, "3");
|
||||
runner.setProperty(ListenSMTP.SMTP_TIMEOUT, "10 seconds");
|
||||
runner.setProperty(ListenSMTP.SMTP_MAXIMUM_MSG_SIZE, "10 B");
|
||||
|
||||
runner.assertValid();
|
||||
|
@ -175,9 +166,7 @@ public class TestListenSMTP {
|
|||
|
||||
runner.run(messageCount, false);
|
||||
|
||||
this.executor.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
this.executor.schedule(() -> {
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
try {
|
||||
Email email = new SimpleEmail();
|
||||
|
@ -195,7 +184,6 @@ public class TestListenSMTP {
|
|||
latch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
boolean complete = latch.await(5000, TimeUnit.MILLISECONDS);
|
||||
|
|
Loading…
Reference in New Issue