From 20ddd56f93146ffdbe616c462bc181c04e8e29f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Mon, 6 Mar 2023 11:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91UUIDGenerator?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jero/common/util/UUIDGenerator.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/UUIDGenerator.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/UUIDGenerator.java index 04efe742..aaf25289 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/UUIDGenerator.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/UUIDGenerator.java @@ -4,16 +4,20 @@ package com.jero.common.util; import java.net.InetAddress; /** - * + * * @Author 张代浩 * */ public class UUIDGenerator { - + private UUIDGenerator(){ + + } + + /** * 产生一个32位的UUID - * + * * @return */ @@ -21,7 +25,7 @@ public class UUIDGenerator { return new StringBuilder(32).append(format(getIP())).append( format(getJVM())).append(format(getHiTime())).append( format(getLoTime())).append(format(getCount())).toString(); - + } private static final int IP; @@ -87,9 +91,8 @@ public class UUIDGenerator { private final static int toInt(byte[] bytes) { int result = 0; for (int i = 0; i < 4; i++) { - result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; + result = (result << 8) - (Byte.MIN_VALUE & 0xff) + bytes[i]; } return result; } - }