pinpoint-apm/pinpoint · error · NullPointerException

${fieldName}

Error message

${fieldName}

What it means

UidPrefix.requireNameLength throws a NullPointerException whose message is the field name when the given name is null. It is a guard ensuring the name component of a UID prefix key is present before it is embedded into HBase row keys.

Solutions

  1. Ensure the name (applicationName/serviceName) is non-null before constructing the row key
  2. Check config/DTO population: a missing or empty config field often yields null here
  3. Catch NullPointerException at the boundary and report the field name given in the message
  4. Prefer explicitly validating inputs and throwing a descriptive exception before calling the key builder

Example fix

// before
UidLinkRowKey key = new UidLinkRowKey(serviceUid, prefix.requireNameLength(appName, "applicationName"), ...);
// after
Objects.requireNonNull(appName, "applicationName must not be null");
UidLinkRowKey key = new UidLinkRowKey(serviceUid, prefix.requireNameLength(appName, "applicationName"), ...);
Defensive patterns

Strategy: validation

Validate before calling

String requireNonNullName(String name, String field) {
    if (name == null) throw new IllegalArgumentException(field + " must not be null");
    return name;
}

Type guard

String requireNonNullName(String name, String field) {
    if (name == null) throw new IllegalArgumentException(field + " must not be null");
    return name;
}

Try / catch

try {
    String validated = UidPrefix.requireNameLength(name, "applicationName");
} catch (NullPointerException e) {
    log.error("missing {} for UID key construction", e.getMessage());
    // fail the request with a clear client-side validation message
}

Prevention

When it happens

Trigger: Calling requireNameLength(name, fieldName) (or any UidPrefix API that delegates to it) with name == null, e.g. building a UidLink row key from an applicationName/serviceName that is null.

Common situations: Config or request missing the application/service name; a null returned by an upstream lookup used directly as the key name; deserialized metadata missing the field.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/0de9b76c2ee7b83d. Report an issue: GitHub.

Appendix: source

Thrown at commons-server/src/main/java/com/navercorp/pinpoint/common/server/applicationmap/statistics/UidPrefix.java:101

        int secondTimestamp = IntInverter.restore(buffer.readInt());
        long msTimestamp = SecondTimestamp.restoreSecondTimestamp(secondTimestamp);
        return new UidPrefix(serviceUid, applicationNameHash, serviceType, msTimestamp);
    }


    public static int hash(byte[] bytes) {
        HashCode hashCode = hashFunction.hashBytes(bytes);
        return hashCode.hashCode();
    }

    public static String requireNameLength(String name, String fieldName) {
        return requireNameLength(name, fieldName, KEY_SIZE);
    }

    public static String requireNameLength(String name, String fieldName, int maxKeySize) {
        if (name == null) {
            throw new NullPointerException(fieldName);
        }
        if (name.length() > maxKeySize) {
            throw new IllegalArgumentException(fieldName + " too long:" + name.length());
        }
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;

        UidPrefix uidPrefix = (UidPrefix) o;
        return serviceUid == uidPrefix.serviceUid && applicationNameHash == uidPrefix.applicationNameHash && serviceType == uidPrefix.serviceType && timestamp == uidPrefix.timestamp;
    }

    @Override
    public int hashCode() {
        int result = serviceUid;

View on GitHub (pinned to 744c3d3075)