-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #11994]修复HttpRequestInstanceBuilderTest出现的空指针问题,优化SnowFlakeInstanceIdGenerator初始化流程 #11995
Conversation
…in HttpRequestInstanceBuilderTest
Error: /home/runner/work/nacos/nacos/naming/src/main/java/com/alibaba/nacos/naming/pojo/instance/SnowFlakeInstanceIdGenerator.java:37:33: Name 'lock' must match pattern '^[A-Z][A-Z0-9](_[A-Z0-9]+)$'. [ConstantName] Please fix code style problem. |
@KomachiSion I have fixed it. |
@@ -54,6 +56,7 @@ public class HttpRequestInstanceBuilderTest { | |||
@BeforeClass | |||
public static void setUpBeforeClass() { | |||
NacosServiceLoader.load(InstanceExtensionHandler.class); | |||
EnvUtil.setEnvironment(new StandardEnvironment()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No problem, I will fix it in next PR. |
…lakeInstanceIdGenerator初始化流程 (alibaba#11995) * [ISSUE alibaba#11994] fix: Initialize EnvUtil's variable environment in HttpRequestInstanceBuilderTest * refactor: Optimize the initialization process of SnowFlakeInstanceIdGenerator * refactor: optimize the initialization process of SnowFlakeInstanceIdGenerator.
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
fix unit test bug.
解决SnowFlakeInstanceIdGenerator类加载时强依赖workerId的初始化过程。
Brief changelog
@BeforeClass增加EnvUtil.setEnvironment(new StandardEnvironment());
改变WorkerId的加载方式。通过SnowFlakeInstanceIdGenerator静态代码块加载->在generateInstanceId通过双检锁保证加载一次
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.