[COLLECTIONS-673] ListUtils.partition potential integer overflow.

Applied patch with reformatting.
This commit is contained in:
Stephan Fuhrmann 2018-06-12 15:43:42 -06:00 committed by Gary Gregory
parent 274c9c1d37
commit b88b065aa9
2 changed files with 5 additions and 1 deletions

View File

@ -688,7 +688,7 @@ public class ListUtils {
@Override
public int size() {
return (list.size() + size - 1) / size;
return (int) Math.ceil((double) list.size() / (double) size);
}
@Override

View File

@ -425,6 +425,10 @@ public class ListUtilsTest {
fail("failed to check for size argument");
} catch (final IllegalArgumentException e) {}
List<List<Integer>> partitionMax = ListUtils.partition(strings, Integer.MAX_VALUE);
assertEquals(1, partitionMax.size());
assertEquals(strings.size(), partitionMax.get(0).size());
assertEquals(strings, partitionMax.get(0));
}
private static Predicate<Number> EQUALS_TWO = new Predicate<Number>() {