Feeding MongoDB a Whole Load of Nothingness
I just found out the hard way what happens when you feed MongoDB (via the Java Driver) an empty List<T>
:
java.lang.IllegalStateException: state should be: count
The error iteself was a difficult one to find online. Though after a brief look at the code at the point of failure, and a couple of Logger.info(...)
statements thrown in for good measure, I spotted a getCollection().save(...)
with an empty list as an argument.
Just thought it might be a useful one to share - just incase!