{"record":{"id":"93bb93e7511d0c5e","repo":"pinpoint-apm/pinpoint","slug":"value","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/annotation/ObjectAnnotation.java","lineNumber":32,"sourceCode":" * limitations under the License.\n */\n\npackage com.navercorp.pinpoint.profiler.context.annotation;\n\nimport com.navercorp.pinpoint.common.util.StringUtils;\nimport com.navercorp.pinpoint.profiler.context.Annotation;\n\n/**\n * @author emeroad\n */\npublic class ObjectAnnotation implements Annotation<Object> {\n\n    private final int key;\n    private final String value;\n\n    ObjectAnnotation(int key, Object value) {\n        if (value == null) {\n            throw new NullPointerException(\"value\");\n        }\n        this.key = key;\n        // Not recommended Lazy evaluation for Thread safety\n        this.value = StringUtils.abbreviate(value.toString());\n    }\n\n    @Override\n    public int getKey() {\n        return key;\n    }\n\n    @Override\n    public Object getValue() {\n        return value;\n    }\n\n    @Override\n    public String toString() {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/annotation/ObjectAnnotation.java#L14-L50","documentation":"ObjectAnnotation wraps an annotation key/value pair attached to spans. The package-private constructor rejects a null value with a NullPointerException(\"value\") to guarantee that every annotation carries a non-null, abbreviated string value. The value is eagerly converted via value.toString() and truncated (StringUtils.abbreviate) for thread-safety, so a null has no meaningful representation.","triggerScenarios":"Calling the ObjectAnnotation factory/constructor with a null value — e.g. TraceValue/Annotations.of(key, null), or plugin code recording an annotation whose computed value (a method argument/return value) is null.","commonSituations":"Plugins annotating method parameters or return values that are legitimately null; configuration recording request attributes that are absent; dynamic values resolved lazily and coming back null at annotation time.","solutions":["Substitute a placeholder string for null before creating the annotation, e.g. Annotations.of(key, String.valueOf(value)) or \"null\".","Skip the annotation entirely when the value is null (check before calling the factory).","Add a null check/log in plugin code where the annotated value is produced to find why it is null.","Wrap annotation creation in a small helper that normalizes nulls so all plugins behave consistently."],"exampleFix":"// before\ntrace.recordAttribute(Annotations.of(100, possiblyNull)); // NPE\n// after\nif (possiblyNull != null) {\n    trace.recordAttribute(Annotations.of(100, possiblyNull));\n} else {\n    trace.recordAttribute(Annotations.of(100, \"null\"));\n}","handlingStrategy":"validation","validationCode":"if (value != null) {\n    trace.recordAttribute(Annotations.of(key, value));\n}","typeGuard":"boolean isAnnotatable(Object value) {\n    return value != null;\n}","tryCatchPattern":"try {\n    trace.recordAttribute(Annotations.of(key, value));\n} catch (NullPointerException e) {\n    logger.debug(\"Skipping annotation {} with null value\", key);\n}","preventionTips":["Normalize null annotation values to \"null\" or skip recording","Null-check method args/returns before annotating them in plugins","Centralize annotation creation in one helper that guards nulls","Remember toString() is called eagerly — only pass concrete values","Write plugin tests covering null argument/return instrumentation"],"tags":["java","pinpoint","annotations","null-pointer","validation"],"backgroundTag":"null-argument","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}