Skip to content

Conversation

@YoWuwuuuw
Copy link
Contributor

@YoWuwuuuw YoWuwuuuw commented May 19, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

  1. Use TreeSet to Increase the MultiRegistryFactory check for repeated registryType
  2. Increase the inspection of RegistryFactory to air registryTypeName(align MultiRegistryFactory)
  3. Put the logic of throwing NotSupportYetException into RegistryType.getType ()

Ⅱ. Does this pull request fix one issue?

#7342

Ⅲ. Why don't you add test cases (unit test/integration test)?

Covers two factory

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.48%. Comparing base (152a7f9) to head (4659493).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7345      +/-   ##
============================================
+ Coverage     58.41%   58.48%   +0.06%     
  Complexity      535      535              
============================================
  Files          1272     1272              
  Lines         45853    45850       -3     
  Branches       5520     5521       +1     
============================================
+ Hits          26785    26815      +30     
+ Misses        16546    16520      -26     
+ Partials       2522     2515       -7     
Files with missing lines Coverage Δ
...seata/discovery/registry/MultiRegistryFactory.java 94.73% <100.00%> (+89.97%) ⬆️
...ache/seata/discovery/registry/RegistryFactory.java 90.00% <100.00%> (+17.27%) ⬆️
.../apache/seata/discovery/registry/RegistryType.java 100.00% <100.00%> (+12.50%) ⬆️

... and 9 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@YongGoose YongGoose self-requested a review May 20, 2025 06:27
Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good 👍🏻

Left some comments!

And also, If the implementation is created through RegistryType, it would be better to verify that the intended implementation is created (e.g., using assertEquals) rather than using assertNotNull.

Comment on lines 73 to 75
if (processedRegistryTypes.contains(registryType.name())) {
LOGGER.warn("The duplicate registration center type '{}' was found in the configuration and has been skipped.", registryType.name());
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw a test that verifies a method was called once by checking if instances.size() equals 1.
How about also adding a test to verify that the corresponding log message is properly output?

What do you think?

Copy link
Contributor Author

@YoWuwuuuw YoWuwuuuw May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, learned and used the method you wrote before in #7315 (it's awesome)

}

/**
* Use reflection to call the buildRegistryServices method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the comment should refer to buildRegistryService instead of buildRegistryServices.

@YongGoose
Copy link
Member

@slievrly

Please take a look :)
image

if (StringUtils.isBlank(registryTypeNamesStr)) {
registryTypeNamesStr = RegistryType.File.name();
}
String[] registryTypeNames = registryTypeNamesStr.split(Constants.REGISTRY_TYPE_SPLIT_CHAR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not convert this directly to a TreeSet? This would allow for case-insensitivity and also handle deduplication

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Also, it would be great to add a test case that covers this scenario.

@YongGoose YongGoose self-requested a review May 23, 2025 03:36
Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’re almost there!
Just a few more things to add and it should be good to go.

Copy link
Member

@YongGoose YongGoose May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it’s been changed to a TreeSet, it might be good to add a few more test cases

  1. When the same RegistryType is provided with different casing (e.g., File, FILE), does it recognize them as the same?

    • This could be verified by checking that no log is printed.
  2. When more than one RegistryType is provided, does the log output as expected?

  3. When a value not defined in RegistryType is passed, is the appropriate exception thrown? (After removing the try-catch block, this test should be added.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

LOGGER.info("use registry center type: {}", registryTypeName);
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try-catch block could be removed, as it simply catches the exception and rethrows it without adding any additional handling.

@YongGoose YongGoose self-requested a review May 23, 2025 11:31
@YongGoose
Copy link
Member

YongGoose commented May 23, 2025

@YoWuwuuuw

I noticed a very minor change was needed, so I opened a PR to your branch.
YoWuwuuuw#10

Feel free to ping me when you have questions :)

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@funky-eyes funky-eyes added this to the 2.5.0 milestone May 26, 2025
Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@funky-eyes funky-eyes merged commit 721dce6 into apache:2.x May 26, 2025
7 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants