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

fuyou001 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new d35c2c25 fix(csharp): correct inverted condition in GetMacAddress to 
prevent ArgumentOutOfRangeException on macOS arm64 (#1255)
d35c2c25 is described below

commit d35c2c2546001931612a75682685c339a98b76d5
Author: guyinyou <[email protected]>
AuthorDate: Tue Jun 2 22:12:47 2026 +0800

    fix(csharp): correct inverted condition in GetMacAddress to prevent 
ArgumentOutOfRangeException on macOS arm64 (#1255)
    
    The ternary condition in Utilities.GetMacAddress() was inverted:
    - When MAC address length < 6, it returned the short array
    - When MAC address length >= 6, it returned random bytes
    
    This caused MessageIdGenerator to throw ArgumentOutOfRangeException
    when calling writer.Write(macAddress, 0, 6) with an array shorter
    than 6 bytes, which occurs on macOS arm64 where some network
    interfaces return MAC addresses less than 6 bytes.
    
    Fixed by changing 'mac.Length < 6' to 'mac.Length >= 6' so that
    real MAC addresses are used when valid (>=6 bytes), and random
    bytes are used as fallback when too short.
    
    Co-authored-by: guyinyou <[email protected]>
---
 csharp/rocketmq-client-csharp/Utilities.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/csharp/rocketmq-client-csharp/Utilities.cs 
b/csharp/rocketmq-client-csharp/Utilities.cs
index ef4616ea..626fda01 100644
--- a/csharp/rocketmq-client-csharp/Utilities.cs
+++ b/csharp/rocketmq-client-csharp/Utilities.cs
@@ -57,7 +57,7 @@ namespace Org.Apache.Rocketmq
 
             var mac = nic.GetPhysicalAddress().GetAddressBytes();
 
-            return mac.Length < 6 ? mac : RandomMacAddressBytes;
+            return mac.Length >= 6 ? mac : RandomMacAddressBytes;
         }
 
         public static int GetProcessId()

Reply via email to