fix random generation (fix bug if only 1 match found)

pull/4/head
nico202 2018-05-24 17:47:34 +02:00
parent 35d4d159a7
commit d6ef0d1e6f
1 changed files with 2 additions and 1 deletions

View File

@ -105,7 +105,8 @@ public class BeetsFetcher {
ArrayList<T> out = new ArrayList<>();
for (int i = 0; i < n; i++) {
out.add(list.get(RANDOM.nextInt(list.size() - 1)));
int item = list.size() > 1 ? RANDOM.nextInt(list.size() - 1) : 0;
out.add(list.get(item));
}
return Collections.unmodifiableList(out);