Skip to content

Commit 00f950a

Browse files
authored
Fix MarshalerUtil sizeRepeatedString calculation per issue#8272 (#8284)
1 parent 65052b0 commit 00f950a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal

exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/MarshalerUtil.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static int sizeRepeatedFixed64(ProtoFieldInfo field, int numValues) {
115115
public static int sizeRepeatedString(ProtoFieldInfo field, byte[][] utf8Bytes) {
116116
int size = 0;
117117
for (byte[] i : utf8Bytes) {
118-
size += MarshalerUtil.sizeBytes(field, i);
118+
size += sizeBytes(field, i, /* skipEmpty= */ false);
119119
}
120120
return size;
121121
}
@@ -384,7 +384,12 @@ public static int sizeFixed32(ProtoFieldInfo field, int message) {
384384

385385
/** Returns the size of a bytes field. */
386386
public static int sizeBytes(ProtoFieldInfo field, byte[] message) {
387-
if (message.length == 0) {
387+
return sizeBytes(field, message, /* skipEmpty= */ true);
388+
}
389+
390+
/** Returns the size of a bytes field. */
391+
public static int sizeBytes(ProtoFieldInfo field, byte[] message, boolean skipEmpty) {
392+
if (message.length == 0 && skipEmpty) {
388393
return 0;
389394
}
390395
return field.getTagSize() + CodedOutputStream.computeByteArraySizeNoTag(message);

0 commit comments

Comments
 (0)