apache/dubbo · warning · IllegalStateException
The instance is not a enum wrapper
Error message
The instance is not a enum wrapper
What it means
Thrown by JavaBeanDescriptor.setEnumNameProperty when the descriptor's type is not TYPE_ENUM. Enum-specific mutators are only valid on enum wrappers; calling them on a class/primitive/collection/map/array/bean descriptor is a programming error, so the method refuses with IllegalStateException.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanDescriptor.java:128
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public Object setProperty(Object propertyName, Object propertyValue) {
notNull(propertyName, "Property name is null");
return properties.put(propertyName, propertyValue);
}
public String setEnumNameProperty(String name) {
if (isEnumType()) {
Object result = setProperty(ENUM_PROPERTY_NAME, name);
return result == null ? null : result.toString();
}
throw new IllegalStateException("The instance is not a enum wrapper");
}
public String getEnumPropertyName() {
if (isEnumType()) {
Object result = getProperty(ENUM_PROPERTY_NAME);
return result == null ? null : result.toString();
}
throw new IllegalStateException("The instance is not a enum wrapper");
}
public String setClassNameProperty(String name) {
if (isClassType()) {
Object result = setProperty(CLASS_PROPERTY_NAME, name);
return result == null ? null : result.toString();
}
throw new IllegalStateException("The instance is not a class wrapper");
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Construct the descriptor as an enum: new JavaBeanDescriptor(className, JavaBeanDescriptor.TYPE_ENUM) before calling setEnumNameProperty.
- Guard with if (desc.isEnumType()) before calling enum mutators.
- Do not reuse a descriptor across types; create a fresh one with the correct type.
- Verify the type field after deserialization before invoking type-specific methods.
Example fix
// before
JavaBeanDescriptor desc = new JavaBeanDescriptor(); // type defaults to 0
desc.setEnumNameProperty("RED"); // throws
// after
JavaBeanDescriptor desc = new JavaBeanDescriptor(Color.class.getName(), JavaBeanDescriptor.TYPE_ENUM);
desc.setEnumNameProperty("RED"); Defensive patterns
Strategy: type-guard
Type guard
// Only set enum name when the descriptor is actually an enum wrapper
boolean canSetEnumName(JavaBeanDescriptor d) {
return d.isEnumType();
} Prevention
- Construct descriptors with the correct TYPE_* before calling type-specific mutators.
- Guard enum mutators with isEnumType().
- Never reuse a descriptor across types; create a fresh one.
- Validate the type after deserialization before invoking type-specific methods.
When it happens
Trigger: desc.setEnumNameProperty(name) on a JavaBeanDescriptor constructed with a type other than TYPE_ENUM (e.g. TYPE_CLASS, TYPE_PRIMITIVE, or the default no-arg constructor whose type defaults to 0).
Common situations: Reusing a descriptor for a different kind without recreating it; building descriptors generically and calling the wrong mutator; default-constructed descriptor (type 0) being treated as an enum; refactoring that changed a type constant.
Related errors
- The instance is not a class wrapper
- The instance is not a primitive type wrapper
- type [ ${type} ] is unsupported
- unterminated escape sequence at index ${i} of: ${str}
- unable to determine bean class from factory's superclass or
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/73925839ecfeda55.
Report an issue: GitHub.