{"record":{"id":"fa974a6b548d2ac7","repo":"openzipkin/zipkin","slug":"value-null","errorCode":null,"errorMessage":"value == null","messagePattern":"value == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin/src/main/java/zipkin2/Annotation.java","lineNumber":21,"sourceCode":" * SPDX-License-Identifier: Apache-2.0\n */\npackage zipkin2;\n\nimport java.io.ObjectStreamException;\nimport java.io.Serializable;\nimport java.io.StreamCorruptedException;\n\n/**\n * Associates an event that explains latency with a timestamp.\n *\n * <p>Unlike log statements, annotations are often codes: Ex. {@code cache.miss}.\n */\n//@Immutable\npublic final class Annotation implements Comparable<Annotation>, Serializable { // for Spark jobs\n  private static final long serialVersionUID = 0L;\n\n  public static Annotation create(long timestamp, String value) {\n    if (value == null) throw new NullPointerException(\"value == null\");\n    return new Annotation(timestamp, value);\n  }\n\n  /**\n   * Microseconds from epoch.\n   *\n   * <p>This value should be set directly by instrumentation, using the most precise value possible.\n   * For example, {@code gettimeofday} or multiplying {@link System#currentTimeMillis} by 1000.\n   */\n  public long timestamp() {\n    return timestamp;\n  }\n\n  /**\n   * Usually a short tag indicating an event, like {@code cache.miss} or {@code error}\n   */\n  public String value() {\n    return value;","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin/src/main/java/zipkin2/Annotation.java#L3-L39","documentation":"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.","triggerScenarios":"Calling Annotation.create(timestamp, null), often with a value pulled from a map or parsed from input that was absent.","commonSituations":"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.","solutions":["Skip annotations whose value is null instead of creating them.","Default or validate the value upstream: requireNonNull(value, 'annotation value required').","If parsing external data, treat a missing value as a data error and log/drop the record."],"exampleFix":"// before\nAnnotation a = Annotation.create(ts, map.get(\"event\")); // null when key absent\n\n// after\nString value = map.get(\"event\");\nif (value != null) annotations.add(Annotation.create(ts, value));","handlingStrategy":"validation","validationCode":"String value = rawValue;\nif (value != null) annotations.add(Annotation.create(timestamp, value));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat null annotation values as data to drop, not to store","Validate external span data at ingestion boundaries"],"tags":["core","annotation","null-pointer","validation","fail-fast"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}