So, this used to be an assertion (basically), but you've turned it into an actual sanity check against the input buffer.  Not sure that AssertionError is the right thing to throw any more?  (Also kinda turned off by the throw RuntimeExceptions I've seen added elsewhere, but, meh?)