apache/dubbo · error · IllegalArgumentException
type [ ${type} ] is unsupported
Error message
type [ ${type} ] is unsupported What it means
Thrown by the JavaBeanDescriptor(String, int) constructor when the supplied type int is outside the valid range [TYPE_CLASS=1 .. TYPE_BEAN=7]. JavaBeanDescriptor uses an int discriminator (CLASS, ENUM, COLLECTION, MAP, ARRAY, PRIMITIVE, BEAN); an out-of-range value would leave the descriptor in an inconsistent state, so it is rejected at construction. IllegalArgumentException.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanDescriptor.java:67
private static final int TYPE_MAX = TYPE_BEAN;
/**
* Used to define a type is valid.
*
* @see #isValidType(int)
*/
private static final int TYPE_MIN = TYPE_CLASS;
private String className;
private int type;
private final Map<Object, Object> properties = new LinkedHashMap<>();
public JavaBeanDescriptor() {}
public JavaBeanDescriptor(String className, int type) {
notEmpty(className, "class name is empty");
if (!isValidType(type)) {
throw new IllegalArgumentException("type [ " + type + " ] is unsupported");
}
this.className = className;
this.type = type;
}
public boolean isClassType() {
return TYPE_CLASS == type;
}
public boolean isEnumType() {
return TYPE_ENUM == type;
}
public boolean isCollectionType() {
return TYPE_COLLECTION == type;
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Use the documented TYPE_* constants (JavaBeanDescriptor.TYPE_CLASS, TYPE_ENUM, ...) instead of literal numbers.
- If the value comes from deserialization, validate/upgrade it against the constant range before constructing.
- Initialize type from a known constant rather than leaving it at the default 0.
- When reading from legacy data, map old ordinals to current TYPE_* values explicitly.
Example fix
// before desc = new JavaBeanDescriptor(className, 0); // 0 is not a valid type // after desc = new JavaBeanDescriptor(className, JavaBeanDescriptor.TYPE_CLASS);
Defensive patterns
Strategy: validation
Validate before calling
// Validate the type ordinal before constructing a JavaBeanDescriptor
boolean isValidType(int type) {
return type >= JavaBeanDescriptor.TYPE_CLASS && type <= JavaBeanDescriptor.TYPE_BEAN;
}
// if (isValidType(t)) new JavaBeanDescriptor(className, t); else throw/reject; Prevention
- Always use the TYPE_* constants instead of literal ints.
- Validate type ordinals read from external/serialized data before constructing.
- Initialize the type field explicitly rather than relying on the default 0.
- When migrating versions, remap old ordinals to the current TYPE_* constants.
When it happens
Trigger: new JavaBeanDescriptor(className, type) with type < 1 or type > 7, e.g. passing 0, 8, or a raw value read from an untrusted/legacy serialized stream. Also when computing the type via arithmetic or constants that yields an invalid ordinal.
Common situations: Deserializing a JavaBeanDescriptor from a corrupted or version-mismatched byte stream; hand-building a descriptor with a wrong constant; migration where a type constant was removed/renumbered; passing a default int (0) because the type field was never set.
Related errors
- Unsupported type ${className}:${type}
- unterminated escape sequence at index ${i} of: ${str}
- The instance is not a enum wrapper
- The instance is not a class wrapper
- The instance is not a primitive type wrapper
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/8e44b9487e9e6e54.
Report an issue: GitHub.