From 37f481c16f3a2ce892f0ac9e5e8ec9a8d7ab167f Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Thu, 5 Sep 2024 19:28:25 -0700 Subject: [PATCH] ArrayDecoders: tag methods as throwing more-specific exception This is a no-op cleanup. The methods are package-private so shouldn't be an API break. I'm about to add some more tests here. This just makes writing the tests easier , as they don't have to catch IOException any more. PiperOrigin-RevId: 671592242 --- .../com/google/protobuf/ArrayDecoders.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/ArrayDecoders.java b/java/core/src/main/java/com/google/protobuf/ArrayDecoders.java index 9bf1439626..889b7bcfa3 100644 --- a/java/core/src/main/java/com/google/protobuf/ArrayDecoders.java +++ b/java/core/src/main/java/com/google/protobuf/ArrayDecoders.java @@ -455,7 +455,8 @@ final class ArrayDecoders { /** Decodes a packed fixed32 field. Returns the position after all read values. */ static int decodePackedFixed32List( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final IntArrayList output = (IntArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -471,7 +472,8 @@ final class ArrayDecoders { /** Decodes a packed fixed64 field. Returns the position after all read values. */ static int decodePackedFixed64List( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final LongArrayList output = (LongArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -487,7 +489,8 @@ final class ArrayDecoders { /** Decodes a packed float field. Returns the position after all read values. */ static int decodePackedFloatList( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final FloatArrayList output = (FloatArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -503,7 +506,8 @@ final class ArrayDecoders { /** Decodes a packed double field. Returns the position after all read values. */ static int decodePackedDoubleList( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final DoubleArrayList output = (DoubleArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -519,7 +523,8 @@ final class ArrayDecoders { /** Decodes a packed boolean field. Returns the position after all read values. */ static int decodePackedBoolList( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final BooleanArrayList output = (BooleanArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -535,7 +540,8 @@ final class ArrayDecoders { /** Decodes a packed sint32 field. Returns the position after all read values. */ static int decodePackedSInt32List( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final IntArrayList output = (IntArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1; @@ -551,7 +557,8 @@ final class ArrayDecoders { /** Decodes a packed sint64 field. Returns the position after all read values. */ static int decodePackedSInt64List( - byte[] data, int position, ProtobufList list, Registers registers) throws IOException { + byte[] data, int position, ProtobufList list, Registers registers) + throws InvalidProtocolBufferException { final LongArrayList output = (LongArrayList) list; position = decodeVarint32(data, position, registers); final int fieldLimit = position + registers.int1;