Merge branch 'pr-120'

This closes #120
This commit is contained in:
Bruno P. Kinoshita 2020-03-28 18:14:42 +13:00
commit 45ea11ad15
4 changed files with 11 additions and 6 deletions

View File

@ -21,6 +21,9 @@
</properties>
<body>
<release version="4.5" date="2020-MM-DD" description="Maintenance release.">
<action issue="COLLECTIONS-737" dev="kinow" type="update" due-to="Prodigysov">
Return 0 immeditaly if the given iterable is null in IterableUtils#size. Update tests.
</action>
<action issue="COLLECTIONS-697" dev="eax" type="update" due-to="Ranjan George">
JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented
</action>

View File

@ -797,6 +797,9 @@ public class IterableUtils {
* @return the number of elements contained in the iterable
*/
public static int size(final Iterable<?> iterable) {
if (iterable == null) {
return 0;
}
if (iterable instanceof Collection<?>) {
return ((Collection<?>) iterable).size();
}

View File

@ -416,12 +416,6 @@ public class FluentIterableTest {
@Test
public void size() {
try {
FluentIterable.of((Iterable<?>) null).size();
fail("expecting NullPointerException");
} catch (final NullPointerException npe) {
// expected
}
assertEquals(0, FluentIterable.of(emptyIterable).size());
assertEquals(IterableUtils.toList(iterableOdd).size(), FluentIterable.of(iterableOdd).size());
}

View File

@ -579,4 +579,9 @@ public class IterableUtilsTest {
// expected
}
}
@Test
public void size() {
assertEquals(0, IterableUtils.size(null));
}
}