Skip to content
Permalink
Browse files

Merge pull request #17 from ikedam/feature/JENKINS-29934_UnsupportedO…

…perationException

[JENKINS-29934] Fix UnsupportedOperationException with adding empty choice to file lists.
  • Loading branch information
ikedam committed Aug 23, 2015
2 parents 9a38ead + 667c207 commit df170dabfb31e083d2e86630fa5b540d73012aaa
@@ -295,29 +295,20 @@ public FilenameChoiceListProvider(String baseDirPath, String includePattern, Str
}
case Directory:
{
ret = Arrays.asList(ds.getIncludedDirectories());
ret = new ArrayList<String>(Arrays.asList(ds.getIncludedDirectories()));
break;
}
default:
{
// case File:
ret = Arrays.asList(ds.getIncludedFiles());
ret = new ArrayList<String>(Arrays.asList(ds.getIncludedFiles()));
break;
}
}

if(reverseOrder)
{
try
{
Collections.reverse(ret);
}
catch(UnsupportedOperationException _)
{
// ret is immutable.
ret = new ArrayList<String>(ret);
Collections.reverse(ret);
}
Collections.reverse(ret);
}

if(emptyChoiceType == null)
@@ -620,18 +620,15 @@ public void testGetFileList() throws IOException
List<String> expected = Arrays.asList(
"",
"dir2/dir3/test4.dat",
"dir2/dir3",
"dir2",
"dir1/test3.txt",
"dir1",
"test2.dat",
"test1.txt"
);
List<String> fileList = FilenameChoiceListProviderForTest.getFileList(
tempDir,
"**/*",
"",
ScanType.FileAndDirectory,
ScanType.File,
true,
EmptyChoiceType.AtTop
);
@@ -641,20 +638,16 @@ public void testGetFileList() throws IOException
// Empty choice at the end and reversed.
{
List<String> expected = Arrays.asList(
"dir2/dir3/test4.dat",
"dir2/dir3",
"dir2",
"dir1/test3.txt",
"dir1",
"test2.dat",
"test1.txt",
""
);
List<String> fileList = FilenameChoiceListProviderForTest.getFileList(
tempDir,
"**/*",
"",
ScanType.FileAndDirectory,
ScanType.Directory,
true,
EmptyChoiceType.AtEnd
);

0 comments on commit df170da

Please sign in to comment.
You can’t perform that action at this time.