You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/09/30 15:43:31 UTC

[skywalking] branch muse-bug-bash/IntLongMath created (now 40fe80a)

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

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


      at 40fe80a  Promote Integer to Long before multiplying to avoid numeric overflow

This branch includes the following new commits:

     new 40fe80a  Promote Integer to Long before multiplying to avoid numeric overflow

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking] 01/01: Promote Integer to Long before multiplying to avoid numeric overflow

Posted by ke...@apache.org.
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 <ke...@163.com>
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) {