*
* @param eof {@code true} if there is no more data in the buffered part of the stream
* @return a new OptionalDataException
*/
public static OptionalDataException createOptionalDataException(boolean eof) {
final OptionalDataException optionalDataException = createOptionalDataException();
final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
final StackTraceElement[] copyStackTrace = new StackTraceElement[stackTrace.length - 1];
System.arraycopy(stackTrace, 1, copyStackTrace, 0, copyStackTrace.length);
optionalDataException.setStackTrace(copyStackTrace);
optionalDataException.eof = eof;
return optionalDataException;
}