This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch muse-bug-bash/IntLongMath
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit 40fe80a86fab6716dd072c0939d359a9b7bd9d76
Author: kezhenxu94 <[email protected]>
AuthorDate: Wed Sep 30 23:43:08 2020 +0800

    Promote Integer to Long before multiplying to avoid numeric overflow
---
 .../org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java
 
b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java
index 26c7ab0..f480ed7 100644
--- 
a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java
+++ 
b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java
@@ -41,7 +41,8 @@ public class Channels<T> {
                 bufferChannels[i] = new Buffer<T>(bufferSize, strategy);
             }
         }
-        size = channelSize * bufferSize;
+        // noinspection PointlessArithmeticExpression
+        size = 1L * channelSize * bufferSize; // it's not pointless, it 
prevents numeric overflow before assigning an integer to a long
     }
 
     public boolean save(T data) {

Reply via email to