Skip to content

Fix potential NPE while executing query#17749

Merged
JackieTien97 merged 1 commit into
masterfrom
fixPotentialNPE
May 23, 2026
Merged

Fix potential NPE while executing query#17749
JackieTien97 merged 1 commit into
masterfrom
fixPotentialNPE

Conversation

@JackieTien97
Copy link
Copy Markdown
Contributor

This pull request enhances error handling and internationalization for schema fetching and data region operations in the IoTDB DataNode module. The main improvements are the addition of more descriptive and localized error messages, better exception handling for missing query executions and timeouts, and clearer logging for data region issues.

Error handling and messaging improvements:

  • Added new error messages for query timeouts and missing query executions during schema fetching, with support for both English and Chinese localizations in DataNodeQueryMessages (en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java, zh/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java) [1] [2].
  • Improved error messages for missing or null data regions in StorageEngineMessages, also localized in both English and Chinese (en/org/apache/iotdb/db/i18n/StorageEngineMessages.java, zh/org/apache/iotdb/db/i18n/StorageEngineMessages.java) [1] [2].

Exception handling and logging enhancements:

  • Updated TableDeviceSchemaFetcher and ClusterSchemaFetchExecutor to throw IoTDBRuntimeException with localized messages when query executions are missing, and to throw a specific QueryTimeoutException when a schema fetch times out (TableDeviceSchemaFetcher.java, ClusterSchemaFetchExecutor.java) [1] [2] [3] [4] [5] [6].
  • Refactored QueryTimeoutRuntimeException to extend IoTDBRuntimeException and include a status code, improving consistency in exception handling (QueryTimeoutRuntimeException.java).

Codebase robustness and maintainability:

  • Added null checks and error logging for data region retrieval in DataRegionConsensusImpl and DataRegionStateMachine, ensuring that missing or null regions are handled gracefully and with clear error messages (DataRegionConsensusImpl.java, DataRegionStateMachine.java) [1] [2].
  • Introduced new logger instances where needed and improved imports for better code clarity and maintainability (DataRegionConsensusImpl.java, TableDeviceSchemaFetcher.java) [1] [2] [3] [4] [5] [6].

These changes make error reporting more informative for both users and developers, improve localization support, and ensure that exceptional cases in schema fetching and data region operations are handled in a robust and maintainable way.

@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 3.70370% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.59%. Comparing base (7563ac8) to head (a7fd577).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...nal/metadata/fetcher/TableDeviceSchemaFetcher.java 1.49% 66 Missing ⚠️
...he/iotdb/db/consensus/DataRegionConsensusImpl.java 20.00% 4 Missing ⚠️
...lan/analyze/schema/ClusterSchemaFetchExecutor.java 0.00% 4 Missing ⚠️
...tatemachine/dataregion/DataRegionStateMachine.java 33.33% 2 Missing ⚠️
.../exception/query/QueryTimeoutRuntimeException.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17749      +/-   ##
============================================
+ Coverage     40.55%   40.59%   +0.04%     
  Complexity     2574     2574              
============================================
  Files          5179     5179              
  Lines        349896   350007     +111     
  Branches      44727    44757      +30     
============================================
+ Hits         141890   142087     +197     
+ Misses       208006   207920      -86     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JackieTien97 JackieTien97 merged commit 669acad into master May 23, 2026
43 of 44 checks passed
@JackieTien97 JackieTien97 deleted the fixPotentialNPE branch May 23, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant