Missing line of code.  Was in bulk branch but not in realtime branch
Found by Findbugs bugtype: "Useless control flow"
Size does not need to be part of the API here.
Return value isn't used, get rid of it.
Add some javadocs
maxMessages is always 1 and is checked by the caller too.
maxMessages is always 1
Return value of size isn't used.
Size limits are inappropriate here. We want to return one message, full stop. Size limits are implemented at a higher level. Anything that reaches this far will be sent, even if we have to split it up (we often do, this is normal).
Incomplete is irrelevant, and can only be set if we add a message anyway. So get rid of it. Note that this refactoring should all have zero functional impact so far - it's simplifying the existing logic.
Remove size calculations completely, we don't need them and they don't do anything. In particular, the methods do not return negative values to indicate incomplete since the previous commit, and even when they did they only did so when we'd added a message.
Make the various methods return a MessageItem, delete the array. Code is now significantly simpler, in spite of all the changes being hopefully "trivial" individually, and gets rid of the last lot of pre-NFP cruft. Delete some now bogus comments too.
Synchronize the whole function grabQueuedMessageItem, like the comments said. Everything in the function is synchronized on the same lock anyway, so avoid reacquiring it repeatedly.
Add FIXME, thanks juiceman
Duplicated if(logMINOR) ty Findbugs.