Skip to content

Commit d476e5c

Browse files
committed
Ignore empty Strings during String to FileArray conversion
* The current state of the code is that an empty String, is converted to a new File("") object with an empty String * A File object instantiated by this will be a File object with an absolute Path that is equivalent to the Path from which the application was started * The result of this is relatively unpredictable * Thus empty String should not be converted to File object and not be added to the output
1 parent d4ab47a commit d476e5c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/java/org/scijava/convert/FileListConverters.java

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public <T> T convert(final Object src, final Class<T> dest) {
8282
final String[] tokens = StringUtils.splitUnquoted((String) src, ",");
8383
final List<File> fileList = new ArrayList<>();
8484
for (final String filePath : tokens) {
85+
if ( filePath.isEmpty() )
86+
continue;
8587
fileList.add(new File(filePath.replaceAll("^\"|\"$", "")));
8688
}
8789
return (T) fileList.toArray(new File[fileList.size()]);

0 commit comments

Comments
 (0)