Fix thread blocking in NotificationControllerV2 by replacing synchronized Multimap with case-insensitive concurrent implementation#5451
Fix thread blocking in NotificationControllerV2 by replacing synchronized Multimap with case-insensitive concurrent implementation#5451Copilot wants to merge 8 commits into
Conversation
|
@nobodyiam 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: nobodyiam <[email protected]>
Co-authored-by: nobodyiam <[email protected]>
|
@copilot the build failed with the error messages |
Co-authored-by: nobodyiam <[email protected]>
... Fixed the compilation errors by adding back the missing Commit: e49746c Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
…ultimap Co-authored-by: nobodyiam <[email protected]>
I've addressed all three questions:
The implementation now fully implements the Guava Multimap interface with comprehensive methods like Commit: 1e63197 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
We could define the variable using the Multimap interface. See comments below.
Also, please update CHANGES.md to reflect this PR and fix the compilation issue:
Error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project apollo-configservice: Compilation failure: Compilation failure:
Error: /home/runner/work/apollo/apollo/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java:[83,11] cannot find symbol
Error: symbol: class ConcurrentMultimap
Error: location: class com.ctrip.framework.apollo.configservice.controller.NotificationControllerV2Test
Error: /home/runner/work/apollo/apollo/apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java:[110,10] cannot find symbol
Error: symbol: class ConcurrentMultimap
Error: location: class com.ctrip.framework.apollo.configservice.controller.NotificationControllerV2Test
Error: -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Error:
Error: After correcting the problems, you can resume the build with the command
Error: mvn <args> -rf :apollo-configservice
Error: Process completed with exit code 1.
| private static final Logger logger = LoggerFactory.getLogger(NotificationControllerV2.class); | ||
| private final Multimap<String, DeferredResultWrapper> deferredResults = | ||
| Multimaps.synchronizedSetMultimap(TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural())); | ||
| private final CaseInsensitiveConcurrentMultimap<String, DeferredResultWrapper> deferredResults = new CaseInsensitiveConcurrentMultimap<>(); |
There was a problem hiding this comment.
| private final CaseInsensitiveConcurrentMultimap<String, DeferredResultWrapper> deferredResults = new CaseInsensitiveConcurrentMultimap<>(); | |
| private final Multimap<String, DeferredResultWrapper> deferredResults = | |
| new CaseInsensitiveConcurrentMultimap<>(); |
| private Gson gson; | ||
|
|
||
| private Multimap<String, DeferredResultWrapper> deferredResults; | ||
| private ConcurrentMultimap<String, DeferredResultWrapper> deferredResults; |
There was a problem hiding this comment.
| private ConcurrentMultimap<String, DeferredResultWrapper> deferredResults; | |
| private Multimap<String, DeferredResultWrapper> deferredResults; |
|
|
||
| deferredResults = | ||
| (Multimap<String, DeferredResultWrapper>) ReflectionTestUtils.getField(controller, "deferredResults"); | ||
| (ConcurrentMultimap<String, DeferredResultWrapper>) ReflectionTestUtils.getField(controller, "deferredResults"); |
There was a problem hiding this comment.
| (ConcurrentMultimap<String, DeferredResultWrapper>) ReflectionTestUtils.getField(controller, "deferredResults"); | |
| (Multimap<String, DeferredResultWrapper>) ReflectionTestUtils.getField(controller, "deferredResults"); |
|
@copilot Please see the review comments above. |
…tion errors Co-authored-by: nobodyiam <[email protected]>
... I've addressed all the requested changes:
All compilation issues should now be resolved while maintaining the API compatibility benefits of using the interface type. Commit: a3976db Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: nobodyiam <[email protected]>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Comment |
|
@copilot There appears to be a concurrency issue in CaseInsensitiveConcurrentMultimap:
As a result, the value added by Thread B is lost. |
…ic compute operations Co-authored-by: nobodyiam <[email protected]>
Fixed the race condition by replacing The fix ensures:
Added a specific test ( Commit: 6985cb5 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
The full implementation of Multimap is not necessary and is thus complicated, use #5532 instead |
put()method to usecompute()for atomic operationsremove()method to usecomputeIfPresent()for atomic operations💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.