In the current code, the constructor of MessageBuffer is package private and the src variable will be initialized one of the DirectBuffer or HeapByteBuffer. So it never reaches the last condition.  

In this sense, this should be IllegalStateException, instead of IllegalArgumentException.