Skip to content

Commit

Permalink
Merge pull request #17 from ikedam/feature/JENKINS-29934_UnsupportedO…
Browse files Browse the repository at this point in the history
…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 df170da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
Expand Up @@ -295,29 +295,20 @@ protected static List<String> getFileList(
}
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)
Expand Down
Expand Up @@ -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
);
Expand All @@ -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
);
Expand Down

0 comments on commit df170da

Please sign in to comment.