-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Fix: Prevent NullPointerException in getActiveEnvs by checking contai… #5417
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
base: master
Are you sure you want to change the base?
Fix: Prevent NullPointerException in getActiveEnvs by checking contai… #5417
Conversation
WalkthroughThe Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build (8)
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java
Outdated
Show resolved
Hide resolved
How about replacing all the occurrences of |
81fffda
to
77491f9
Compare
Thank you for the suggestion! I have updated the code to use the |
Please replace ALL instances of |
I have read the CLA Document and I hereby sign the CLA |
77491f9
to
7673f8e
Compare
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build (8)
🔇 Additional comments (3)
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java (3)
93-93
: Good improvement using the helper method.This change correctly replaces the direct map lookup with the
isEnvActive()
helper method, following the suggestion from previous reviews to maintain consistency.
128-128
: Consistent use of helper method, but depends on fixing the recursion bug.This change correctly uses the
isEnvActive()
helper method instead of direct map access, which improves consistency. However, this will fail due to the infinite recursion bug in theisEnvActive()
method (line 102).
158-158
: Consistent use of helper method, but depends on fixing the recursion bug.This change correctly uses the
isEnvActive()
helper method instead of direct map access, which improves consistency. However, this will fail due to the infinite recursion bug in theisEnvActive()
method (line 102).
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PortalSettings.java
Outdated
Show resolved
Hide resolved
Thank you for the suggestion! I understand that all occurrences of envStatusMark.get(env) should be replaced with isEnvActive(env). |
7673f8e
to
68a686c
Compare
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 14 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Hi,
Fixes a potential 'NullPointerException' in the 'getActiveEnvs()' method by ensuring that 'envStatusMark.get(env)' is only called after confirming that the key exists using 'containsKey()'.
Expected Behavior
When iterating through 'allEnvs', only environments with a 'true' value in 'envStatusMark' should be added to 'activeEnvs', and no 'NullPointerException' should occur regardless of the contents of 'envStatusMark'.
Actual Behavior
Previously, if 'envStatusMark.get(env)' returned null, a 'NullPointerException' could occur during the evaluation of the 'if' condition.
This Patch
This patch prevents a subtle 'NullPointerException' with minimal changes while preserving the original logic. It improves the method's stability and ensures that only valid and
true
entries are added to 'activeEnvs'.Thanks for reviewing.
Summary by CodeRabbit