Github user justinleet commented on the issue:

    https://github.com/apache/incubator-metron/pull/463
  
    I figured out why
    
    From the docs:
    ```
    
       List list = new LinkedList();
       List spy = spy(list);
    
       //Impossible: real method is called so spy.get(0) throws 
IndexOutOfBoundsException (the list is yet empty)
       when(spy.get(0)).thenReturn("foo");
    
       //You have to use doReturn() for stubbing
       doReturn("foo").when(spy).get(0);
    ```
    So the first call to @cestella's trySplit() is in the when(), not in the 
lambda.  The subsequent calls are.  So everything shifts by one.
    
    As the docs note "Sometimes it's impossible or impractical to use 
when(Object) for stubbing spies. Therefore when using spies please consider 
doReturn|Answer|Throw() family of methods for stubbing."
    
    I just happened to try this, and now I know why it works.


---
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.
---

Reply via email to