Tencent/matrix · error · RuntimeException
publish issue, but issue listener is null
Error message
publish issue, but issue listener is null
What it means
IssuePublisher.publishIssue() throws when mIssueListener is null. Subclasses (e.g. individual detectors) call publishIssue to hand detected issues to a registered IssueListener; without a listener there is nowhere to deliver the issue, so Matrix fails fast.
Solutions
- Call setIssueListener() on the publisher before any detection runs
- Ensure the plugin's PluginListener.onStart wires the issue listener before detectors start working
- Guard publishIssue call sites with a null listener check
- Verify plugin initialization order so the listener is attached before detection begins
Example fix
// before
public class MyDetector extends IssuePublisher {
void onFound(Issue issue) { publishIssue(issue); }
}
// after
public class MyDetector extends IssuePublisher {
MyDetector() { setIssueListener(listener); }
void onFound(Issue issue) { publishIssue(issue); }
} Defensive patterns
Strategy: validation
Validate before calling
if (getIssueListener() == null) {
setIssueListener(defaultListener);
}
publishIssue(issue); Type guard
if (this.mIssueListener != null) { publishIssue(issue); } Try / catch
try {
publishIssue(issue);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("issue listener is null")) {
Log.w(TAG, "issue dropped: no listener registered");
} else { throw e; }
} Prevention
- Register the IssueListener in the detector's constructor or onStart
- Never start detection before the listener is attached
- Provide a default no-op listener in custom IssuePublisher subclasses
When it happens
Trigger: A detector subclass calls publishIssue(issue) before its listener was registered, or the listener was never set on the IssuePublisher subclass at all.
Common situations: Custom detectors extending IssuePublisher without calling setIssueListener; configuring a detector (e.g. SQLiteLint, IOCanary) without its reporter callback; publishing issues before plugin init completes.
Related errors
- plugin stop, plugin listener is null
- plugin destroy, plugin listener is null
- plugin destroy, but plugin has been already destroyed
- [-] Either or should be applied when use this script.
- Matrix init, Matrix should not be null.
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/2b8958c1d62e18aa.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-android-lib/src/main/java/com/tencent/matrix/report/IssuePublisher.java:45
*/
public class IssuePublisher {
private final OnIssueDetectListener mIssueListener;
private final HashSet<String> mPublishedMap;
public interface OnIssueDetectListener {
void onDetectIssue(Issue issue);
}
public IssuePublisher(OnIssueDetectListener issueDetectListener) {
mPublishedMap = new HashSet<>();
this.mIssueListener = issueDetectListener;
}
protected void publishIssue(Issue issue) {
if (mIssueListener == null) {
throw new RuntimeException("publish issue, but issue listener is null");
}
if (issue != null) {
mIssueListener.onDetectIssue(issue);
}
}
protected boolean isPublished(String key) {
if (key == null) {
return false;
}
return mPublishedMap.contains(key);
}
protected void markPublished(String key) {
if (key == null) {
return;
}View on GitHub (pinned to 3b8293bd65)