pinpoint-apm/pinpoint · error · IllegalArgumentException

unsupported content :+content

Error message

unsupported content :+content

What it means

ContentLength.Builder.addContentType registers a length-computing function for a content Class, looked up in a static MAPPING of supported types. If the class is not in the mapping, no LengthFunction exists for it and IllegalArgumentException is thrown listing the unsupported content type.

Solutions

  1. Use addFunction(LengthFunction) with a custom length function for unsupported types.
  2. Only pass classes registered in ContentLength.MAPPING to addContentType.
  3. Register the new content type in MAPPING if the class should be supported globally.

Example fix

// before
builder.addContentType(MyDto.class); // throws
// after
builder.addFunction(MyDto.class, content -> serialize(content).length);
Defensive patterns

Strategy: validation

Validate before calling

if (!ContentLength.isSupported(content)) {
    throw new IllegalArgumentException("no LengthFunction registered for " + content);
}

Type guard

boolean isSupportedContent(Class<?> c) { return ContentLength.isSupported(c); }

Try / catch

try {
    builder.addContentType(content);
} catch (IllegalArgumentException e) {
    log.warn("Unsupported content type {}, registering custom length function", content);
    builder.addFunction(customLengthFunction);
}

Prevention

When it happens

Trigger: Calling addContentType(SomeClass.class) where SomeClass is not one of the pre-registered types in ContentLength.MAPPING, e.g. passing a custom DTO class or a type from a different library instead of supported types like String or byte[].

Common situations: Extending content-length computation to new types without registering a LengthFunction, or refactors renaming/moving a class so it no longer matches the mapping key.

Related errors


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

Appendix: source

Thrown at commons/src/main/java/com/navercorp/pinpoint/common/util/ContentLength.java:75

            Map<Class<?>, LengthFunction> map = new LinkedHashMap<>();
            map.put(String.class, new StringLength());
            map.put(byte[].class, new PrimitiveByteArrayLength());
            map.put(char[].class, new PrimitiveCharArrayLength());
            map.put(File.class, new FileLength());
            map.put(InputStream.class, new InputStreamAvailableLength());
            return map;
        }

        private Builder() {
        }

        private final List<LengthFunction> list = new ArrayList<>();

        public void addContentType(Class<?> content) {
            Objects.requireNonNull(content, "content");
            LengthFunction lengthFunction = MAPPING.get(content);
            if (lengthFunction == null) {
                throw new IllegalArgumentException("unsupported content :" + content);
            }
            list.add(lengthFunction);
        }

        public void addFunction(LengthFunction function) {
            Objects.requireNonNull(function, "function");
            list.add(function);
        }

        public ContentLength build() {
            LengthFunction[] functions = list.toArray(new LengthFunction[0]);
            return new ContentLength(functions);
        }
    }

    public interface LengthFunction {
        long getLength(Object context);
    }

View on GitHub (pinned to 744c3d3075)