This is an automated email from the ASF dual-hosted git repository.
jonyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new 0a1302017 [ISSUE #1538] Fixes issue with integer-based for loop in
BatchMessage.java (#2924)
0a1302017 is described below
commit 0a13020172e2d608754c3041ef761b207ccbaf1c
Author: Or Cohen <[email protected]>
AuthorDate: Wed Jan 18 04:17:45 2023 +0200
[ISSUE #1538] Fixes issue with integer-based for loop in BatchMessage.java
(#2924)
* Fixes issue with integer-based for loop in BatchMessage.java by using an
iterator or foreach
* Fixes issue with integer-based for loop in BatchMessage.java by using
foreach
* Fixes issue with integer-based for loop in BatchMessage.java by using
stream()
---
.../common/protocol/grpc/protos/BatchMessage.java | 28 ++++++++--------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git
a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java
b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java
index 7cee369c8..309e32764 100644
---
a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java
+++
b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/BatchMessage.java
@@ -21,6 +21,7 @@
package org.apache.eventmesh.common.protocol.grpc.protos;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
import com.google.protobuf.ByteString;
@@ -1542,24 +1543,15 @@ public final class BatchMessage extends
}
public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) return size;
-
- size = 0;
- size += (header_ != null ?
- com.google.protobuf.CodedOutputStream.computeMessageSize(1,
getHeader()) : 0)
- +
- (!getProducerGroupBytes().isEmpty() ?
-
com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerGroup_) : 0)
- +
- (!getTopicBytes().isEmpty() ?
-
com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_) : 0);
-
- for (int i = 0; i < messageItem_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(4, messageItem_.get(i));
- }
-
+ int size;
+ if (memoizedSize != -1) return memoizedSize;
+ size = header_ != null ?
+ com.google.protobuf.CodedOutputStream.computeMessageSize(1,
getHeader()) : 0;
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2,
producerGroup_);
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3,
topic_);
+ size += messageItem_.stream()
+ .mapToInt(messageItem ->
com.google.protobuf.CodedOutputStream.computeMessageSize(4, messageItem))
+ .sum();
size += unknownFields.getSerializedSize();
memoizedSize = size;
return memoizedSize;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]