From 11117398ddca0c3194d972e821921c32612e8de2 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 24 Aug 2026 15:29:34 -0700 Subject: [PATCH] Update CodedInputStream Javadoc regarding exception handling and isAtEnd behavior. PiperOrigin-RevId: 970118591 --- .../com/google/protobuf/CodedInputStream.java | 15 ++++++++++----- 1 file changed, 10 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 76e5cafd0f..033187ab46 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java @@ -31,6 +31,11 @@ import java.util.List; * reading encoded protocol messages, you should use the former methods, but if you are reading some * other format of your own design, use the latter. * + *

Critical note on Exceptions: If any method throws an exception (such as an {@link + * java.io.IOException} or {@link InvalidProtocolBufferException}), it can desynchronize the + * instance and leave its internal state unspecified. The instance should not be used further and + * must be discarded. + * * @author kenton@google.com Kenton Varda */ public abstract class CodedInputStream { @@ -635,11 +640,11 @@ public abstract class CodedInputStream { public abstract int getBytesUntilLimit(); /** - * Returns true if the stream has reached the end of the input. This is the case if either the end - * of the underlying input source has been reached or if the stream has reached a limit created - * using {@link #pushLimit(int)}. This function may get blocked when using StreamDecoder as it - * invokes {@link StreamDecoder#tryRefillBuffer(int)} in this function which will try to read - * bytes from input. + * Returns true if the stream has reached the end of the input. This is the case if the current + * position is at the exact end of the underlying input source or at a limit created using {@link + * #pushLimit(int)}, without passing over the limit. This function may get blocked when using + * StreamDecoder as it invokes {@link StreamDecoder#tryRefillBuffer(int)} in this function which + * will try to read bytes from input. */ public abstract boolean isAtEnd() throws IOException;