{"record":{"id":"54c30b6379505e50","repo":"openzipkin/zipkin","slug":"servicenamesuffix-null","errorCode":null,"errorMessage":"serviceNameSuffix == null","messagePattern":"serviceNameSuffix == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-tests/src/main/java/zipkin2/TestObjects.java","lineNumber":116,"sourceCode":"  }\n\n  public static Span newClientSpan(String serviceNameSuffix) {\n    return spanBuilder(serviceNameSuffix).kind(CLIENT)\n      .remoteEndpoint(BACKEND.toBuilder().serviceName(\"backend\" + serviceNameSuffix).build())\n      .name(\"get /foo\")\n      .clearTags()\n      .putTag(\"http.method\", \"GET\")\n      .putTag(\"http.path\", \"/foo\")\n      .build();\n  }\n\n  public static Span.Builder spanBuilder(String serviceNameSuffix) {\n    Endpoint frontend = suffixServiceName(FRONTEND, serviceNameSuffix);\n    return SPAN_BUILDER.clone().localEndpoint(frontend).traceId(newTraceId());\n  }\n\n  public static String appendSuffix(String serviceName, String serviceNameSuffix) {\n    if (serviceNameSuffix == null) throw new NullPointerException(\"serviceNameSuffix == null\");\n    if (serviceNameSuffix.isEmpty()) return serviceName;\n    return serviceName + \"_\" + serviceNameSuffix;\n  }\n\n  public static Endpoint suffixServiceName(Endpoint endpoint, String serviceNameSuffix) {\n    String prefixed = appendSuffix(endpoint.serviceName(), serviceNameSuffix);\n    if (endpoint.serviceName().equals(prefixed)) return endpoint;\n    return endpoint.toBuilder().serviceName(prefixed).build();\n  }\n\n  public static List<Span> newTrace(String serviceNameSuffix) {\n    return newTrace(newTraceId(), serviceNameSuffix);\n  }\n\n  static List<Span> newTrace(String traceId, String serviceNameSuffix) {\n    Endpoint frontend = suffixServiceName(FRONTEND, serviceNameSuffix);\n    Endpoint backend = suffixServiceName(BACKEND, serviceNameSuffix);\n    Endpoint db = suffixServiceName(DB, serviceNameSuffix);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-tests/src/main/java/zipkin2/TestObjects.java#L98-L134","documentation":"TestObjects.appendSuffix throws NullPointerException when serviceNameSuffix is null. This is a test-support helper in zipkin-tests used to namespace service names so parallel integration test runs do not collide. It requires an explicit (possibly empty) suffix rather than null so intentions stay clear in test code.","triggerScenarios":"Calling TestObjects.spanBuilder(null), TestObjects.newTrace(null), or TestObjects.appendSuffix(name, null) directly in a test.","commonSituations":"Writing custom storage integration tests that copy TestObjects usage but pass a nullable suffix variable; refactoring tests so a suffix field becomes null in some branches.","solutions":["Pass \"\" when no suffix is needed: TestObjects.spanBuilder(\"\").","Default the variable before use: suffix = suffix == null ? \"\" : suffix.","When tests run in parallel against one storage, pass a unique suffix per test class instead of null."],"exampleFix":"// before\nSpan.Builder b = TestObjects.spanBuilder(null);\n\n// after\nSpan.Builder b = TestObjects.spanBuilder(\"\");","handlingStrategy":"validation","validationCode":"String suffix = (requestedSuffix == null) ? \"\" : requestedSuffix;\nSpan.Builder b = TestObjects.spanBuilder(suffix);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use \"\" for the no-suffix case in tests; reserve null for bugs","Generate per-class suffixes for parallel test isolation"],"tags":["testing","test-helpers","null-pointer","zipkin-tests"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}