From b53cbda64219578a29624f9d21796fbb4ecabb30 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 3 Nov 2023 13:52:03 +0800 Subject: [PATCH] ci: rid test sync --- .../io/metersphere/system/rid/RIdGeneratorTests.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/rid/RIdGeneratorTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/rid/RIdGeneratorTests.java index 358fe6e771..9c60586a5f 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/rid/RIdGeneratorTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/rid/RIdGeneratorTests.java @@ -31,8 +31,10 @@ public class RIdGeneratorTests { executorService.submit(() -> { long nextId = NumGenerator.nextNum(projectId, ApplicationNumScope.API_DEFINITION); System.out.println(nextId); - if (atomicLong.get() < nextId) { - atomicLong.set(nextId); + synchronized (projectId) { + if (atomicLong.get() < nextId) { + atomicLong.set(nextId); + } } }); } @@ -58,8 +60,10 @@ public class RIdGeneratorTests { // 接口用例的前缀为: PROJECT_ID_API_DEFINITION 比较特殊 long nextId = NumGenerator.nextNum(projectId + "_" + apiNum, ApplicationNumScope.API_TEST_CASE); System.out.println(nextId); - if (atomicLong.get() < nextId) { - atomicLong.set(nextId); + synchronized (projectId) { + if (atomicLong.get() < nextId) { + atomicLong.set(nextId); + } } }); }