Scan through the commits using Java API

Hello,

I am building a plugin but I need to gather some metadata from all commits in chronological (commit date) order from all repos.

Every method I try using (except commitService.traverse that does not support chronological order) from CommitService errs with

[INFO] java.lang.IllegalStateException: At least one commit must be provided to include

How can I scan through the commits using the Java API?

Update: You can specify all the branches and the commitService works but when you try to scroll through all the branches in the repo you get:

[INFO] org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
[INFO] 	at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:379)
[INFO] 	at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:223)
[INFO] 	at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:65)
[INFO] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] 	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
[INFO] 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
[INFO] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] 	at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:112)
[INFO] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
[INFO] 	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
[INFO] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
[INFO] 	at com.sun.proxy.$Proxy315.streamCommitsBetween(Unknown Source)
[INFO] 	at sun.reflect.GeneratedMethodAccessor1615.invoke(Unknown Source)
[INFO] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] 	at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] 	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
[INFO] 	at com.sun.proxy.$Proxy522.streamCommitsBetween(Unknown Source)
[INFO] 	at com.fourpsa.Sync.lambda$null$0(Sync.java:70)
[INFO] 	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
[INFO] 	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
[INFO] 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
[INFO] 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
[INFO] 	at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:747)
[INFO] 	at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:721)
[INFO] 	at java.util.stream.AbstractTask.compute(AbstractTask.java:316)
[INFO] 	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
[INFO] 	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
[INFO] 	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
[INFO] 	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
[INFO] 	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)

even when running with:

ComponentLocator.getComponent(SecurityService.class).impersonating(
                adminUser
                , "Sync service"
        )