static InvalidProtocolBufferException truncatedMessage() { return new InvalidProtocolBufferException("While parsing a protocol message, the input ended unexpectedly " + "in the middle of a field. This could mean either than the " + "input has been truncated or that an embedded message " + "misreported its own length."); }
static InvalidProtocolBufferException sizeLimitExceeded() { return new InvalidProtocolBufferException("Protocol message was too large. May be malicious. " + "Use CodedInputStream.setSizeLimit() to increase the size limit."); } }
static InvalidProtocolBufferException invalidEndTag() { return new InvalidProtocolBufferException("Protocol message end-group tag did not match expected tag."); }
static InvalidProtocolBufferException invalidWireType() { return new InvalidProtocolBufferException("Protocol message tag had invalid wire type."); }
static InvalidProtocolBufferException recursionLimitExceeded() { return new InvalidProtocolBufferException("Protocol message had too many levels of nesting. May be malicious. " + "Use CodedInputStream.setRecursionLimit() to increase the depth limit."); }
static InvalidProtocolBufferException negativeSize() { return new InvalidProtocolBufferException("CodedInputStream encountered an embedded string or message " + "which claimed to have negative size."); }
static InvalidProtocolBufferException malformedVarint() { return new InvalidProtocolBufferException("CodedInputStream encountered a malformed varint."); }
static InvalidProtocolBufferException invalidTag() { return new InvalidProtocolBufferException("Protocol message contained an invalid tag (zero)."); }
static protected byte readRawByte(InputStream is) throws IOException { int rc = is.read(); if (rc == -1) { throw new InvalidProtocolBufferException("While parsing a protocol message, the input ended unexpectedly " + "in the middle of a field. This could mean either than the " + "input has been truncated or that an embedded message " + "misreported its own length."); } return (byte) rc; }
static public byte readRawByte(InputStream is) throws IOException { int rc = is.read(); if (rc == -1) { throw new InvalidProtocolBufferException("While parsing a protocol message, the input ended unexpectedly " + "in the middle of a field. This could mean either than the " + "input has been truncated or that an embedded message " + "misreported its own length.", true); } return (byte) rc; }
/** * Converts this exception to an {@link InvalidProtocolBufferException}. * When a parsed message is missing required fields, this should be thrown * instead of {@code UninitializedMessageException}. */ public InvalidProtocolBufferException asInvalidProtocolBufferException() { return new InvalidProtocolBufferException(getMessage()); }
public T mergeFramed(InputStream input) throws IOException { int length = readRawVarint32(input); byte[] data = new byte[length]; int pos = 0; while (pos < length) { int r = input.read(data, pos, length - pos); if (r < 0) { throw new InvalidProtocolBufferException("Input stream ended before a full message frame could be read."); } pos += r; } return mergeUnframed(data); }
public static Buffer readFrame(java.io.InputStream input) throws IOException { int length = 0; try { length = readRawVarint32(input); } catch (InvalidProtocolBufferException e) { if( e.isEOF() ) { throw new EOFException(); } else { throw e; } } byte[] data = new byte[length]; int pos = 0; while (pos < length) { int r = input.read(data, pos, length - pos); if (r < 0) { throw new InvalidProtocolBufferException("Input stream ended before a full message frame could be read."); } pos += r; } return new Buffer(data); }
return result; throw new InvalidProtocolBufferException("CodedInputStream encountered a malformed varint.");
return result; throw new InvalidProtocolBufferException("CodedInputStream encountered a malformed varint.");