Skip to content

<fix>[thread]: guard Context.current() with telemetry check to prevent MN startup crash#3364

Closed
zstack-robot-2 wants to merge 1 commit into5.5.6from
sync/yaohua.wu/ZSTAC-82274
Closed

<fix>[thread]: guard Context.current() with telemetry check to prevent MN startup crash#3364
zstack-robot-2 wants to merge 1 commit into5.5.6from
sync/yaohua.wu/ZSTAC-82274

Conversation

@zstack-robot-2
Copy link
Collaborator

Resolves ZSTAC-82274. DispatchQueueImpl.SyncTaskFuture calls Context.current() unconditionally in constructor, triggering ServiceLoader for ContextStorageProvider even when telemetry is disabled. This causes ServiceConfigurationError when sentry-opentelemetry-bootstrap jar has ClassLoader conflicts in Tomcat.

sync from gitlab !9199

SyncTaskFuture constructor calls Context.current() unconditionally,
which triggers ServiceLoader for ContextStorageProvider even when
telemetry is disabled. If sentry-opentelemetry-bootstrap jar is on
classpath, ServiceLoader fails with "not a subtype" due to
ClassLoader isolation in Tomcat, throwing ServiceConfigurationError
(extends Error) that escapes all catch(Exception) blocks and crashes
MN startup.

Fix: only call Context.current() when telemetry is enabled, matching
the existing pattern used in other DispatchQueueImpl code paths.

Change-Id: I8ae1f790c8591ae7acebd011319878eb824d2fb0
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉


概览

在 SyncTaskFuture 构造器中修改了 parentContext 的赋值逻辑,使其根据遥测启用状态进行条件判断:遥测启用时设为 Context.current(),否则设为 null。

变更

队列 / 文件 概述
条件逻辑优化
core/src/main/java/org/zstack/core/thread/DispatchQueueImpl.java
修改 SyncTaskFuture 构造器中 parentContext 的赋值,从无条件赋值改为根据遥测启用状态的条件赋值。

预估代码审查工作量

🎯 1 (微小) | ⏱️ ~3 分钟

一只兔子来报信,
telemetry 状态要区分,
Context 现在更聪慧,
有无遥测各不同,
代码简洁又高效 🐰✨


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Title check ❌ Error PR title exceeds 72 character limit (87 chars) and does not meet the required format constraint, though it follows the type[scope]: description pattern. 缩短标题至72个字符以内。建议:'[thread]: Guard Context.current() with telemetry check' (59 characters)。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly relates to the changeset, explaining the issue with Context.current() being called unconditionally and the telemetry-dependent fix.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into 5.5.6
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/yaohua.wu/ZSTAC-82274

Comment @coderabbitai help to get the list of available commands and usage tips.

@ZStack-Robot ZStack-Robot deleted the sync/yaohua.wu/ZSTAC-82274 branch February 16, 2026 13:21
@MatheMatrix MatheMatrix restored the sync/yaohua.wu/ZSTAC-82274 branch February 16, 2026 13:30
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.

3 participants