mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-10 03:56:11 +00:00
[COLLECTIONS-673] ListUtils.partition potential integer overflow.
Applied patch with reformatting.
This commit is contained in:
parent
274c9c1d37
commit
b88b065aa9
@ -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
|
||||
|
@ -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>() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user