aboutsummaryrefslogtreecommitdiff
path: root/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/CodedInputStream.java')
-rw-r--r--java/core/src/main/java/com/google/protobuf/CodedInputStream.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
index 4545d0ae..df4cc664 100644
--- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
+++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
@@ -77,8 +77,11 @@ public abstract class CodedInputStream {
return newInstance(input, DEFAULT_BUFFER_SIZE);
}
- /** Create a new CodedInputStream wrapping the given InputStream. */
- static CodedInputStream newInstance(final InputStream input, int bufferSize) {
+ /** Create a new CodedInputStream wrapping the given InputStream, with a specified buffer size. */
+ public static CodedInputStream newInstance(final InputStream input, int bufferSize) {
+ if (bufferSize <= 0) {
+ throw new IllegalArgumentException("bufferSize must be > 0");
+ }
if (input == null) {
// TODO(nathanmittler): Ideally we should throw here. This is done for backward compatibility.
return newInstance(EMPTY_BYTE_ARRAY);
@@ -130,7 +133,7 @@ public abstract class CodedInputStream {
/** Create a new CodedInputStream wrapping the given byte array slice. */
public static CodedInputStream newInstance(final byte[] buf, final int off, final int len) {
- return newInstance(buf, off, len, false /* bufferIsImmutable */);
+ return newInstance(buf, off, len, /* bufferIsImmutable= */ false);
}
/** Create a new CodedInputStream wrapping the given byte array slice. */
@@ -166,7 +169,7 @@ public abstract class CodedInputStream {
* trying to alter the ByteBuffer's status.
*/
public static CodedInputStream newInstance(ByteBuffer buf) {
- return newInstance(buf, false /* bufferIsImmutable */);
+ return newInstance(buf, /* bufferIsImmutable= */ false);
}
/** Create a new CodedInputStream wrapping the given buffer. */
@@ -410,7 +413,6 @@ public abstract class CodedInputStream {
return oldLimit;
}
-
private boolean shouldDiscardUnknownFields = false;
/**