/** * Reads a varint from the input one byte at a time, so that it does not * read any bytes after the end of the varint. If you simply wrapped the * stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)} * then you would probably end up reading past the end of the varint since * CodedInputStream buffers its input. */ static int readRawVarint32(final InputStream input) throws IOException { final int firstByte = input.read(); if (firstByte == -1) { throw InvalidProtocolBufferException.truncatedMessage(); } return readRawVarint32(firstByte, input); }
/** * Reads a varint from the input one byte at a time, so that it does not * read any bytes after the end of the varint. If you simply wrapped the * stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)} * then you would probably end up reading past the end of the varint since * CodedInputStream buffers its input. */ static int readRawVarint32(final InputStream input) throws IOException { final int firstByte = input.read(); if (firstByte == -1) { throw InvalidProtocolBufferException.truncatedMessage(); } return readRawVarint32(firstByte, input); }
/** * Reads a varint from the input one byte at a time, so that it does not * read any bytes after the end of the varint. If you simply wrapped the * stream in a CodedInputStream and used {@link #readRawVarint32(InputStream)} * then you would probably end up reading past the end of the varint since * CodedInputStream buffers its input. */ static int readRawVarint32(final InputStream input) throws IOException { final int firstByte = input.read(); if (firstByte == -1) { throw InvalidProtocolBufferException.truncatedMessage(); } return readRawVarint32(firstByte, input); }
final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage(); final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage();
final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage(); final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage();
final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage(); final int b = input.read(); if (b == -1) { throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage(); } else { return false; bufferSize = 0; if (mustSucceed) { throw InvalidProtocolBufferException.truncatedMessage(); } else { return false;
throw InvalidProtocolBufferException.truncatedMessage(); } else { return false; bufferSize = 0; if (mustSucceed) { throw InvalidProtocolBufferException.truncatedMessage(); } else { return false;
throw InvalidProtocolBufferException.truncatedMessage(); } else { return false; bufferSize = 0; if (mustSucceed) { throw InvalidProtocolBufferException.truncatedMessage(); } else { return false;
/** * Sets {@code currentLimit} to (current position) + {@code byteLimit}. This * is called when descending into a length-delimited embedded message. * * <p>Note that {@code pushLimit()} does NOT affect how many bytes the * {@code CodedInputStream} reads from an underlying {@code InputStream} when * refreshing its buffer. If you need to prevent reading past a certain * point in the underlying {@code InputStream} (e.g. because you expect it to * contain more data after the end of the message which you need to handle * differently) then you must place a wrapper around your {@code InputStream} * which limits the amount of data that can be read from it. * * @return the old limit. */ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException { if (byteLimit < 0) { throw InvalidProtocolBufferException.negativeSize(); } byteLimit += totalBytesRetired + bufferPos; final int oldLimit = currentLimit; if (byteLimit > oldLimit) { throw InvalidProtocolBufferException.truncatedMessage(); } currentLimit = byteLimit; recomputeBufferSizeAfterLimit(); return oldLimit; }
/** * Sets {@code currentLimit} to (current position) + {@code byteLimit}. This * is called when descending into a length-delimited embedded message. * * <p>Note that {@code pushLimit()} does NOT affect how many bytes the * {@code CodedInputStream} reads from an underlying {@code InputStream} when * refreshing its buffer. If you need to prevent reading past a certain * point in the underlying {@code InputStream} (e.g. because you expect it to * contain more data after the end of the message which you need to handle * differently) then you must place a wrapper around your {@code InputStream} * which limits the amount of data that can be read from it. * * @return the old limit. */ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException { if (byteLimit < 0) { throw InvalidProtocolBufferException.negativeSize(); } byteLimit += totalBytesRetired + bufferPos; final int oldLimit = currentLimit; if (byteLimit > oldLimit) { throw InvalidProtocolBufferException.truncatedMessage(); } currentLimit = byteLimit; recomputeBufferSizeAfterLimit(); return oldLimit; }
/** * Sets {@code currentLimit} to (current position) + {@code byteLimit}. This * is called when descending into a length-delimited embedded message. * * <p>Note that {@code pushLimit()} does NOT affect how many bytes the * {@code CodedInputStream} reads from an underlying {@code InputStream} when * refreshing its buffer. If you need to prevent reading past a certain * point in the underlying {@code InputStream} (e.g. because you expect it to * contain more data after the end of the message which you need to handle * differently) then you must place a wrapper around your {@code InputStream} * which limits the amount of data that can be read from it. * * @return the old limit. */ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException { if (byteLimit < 0) { throw InvalidProtocolBufferException.negativeSize(); } byteLimit += totalBytesRetired + bufferPos; final int oldLimit = currentLimit; if (byteLimit > oldLimit) { throw InvalidProtocolBufferException.truncatedMessage(); } currentLimit = byteLimit; recomputeBufferSizeAfterLimit(); return oldLimit; }
throw InvalidProtocolBufferException.truncatedMessage(); input.read(chunk, pos, chunk.length - pos); if (n == -1) { throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage(); input.read(chunk, pos, chunk.length - pos); if (n == -1) { throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage(); input.read(chunk, pos, chunk.length - pos); if (n == -1) { throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage();
throw InvalidProtocolBufferException.truncatedMessage();