The NLST FTP command, when issued with the name of a non-existent file as an argument, returns that name instead of an empty list. Compare this behavior to that of the LIST command, which correctly returns an empty list in such a case.
A test case reproducing the bug (using the FTP client from the commons-net package):
@Test
void shouldReturnEmptyListingOfNonExistingFiles() {
ftpClient.connect(IP, PORT);
ftpClient.login(USERNAME, PASSWORD);
ftpClient.enterLocalPassiveMode();
// this assertion passes
assertThat(ftpClient.listFiles(UUID.randomUUID().toString()), is(emptyArray()));
// while this one fails
assertThat(ftpClient.listNames(UUID.randomUUID().toString()), is(emptyArray()));
}
The NLST FTP command, when issued with the name of a non-existent file as an argument, returns that name instead of an empty list. Compare this behavior to that of the LIST command, which correctly returns an empty list in such a case.
A test case reproducing the bug (using the FTP client from the
commons-netpackage):