Attached is a test case that goes into an inifinite loop on calling ContentScanner.nextContent().
The only drawback I see is that not all of fCurrentEntity.stream support mark()ing, but nextContent() calls read() which can potentially calls load() which can get more buffer from the stream. I don't know how nextContent() can return back to the initial stream status if mark() is not supported.
Hope you find the patch useful.
1- original HtmlUnit bug resides in https://sourceforge.net/tracker/?func=detail&aid=2933404&group_id=47038&atid=448266
2- Current SVN build gives error on my machine