{"record":{"id":"18733aa07a8b0cf4","repo":"openzipkin/zipkin","slug":"transporttype-null","errorCode":null,"errorMessage":"transportType == null","messagePattern":"transportType == null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-collector/core/src/main/java/zipkin2/collector/InMemoryCollectorMetrics.java","lineNumber":34,"sourceCode":"  private final String spans;\n  private final String spansDropped;\n\n  public InMemoryCollectorMetrics() {\n    this(new ConcurrentHashMap<>(), null);\n  }\n\n  InMemoryCollectorMetrics(ConcurrentHashMap<String, AtomicInteger> metrics, String transport) {\n    this.metrics = metrics;\n    this.messages = scope(\"messages\", transport);\n    this.messagesDropped = scope(\"messagesDropped\", transport);\n    this.bytes = scope(\"bytes\", transport);\n    this.spans = scope(\"spans\", transport);\n    this.spansDropped = scope(\"spansDropped\", transport);\n  }\n\n  @Override\n  public InMemoryCollectorMetrics forTransport(String transportType) {\n    if (transportType == null) throw new NullPointerException(\"transportType == null\");\n    return new InMemoryCollectorMetrics(metrics, transportType);\n  }\n\n  @Override\n  public void incrementMessages() {\n    increment(messages, 1);\n  }\n\n  public int messages() {\n    return get(messages);\n  }\n\n  @Override\n  public void incrementMessagesDropped() {\n    increment(messagesDropped, 1);\n  }\n\n  public int messagesDropped() {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-collector/core/src/main/java/zipkin2/collector/InMemoryCollectorMetrics.java#L16-L52","documentation":"InMemoryCollectorMetrics.forTransport scopes an existing metrics registry to a named transport (e.g. 'http', 'kafka', 'activemq'); the transport name keys the per-transport counters, so null would corrupt the metric map and is rejected. This is the metrics implementation backing zipkin-server's metrics endpoint.","triggerScenarios":"Calling inMemoryCollectorMetrics.forTransport(null) — e.g. a collector wrapper deriving the transport label from config that resolved to null, then delegating to forTransport like ActiveMQCollector/KafkaCollector builders do internally with a hard-coded name.","commonSituations":"Custom CollectorComponent implementations copying the built-in builders but deriving the transport string dynamically; config-driven transport label missing.","solutions":["Pass a fixed, non-null transport label string (\"http\", \"kafka\", \"activemq\", ...).","Default the label if it comes from config: transport != null ? transport : \"unknown\".","Reuse the built-in collectors (ActiveMQCollector/KafkaCollector) which scope metrics for you."],"exampleFix":"// before\nString t = props.getProperty(\"transport\"); // null\nmetrics.forTransport(t); // NPE\n\n// after\nmetrics.forTransport(t != null ? t : \"unknown\");","handlingStrategy":"validation","validationCode":"java\nString label = (transportType != null) ? transportType : \"unknown\";\nreturn metrics.forTransport(label);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use hard-coded transport labels matching built-in collectors.","Default config-derived labels to a constant."],"tags":["zipkin","java","metrics","collector","configuration"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}