apache/pulsar · error · IllegalArgumentException
unsupported field-type %s for %s
Error message
unsupported field-type %s for %s
What it means
FieldParser.value() only supports parameterized (generic) fields of type List, Set, Map, or Optional. Any other generic field type encountered while converting a non-blank string value throws IllegalArgumentException naming the field type and name.
Source
Thrown at pulsar-common/src/main/java/org/apache/pulsar/common/util/FieldParser.java:198
return stringToList(strValue, clazz);
} else if (field.getType().equals(Set.class)) {
// covert to set
return stringToSet(strValue, clazz);
} else if (field.getType().equals(Map.class)) {
Class<?> valueClass =
(Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1];
return stringToMap(strValue, clazz, valueClass);
} else if (field.getType().equals(Optional.class)) {
Type typeClazz = ((ParameterizedType) fieldType).getActualTypeArguments()[0];
if (typeClazz instanceof ParameterizedType) {
throw new IllegalArgumentException(format("unsupported non-primitive Optional<%s> for %s",
typeClazz.getClass(), field.getName()));
}
@SuppressWarnings("unchecked") // typeClazz is verified to be a non-parameterized Class
Optional<?> result = Optional.ofNullable(convert(strValue, (Class<?>) typeClazz));
return result;
} else {
throw new IllegalArgumentException(
format("unsupported field-type %s for %s", field.getType(), field.getName()));
}
} else {
return convert(strValue, field.getType());
}
}
/**
* Sets the empty/null value if field is allowed to be set empty.
*
* @param strValue
* @param field
* @param obj
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
public static <T> void setEmptyValue(String strValue, Field field, T obj)
throws IllegalArgumentException, IllegalAccessException {View on GitHub (pinned to 820761864e)
Solutions
- Change the field to List<T>, Set<T>, Map<K,V>, or a simple type that convert() supports.
- Parse the field manually and set it via direct assignment/setter instead of FieldParser.update().
- Exclude the field from the properties map so update() never attempts to convert it.
Example fix
// before private Properties extraProps; // unsupported field-type class java.util.Properties // after private Map<String, String> extraProps; // supported via stringToMap
Defensive patterns
Strategy: type-guard
Validate before calling
static final Set<Class<?>> SUPPORTED_GENERIC = Set.of(List.class, Set.class, Map.class, Optional.class);
static void checkGenericType(Field f) {
if (f.getGenericType() instanceof ParameterizedType && !SUPPORTED_GENERIC.contains(f.getType())) {
throw new IllegalArgumentException("unsupported field-type " + f.getType() + " for " + f.getName());
}
} Type guard
static boolean isFieldParserSupported(Field f) {
if (!(f.getGenericType() instanceof ParameterizedType)) return true; // falls to convert()
return List.class.equals(f.getType()) || Set.class.equals(f.getType())
|| Map.class.equals(f.getType()) || Optional.class.equals(f.getType());
} Try / catch
try {
return FieldParser.value(strValue, field);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("unsupported field-type")) {
return null; // or parse with Jackson manually
}
throw e;
} Prevention
- Use only List, Set, Map, or Optional as generic field types in config classes
- Use Map<String,String> instead of java.util.Properties
- Avoid custom Collection subclasses in reflectively-populated POJOs
- Unit-test update() over all fields of every config class
When it happens
Trigger: Calling update()/value() on a class with a generic field whose raw type is not List/Set/Map/Optional, e.g. Properties props field, custom Collection<E> subclass, or OptionalInt-style types, when the properties map has a non-blank value for it.
Common situations: Config classes holding java.util.Properties or custom collection fields populated from a properties map; adding a new collection type to a Pulsar config class that FieldParser was never taught about.
Related errors
- unsupported non-primitive Optional<%s> for %s
- Failed to instantiate ${className}
- Exception caused while converting configuration: ${message}
- Failed to compute configuration overrides
- Failed to create authentication: ${message}
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/7795266dcd32003b.
Report an issue: GitHub.