alibaba/nacos · warning · IllegalArgumentException
Unsupported object type: null
Error message
Unsupported object type: null
What it means
Thrown by CollectionUtils.sizeIsEmpty(Object) when the argument is null. Unlike most 'isEmpty' helpers, this method deliberately rejects null instead of treating it as empty — passing null is treated as a programming error, not an empty collection.
Source
Thrown at common/src/main/java/com/alibaba/nacos/common/utils/CollectionUtils.java:196
* Judge whether object is empty.
*
* @param object object
* @return true if object is empty, otherwise false
* @throws IllegalArgumentException if object has no length or size
*/
public static boolean sizeIsEmpty(Object object) {
if (object instanceof Collection) {
return ((Collection) object).isEmpty();
} else if (object instanceof Map) {
return ((Map) object).isEmpty();
} else if (object instanceof Object[]) {
return ((Object[]) object).length == 0;
} else if (object instanceof Iterator) {
return ((Iterator) object).hasNext() == false;
} else if (object instanceof Enumeration) {
return ((Enumeration) object).hasMoreElements() == false;
} else if (object == null) {
throw new IllegalArgumentException("Unsupported object type: null");
} else {
try {
return Array.getLength(object) == 0;
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException(
"Unsupported object type: " + object.getClass().getName());
}
}
}
/**
* Whether contain item in collection.
*
* @param coll collection
* @param target target value
* @param <T> General Type
* @return true if contain, otherwise false
*/View on GitHub (pinned to 9b989acdf1)
Solutions
- Null-check before calling: if (obj != null && sizeIsEmpty(obj)) ...
- Prefer CollectionUtils.isEmpty(coll) / isNotEmpty(coll) for null-safe behavior when you only deal with Collections.
- Fix the upstream null return so the invariant the method assumes holds.
Example fix
// before boolean empty = CollectionUtils.sizeIsEmpty(maybeNull); // after boolean empty = maybeNull != null && CollectionUtils.sizeIsEmpty(maybeNull);
Defensive patterns
Strategy: validation
Validate before calling
if (object == null) {
// treat as empty or reject explicitly — sizeIsEmpty will not accept null
return; // or throw a domain error
}
boolean empty = CollectionUtils.sizeIsEmpty(object); Type guard
boolean isSizeable(Object o) {
return o instanceof Collection || o instanceof Map
|| o instanceof Object[] || o instanceof Iterator
|| o instanceof Enumeration;
} Prevention
- Never call sizeIsEmpty on a possibly-null value without a null guard.
- Prefer CollectionUtils.isEmpty(coll) for null-safe Collection checks.
- Fix upstream null returns at the source.
When it happens
Trigger: Calling CollectionUtils.sizeIsEmpty(null). Any caller that passes an unguarded null variable hits this immediately.
Common situations: A nullable field or method result passed into sizeIsEmpty without a null check; refactoring that introduced a nullable return upstream.
Related errors
- iterable cannot be null.
- Unsupported object type: {}
- Expected an array of elements (or empty array) but received
- expected one element but was: <{}>
- Agent replacement must not be null
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/d16d89520c4f26b4.
Report an issue: GitHub.