openzipkin/zipkin · error · NullPointerException
serviceNameSuffix == null
Error message
serviceNameSuffix == null
What it means
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.
Source
Thrown at zipkin-tests/src/main/java/zipkin2/TestObjects.java:116
}
public static Span newClientSpan(String serviceNameSuffix) {
return spanBuilder(serviceNameSuffix).kind(CLIENT)
.remoteEndpoint(BACKEND.toBuilder().serviceName("backend" + serviceNameSuffix).build())
.name("get /foo")
.clearTags()
.putTag("http.method", "GET")
.putTag("http.path", "/foo")
.build();
}
public static Span.Builder spanBuilder(String serviceNameSuffix) {
Endpoint frontend = suffixServiceName(FRONTEND, serviceNameSuffix);
return SPAN_BUILDER.clone().localEndpoint(frontend).traceId(newTraceId());
}
public static String appendSuffix(String serviceName, String serviceNameSuffix) {
if (serviceNameSuffix == null) throw new NullPointerException("serviceNameSuffix == null");
if (serviceNameSuffix.isEmpty()) return serviceName;
return serviceName + "_" + serviceNameSuffix;
}
public static Endpoint suffixServiceName(Endpoint endpoint, String serviceNameSuffix) {
String prefixed = appendSuffix(endpoint.serviceName(), serviceNameSuffix);
if (endpoint.serviceName().equals(prefixed)) return endpoint;
return endpoint.toBuilder().serviceName(prefixed).build();
}
public static List<Span> newTrace(String serviceNameSuffix) {
return newTrace(newTraceId(), serviceNameSuffix);
}
static List<Span> newTrace(String traceId, String serviceNameSuffix) {
Endpoint frontend = suffixServiceName(FRONTEND, serviceNameSuffix);
Endpoint backend = suffixServiceName(BACKEND, serviceNameSuffix);
Endpoint db = suffixServiceName(DB, serviceNameSuffix);View on GitHub (pinned to 878ce2a1fa)
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.
Example fix
// before
Span.Builder b = TestObjects.spanBuilder(null);
// after
Span.Builder b = TestObjects.spanBuilder(""); Defensive patterns
Strategy: validation
Validate before calling
String suffix = (requestedSuffix == null) ? "" : requestedSuffix; Span.Builder b = TestObjects.spanBuilder(suffix);
Prevention
- Use "" for the no-suffix case in tests; reserve null for bugs
- Generate per-class suffixes for parallel test isolation
When it happens
Trigger: Calling TestObjects.spanBuilder(null), TestObjects.newTrace(null), or TestObjects.appendSuffix(name, null) directly in a test.
Common situations: 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.
Related errors
- keys == null
- datasource == null
- settings == null
- executor == null
- Could not connect to storage, skipping test: {}
AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14).
Data as JSON: /api/errors/54c30b6379505e50.
Report an issue: GitHub.