fix: guard several edge cases that crash at runtime - #711
Open
yyqdbngt wants to merge 1 commit into
Open
Conversation
- TopicServiceImpl: sending a message to a topic without any broker route
threw IndexOutOfBoundsException on topicConfigInfos.get(0); throw a
ServiceException with a clear message instead
- DashboardCollectTask: kvTable.get("getTotalTps") could be null or blank,
causing NPE or a divide-by-zero on the empty split result; skip the
broker in that case
- DashboardCollectServiceImpl: an empty/corrupt dashboard data file makes
JSONObject.parse return null and json.entrySet() NPE; return an empty
map instead
- FileUserStrategy: a non-numeric role in users.properties threw
NumberFormatException outside any try/catch and aborted startup; treat
it as a normal user (role 0) and log a warning
yyqdbngt
force-pushed
the
fix/edge-case-defensive-checks
branch
from
July 31, 2026 15:34
a360b58 to
5dbf47b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Four defensive fixes for runtime crashes found by code review:
TopicServiceImpl.sendTopicMessageRequest — when a topic has no broker route,
topicConfigInfos.get(0)threwIndexOutOfBoundsException. Now a clearServiceExceptionis thrown instead.DashboardCollectTask.collectBroker —
kvTable.getTable().get("getTotalTps")could benullor blank, causing aNullPointerExceptionor a divide-by-zero when the blank value splits into an empty array. The broker is now skipped when there is no TPS data.DashboardCollectServiceImpl.jsonDataFile2map — an empty or corrupt dashboard data file makes
JSONObject.parsereturnnull, sojson.entrySet()threwNullPointerException. An empty map is returned instead.FileUserStrategy.FileBasedUserInfoStore.load — a non-numeric role in
users.propertiesthrewNumberFormatExceptionoutside of anytry/catch, aborting application startup. It is now treated as a normal user (role 0) with a warning logged.Verification
mvn compiler:compilepasses (BUILD SUCCESS).Diff
4 files changed, +21 / -3.