You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by "Aldrin Piri (JIRA)" <ji...@apache.org> on 2015/05/06 05:35:16 UTC
[jira] [Created] (NIFI-593) Ordering is not guaranteed for
directory listings
Aldrin Piri created NIFI-593:
--------------------------------
Summary: Ordering is not guaranteed for directory listings
Key: NIFI-593
URL: https://issues.apache.org/jira/browse/NIFI-593
Project: Apache NiFi
Issue Type: Bug
Affects Versions: 0.1.0
Reporter: Aldrin Piri
Priority: Blocker
org.apache.nifi.nar.NarUnpackerTest#testUnpackNars makes explicit selections of listed directories by array index. This can be problematic as those listings are not guaranteed to be ordered.
This signature is also present in NiFiPropertiesTest#testProperties where a similar selection of value is provided via an element index.
Results where order is not guaranteed and does not matter need to have their semantics changed to model those of a Set in lieu of the List that is typically returned.
A scan needs to be performed for such problem cases and converted to use this.
Something along the lines would be sufficient:
{code}
final File extensionsWorkingDir = properties.getExtensionsWorkingDirectory();
File[] extensionFiles = extensionsWorkingDir.listFiles();
Set<String> expectedNars = new HashSet<>();
expectedNars.add("dummy-one.nar-unpacked");
expectedNars.add("dummy-two.nar-unpacked");
assertEquals(expectedNars.size(), extensionFiles.length);
for (File extensionFile : extensionFiles) {
Assert.assertTrue(expectedNars.contains(extensionFile.getName()));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)