Skip to content
Snippets Groups Projects
Commit 9f7e2f58 authored by Christian Wulf's avatar Christian Wulf
Browse files

added check for negative input in ObjectProducer

parent eb3c8495
No related branches found
No related tags found
No related merge requests found
#FindBugs User Preferences
#Tue Apr 21 14:17:42 CEST 2015
#Tue Apr 21 16:50:39 CEST 2015
detector_threshold=3
effort=max
excludefilter0=.fbExcludeFilterFile|true
......
......@@ -32,6 +32,9 @@ public final class ObjectProducer<T> extends AbstractProducerStage<T> {
* @since 1.0
*/
public ObjectProducer(final long numInputObjects, final ConstructorClosure<T> inputObjectCreator) {
if (numInputObjects < 0) {
throw new IllegalArgumentException("numInputObjects must be non-negative.");
}
this.numInputObjects = numInputObjects;
this.inputObjectCreator = inputObjectCreator;
}
......
wiki @ 0e447457
Subproject commit 162510ff4d2f04011498ba6920aae0c78347c6c8
Subproject commit 0e4474577e1f49bc96e734c286b2d9e0363895e8
......@@ -53,6 +53,14 @@ public class ObjectProducerTest {
assertThat(results, is(empty()));
}
@Test(expected = IllegalArgumentException.class)
public void producerShouldFailOnNegativeInput() {
final List<Integer> results = new ArrayList<Integer>();
final ObjectProducer<Integer> producer = new ObjectProducer<Integer>(-1, new Generator());
test(producer).and().receive(results).from(producer.getOutputPort()).start();
}
private static class Generator implements ConstructorClosure<Integer> {
private int counter = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment