From dd78f0ac12b5134b011d93f43d681415b481c30e Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Wed, 2 Oct 2024 18:47:37 -0700 Subject: [PATCH] No-op: move position updating to end of method for consistency Other methods are now updating position at the end of the method. Also, it's good practice to limit the scope of try { } blocks. This is a partial roll-forward of cl/673588324 PiperOrigin-RevId: 681673291 --- .../src/main/java/com/google/protobuf/CodedOutputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java index 0e381b268b..fccdb2178e 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java @@ -1433,10 +1433,10 @@ public abstract class CodedOutputStream extends ByteOutput { public final void write(byte[] value, int offset, int length) throws IOException { try { System.arraycopy(value, offset, buffer, position, length); - position += length; } catch (IndexOutOfBoundsException e) { throw new OutOfSpaceException(position, limit, length, e); } + position += length; } @Override