Skip to content

Commit 3e30625

Browse files
committed
Fix FtpServerOutboundTests.allEvents test
Spurious events captured from other tests. Only capture events for the test's session.
1 parent 185d370 commit 3e30625

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.FileOutputStream;
3131
import java.io.IOException;
3232
import java.io.InputStream;
33+
import java.net.InetSocketAddress;
3334
import java.util.ArrayList;
3435
import java.util.Arrays;
3536
import java.util.Calendar;
@@ -808,6 +809,8 @@ public static class Config {
808809

809810
private volatile CountDownLatch latch;
810811

812+
private volatile InetSocketAddress clientAddress;
813+
811814
@Bean
812815
public SessionFactory<FTPFile> ftpSessionFactory(ApplicationContext context) {
813816
FtpServerOutboundTests.ftplet().setApplicationEventPublisher(context);
@@ -827,7 +830,13 @@ public FtpRemoteFileTemplate template(SessionFactory<FTPFile> sf) {
827830
public void handleEvent(ApacheMinaFtpEvent event) {
828831
if (this.latch != null) {
829832
if (this.events.size() > 0 || event instanceof SessionOpenedEvent) {
830-
this.events.add(event);
833+
if (event instanceof SessionOpenedEvent) {
834+
this.clientAddress = event.getSession().getClientAddress();
835+
this.events.add(event);
836+
}
837+
else if (event.getSession().getClientAddress().equals(this.clientAddress)) {
838+
this.events.add(event);
839+
}
831840
if (event instanceof SessionClosedEvent) {
832841
this.latch.countDown();
833842
}

0 commit comments

Comments
 (0)