Github user cestella commented on the issue:
https://github.com/apache/incubator-metron/pull/463
I reacted to your request, @justinleet . Also, I would like to put out a
request for the community:
The `delegatingSpliterator` pattern that I used uses polymorphism to
construct a delegate which allows me to count splits. I wanted to investigate
using mocks to do this in a cleaner way, but I kept getting off-by-one issues.
Here's what I did as a replacement for `delegatingSpliterator`
```
Spliterator<String> delegatingSpliterator = spy(spliterator);
when(delegatingSpliterator.trySplit()).thenAnswer(answer -> {
Spliterator<String> ret = spliterator.trySplit();
if(ret != null) {
numSplits.incrementAndGet();
}
return ret;
});
```
What I see is that I am processing 1 fewer splits than I expect. What we
have in the PR is perfectly sufficient and inoffensive, but I wanted to learn a
bit more about mockito and thought if anyone had insight, we could all get
better. :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---