aboutsummaryrefslogtreecommitdiffhomepage
path: root/java/core/src/main/java/com/google/protobuf/Parser.java
diff options
context:
space:
mode:
authorGravatar Joshua Humphries <jh@squareup.com>2015-10-20 16:24:48 -0400
committerGravatar Joshua Humphries <jh@squareup.com>2016-01-15 21:51:19 -0500
commitf3c75580e4e7b18c372e1f83e4283701c01bcaca (patch)
tree7fc56ae23162f1e90c1dd15cda04f7d4b4f9fe7b /java/core/src/main/java/com/google/protobuf/Parser.java
parent9a5d892e2a2708335a3223d10e268ea932245e15 (diff)
throw IOException instead of InvalidProtocolBufferException when appropriate
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/Parser.java')
-rw-r--r--java/core/src/main/java/com/google/protobuf/Parser.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/Parser.java b/java/core/src/main/java/com/google/protobuf/Parser.java
index 227c02b7..3fa11c3b 100644
--- a/java/core/src/main/java/com/google/protobuf/Parser.java
+++ b/java/core/src/main/java/com/google/protobuf/Parser.java
@@ -30,6 +30,7 @@
package com.google.protobuf;
+import java.io.IOException;
import java.io.InputStream;
/**
@@ -37,9 +38,20 @@ import java.io.InputStream;
*
* The implementation should be stateless and thread-safe.
*
+ * <p>All methods may throw {@link InvalidProtocolBufferException}. In the event of invalid data,
+ * like an encoding error, the cause of the thrown exception will be {@code null}. However, if an
+ * I/O problem occurs, an exception is thrown with an {@link IOException} cause.
+ *
* @author liujisi@google.com (Pherl Liu)
*/
public interface Parser<MessageType> {
+
+ // NB(jh): Other parts of the protobuf API that parse messages distinguish between an I/O problem
+ // (like failure reading bytes from a socket) and invalid data (encoding error) via the type of
+ // thrown exception. But it would be source-incompatible to make the methods in this interface do
+ // so since they were originally spec'ed to only throw InvalidProtocolBufferException. So callers
+ // must inspect the cause of the exception to distinguish these two cases.
+
/**
* Parses a message of {@code MessageType} from the input.
*