[ISSUE #10978] Add Nullable annotations to nullable Message getters and stop kotlin-stdlib transitive leak - #11155
Conversation
…ters and stop kotlin-stdlib transitive leak Two independent fixes: 1. Annotate the seven Message getters that return null under normal conditions (getTags/getKeys/getProperty/getUserProperty/getBuyerId/ getProperties/getTransactionId) with javax.annotation.Nullable so Java IDEs and Kotlin callers can detect the nullability. 2. Exclude com.squareup.okhttp3:okhttp from the opentelemetry-exporter-otlp dependency so the unused HTTP sender no longer pulls kotlin-stdlib into pure-Java consumers. RocketMQ uses the gRPC exporter, so the HTTP transport is not needed. Closes apache#10978 Signed-off-by: jokerzsd <2701819133@qq.com>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Two clean, well-scoped fixes for #10978 — @Nullable annotations on seven Message getters and an okhttp transitive exclusion to stop kotlin-stdlib leaking into pure-Java consumers.
Findings
- [Info]
common/src/main/java/.../Message.java— The@Nullableannotations correctly document the existing null-returning contract ofgetTags(),getKeys(),getProperty(),getUserProperty(),getBuyerId(),getProperties(), andgetTransactionId(). Good improvement for Kotlin interop and static analysis. - [Info]
common/pom.xml— The okhttp exclusion onopentelemetry-exporter-otlpis correct since RocketMQ uses the gRPC exporter. Verifiedjakarta.annotation-api:1.3.5in the parent POM providesjavax.annotation.Nullable, so the import resolves without adding a new dependency. - [Info] No behavioral change — purely metadata additions and dependency cleanup. No new tests needed.
Verdict
LGTM. Clean, minimal, and well-documented.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR makes two independent improvements from issue #10978: adding @Nullable annotations to Message getters and excluding an unused transitive dependency. Both changes are clean, well-scoped, and address real pain points.
Findings
- [Info] Message.java:102 —
@Nullableannotations correctly applied, improves Kotlin interop - [Info] common/pom.xml:70 — okhttp exclusion prevents kotlin-stdlib leak, mirrors existing pattern
Strengths
✅ Annotations are pure metadata, no behavioral risk
✅ Dependency exclusion is surgical and well-justified
✅ PR description clearly explains both changes and their rationale
✅ Verification steps included (compile + dependency tree check)
Verification
The PR description shows:
mvn compilepasses with checkstyle + spotbugsdependency:treeconfirms no kotlin artifacts remain
This is a low-risk, high-value change for Kotlin consumers and dependency hygiene.
| this.putProperty(name, value); | ||
| } | ||
|
|
||
| @Nullable |
There was a problem hiding this comment.
[Info] The @Nullable annotations are correctly applied to all seven getters that can legitimately return null. This improves IDE support and Kotlin interop without changing runtime behavior.
One minor note: javax.annotation.Nullable is from JSR-305 (legacy). Modern Java projects sometimes prefer org.jetbrains.annotations.Nullable or @org.checkerframework.checker.nullness.qual.Nullable, but javax.annotation.Nullable is widely recognized and works well with Kotlin's null-safety. No action needed.
| <dependency> | ||
| <groupId>io.opentelemetry</groupId> | ||
| <artifactId>opentelemetry-exporter-otlp</artifactId> | ||
| <exclusions> |
There was a problem hiding this comment.
[Info] The okhttp exclusion is well-targeted. Since RocketMQ uses the gRPC exporter (opentelemetry-exporter-otlp with gRPC transport), the HTTP sender (okhttp) is unused and was pulling kotlin-stdlib transitively into pure-Java consumers.
This mirrors the existing okio-jvm exclusion pattern in the root pom and keeps the dependency tree clean for Java-only deployments.
What is the purpose of the change
Two independent fixes from issue #10978:
Nullable getters: annotate the seven
Messagegetters that return null under normal conditions —getTags(),getKeys(),getProperty(),getUserProperty(),getBuyerId(),getProperties(),getTransactionId()— withjavax.annotation.Nullable. Pure metadata, no behavioral change; lets Java IDEs and Kotlin callers detect the nullability.kotlin-stdlib transitive leak: exclude
com.squareup.okhttp3:okhttpfrom theopentelemetry-exporter-otlpdependency incommon/pom.xml. The unused HTTP sender (RocketMQ uses the gRPC exporter) pulledkotlin-stdlibinto every pure-Java consumer. This mirrors the kotlin exclusions already applied to theokio-jvmedge in the root pom.Brief changelog
common/src/main/java/org/apache/rocketmq/common/message/Message.java: add@Nullableto seven getters.common/pom.xml: add okhttp exclusion toopentelemetry-exporter-otlp.Verifying this change
mvn -f common/pom.xml compile— BUILD SUCCESS (checkstyle + spotbugs pass).mvn -f common/pom.xml dependency:tree -Dincludes=org.jetbrains.kotlin— no kotlin artifacts remain in the tree.Closes #10978