{"record":{"id":"e1be199cb3dfdad0","repo":"alibaba/nacos","slug":"unsupported-object-type","errorCode":null,"errorMessage":"Unsupported object type: {}","messagePattern":"Unsupported object type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"common/src/main/java/com/alibaba/nacos/common/utils/CollectionUtils.java","lineNumber":201,"sourceCode":"     */\n    public static boolean sizeIsEmpty(Object object) {\n        if (object instanceof Collection) {\n            return ((Collection) object).isEmpty();\n        } else if (object instanceof Map) {\n            return ((Map) object).isEmpty();\n        } else if (object instanceof Object[]) {\n            return ((Object[]) object).length == 0;\n        } else if (object instanceof Iterator) {\n            return ((Iterator) object).hasNext() == false;\n        } else if (object instanceof Enumeration) {\n            return ((Enumeration) object).hasMoreElements() == false;\n        } else if (object == null) {\n            throw new IllegalArgumentException(\"Unsupported object type: null\");\n        } else {\n            try {\n                return Array.getLength(object) == 0;\n            } catch (IllegalArgumentException ex) {\n                throw new IllegalArgumentException(\n                    \"Unsupported object type: \" + object.getClass().getName());\n            }\n        }\n    }\n    \n    /**\n     * Whether contain item in collection.\n     *\n     * @param coll   collection\n     * @param target target value\n     * @param <T>    General Type\n     * @return true if contain, otherwise false\n     */\n    public static <T> boolean contains(Collection<T> coll, T target) {\n        if (isEmpty(coll)) {\n            return false;\n        }\n        return coll.contains(target);","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/utils/CollectionUtils.java#L183-L219","documentation":"Thrown by CollectionUtils.sizeIsEmpty(Object) when the argument is a non-null object that is not a Collection, Map, Object[], Iterator, or Enumeration, and Array.getLength(object) also throws. The message appends the actual class name so you can see what was passed.","triggerScenarios":"Calling sizeIsEmpty with an arbitrary object such as a String, a primitive array (int[]), a custom POJO, or any type without a measurable size.","commonSituations":"Passing a String (common mistake — length is queried differently); passing a primitive array like int[] (only Object[] is supported); passing a POJO where a Collection was expected.","solutions":["Check the class name in the error message to confirm what was passed.","Convert the input to a supported type before calling (e.g., Arrays.asList for arrays, wrap in a collection).","For Strings use str.isEmpty(); for primitive arrays use array.length directly."],"exampleFix":"// before\nboolean empty = CollectionUtils.sizeIsEmpty(someString);\n\n// after\nboolean empty = someString == null || someString.isEmpty();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isSupportedBySizeIsEmpty(Object o) {\n    return o instanceof Collection || o instanceof Map\n        || o instanceof Object[] || o instanceof Iterator\n        || o instanceof Enumeration;\n}","tryCatchPattern":"try {\n    return CollectionUtils.sizeIsEmpty(obj);\n} catch (IllegalArgumentException e) {\n    // obj was a String, primitive array, or arbitrary POJO\n    return false; // or compute size the type-specific way\n}","preventionTips":["sizeIsEmpty only accepts Collection, Map, Object[], Iterator, Enumeration — not String, not primitive arrays.","Use String.isEmpty(), array.length, or Arrays.asList for unsupported types.","Read the class name in the error message to confirm the offending type."],"tags":["collections","type-mismatch","validation","utility"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}