openzipkin/zipkin · error · NullPointerException

value == null

Error message

value == null

What it means

Annotation.create throws NullPointerException when value is null. An Annotation is a (timestamp, value) pair where value names the event (e.g. 'sr', 'cache.miss'); a null value has no meaning, so creation is rejected eagerly instead of failing later during encoding or comparison.

Solutions

  1. Skip annotations whose value is null instead of creating them.
  2. Default or validate the value upstream: requireNonNull(value, 'annotation value required').
  3. If parsing external data, treat a missing value as a data error and log/drop the record.

Example fix

// before
Annotation a = Annotation.create(ts, map.get("event")); // null when key absent

// after
String value = map.get("event");
if (value != null) annotations.add(Annotation.create(ts, value));
Defensive patterns

Strategy: validation

Validate before calling

String value = rawValue;
if (value != null) annotations.add(Annotation.create(timestamp, value));

Prevention

When it happens

Trigger: Calling Annotation.create(timestamp, null), often with a value pulled from a map or parsed from input that was absent.

Common situations: Converting wire/JSON data where the annotation value field is missing; instrumentation code building annotations from dynamic key/value pairs where the value expression evaluates to null.

Related errors


AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14). Data as JSON: /api/errors/fa974a6b548d2ac7. Report an issue: GitHub.

Appendix: source

Thrown at zipkin/src/main/java/zipkin2/Annotation.java:21

 * SPDX-License-Identifier: Apache-2.0
 */
package zipkin2;

import java.io.ObjectStreamException;
import java.io.Serializable;
import java.io.StreamCorruptedException;

/**
 * Associates an event that explains latency with a timestamp.
 *
 * <p>Unlike log statements, annotations are often codes: Ex. {@code cache.miss}.
 */
//@Immutable
public final class Annotation implements Comparable<Annotation>, Serializable { // for Spark jobs
  private static final long serialVersionUID = 0L;

  public static Annotation create(long timestamp, String value) {
    if (value == null) throw new NullPointerException("value == null");
    return new Annotation(timestamp, value);
  }

  /**
   * Microseconds from epoch.
   *
   * <p>This value should be set directly by instrumentation, using the most precise value possible.
   * For example, {@code gettimeofday} or multiplying {@link System#currentTimeMillis} by 1000.
   */
  public long timestamp() {
    return timestamp;
  }

  /**
   * Usually a short tag indicating an event, like {@code cache.miss} or {@code error}
   */
  public String value() {
    return value;

View on GitHub (pinned to 878ce2a1fa)