Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.4
-
None
-
None
Description
3 methods from ClosureUtils fails to throw an IllegalArgumentException when at least one of their parameters is empty.
The methods and the test cases that highlight the issue are the following:
ClosureUtils.chainedClosure (Collection<? extends Closure<? super E>> closures)
public class ClosureUtils_failure_Test_1 { public void test() throws Throwable { LinkedList<Closure<Object>> linkedList = new LinkedList<Closure<Object>>(); try { Closure<Object> closure = ClosureUtils.chainedClosure( (Collection<? extends Closure<? super Object>>) linkedList); org.junit.Assert.fail(); } catch (java.lang.IllegalArgumentException e) { //Exception caught and test successful } } }
ClosureUtils.switchMapClosure (Map<? extends E, Closure<E>> objectsAndClosures)
public class ClosureUtils_failure_Test_2 { public void test() throws Throwable { HashMap<Object, Closure<Object>> hashMap = new HashMap<Object, Closure<Object>>(); try { Closure<Object> closure = ClosureUtils.switchMapClosure( (Map<?, Closure<Object>>) hashMap); org.junit.Assert.fail(); } catch (java.lang.IllegalArgumentException e) { //Exception caught and test successful } } }
ClosureUtils.switchClosure (Map<Predicate<E>, Closure<E>> predicatesAndClosures)
public class ClosureUtils_failure_Test_3 { public void test() throws Throwable { HashMap<Predicate<Object>, Closure<Object>> hashMap = new HashMap<>(); try { Closure<Object> closure = ClosureUtils.switchClosure(hashMap); org.junit.Assert.fail(); } catch (java.lang.IllegalArgumentException e) { //Exception caught and test successful } } }
All the above test cases fail to catch an IllegalArgumentException.
I was taking a look at the upcoming version currently in development and all 3 methods seems to return an empty NOPClosure, without throwing any IllegalArgumentException. Is the code wrong or the documentation simply out of date?