commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-collections git commit: [COLLECTIONS-673] ListUtils.partition potential integer overflow. Applied patch with reformatting.
Date Tue, 12 Jun 2018 21:43:46 GMT
Repository: commons-collections
Updated Branches:
  refs/heads/master 274c9c1d3 -> b88b065aa


[COLLECTIONS-673] ListUtils.partition potential integer overflow.
Applied patch with reformatting.

Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/b88b065a
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/b88b065a
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/b88b065a

Branch: refs/heads/master
Commit: b88b065aa955d7a7d8f74c427b05d2243eda0779
Parents: 274c9c1
Author: Stephan Fuhrmann <s@sfuhrm.de>
Authored: Tue Jun 12 15:43:42 2018 -0600
Committer: Gary Gregory <garydgregory@gmail.com>
Committed: Tue Jun 12 15:43:42 2018 -0600

----------------------------------------------------------------------
 src/main/java/org/apache/commons/collections4/ListUtils.java     | 2 +-
 src/test/java/org/apache/commons/collections4/ListUtilsTest.java | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-collections/blob/b88b065a/src/main/java/org/apache/commons/collections4/ListUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java
index 12201a6..4d52847 100644
--- a/src/main/java/org/apache/commons/collections4/ListUtils.java
+++ b/src/main/java/org/apache/commons/collections4/ListUtils.java
@@ -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

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/b88b065a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
index 69747b7..8a23039 100644
--- a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
@@ -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>() {


Mime
View raw message