{"record":{"id":"6811d791fff8f2c8","repo":"zhisheng17/flink-learning","slug":"the-given-argument-is-no-array","errorCode":null,"errorMessage":"The given argument is no array.","messagePattern":"The given argument is no array\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-learning-core/src/main/java/com/zhisheng/core/utils/StringUtils.java","lineNumber":166,"sourceCode":"\t\t\treturn Arrays.toString((double[]) array);\n\t\t}\n\t\tif (array instanceof float[]) {\n\t\t\treturn Arrays.toString((float[]) array);\n\t\t}\n\t\tif (array instanceof boolean[]) {\n\t\t\treturn Arrays.toString((boolean[]) array);\n\t\t}\n\t\tif (array instanceof char[]) {\n\t\t\treturn Arrays.toString((char[]) array);\n\t\t}\n\t\tif (array instanceof short[]) {\n\t\t\treturn Arrays.toString((short[]) array);\n\t\t}\n\n\t\tif (array.getClass().isArray()) {\n\t\t\treturn \"<unknown array type>\";\n\t\t} else {\n\t\t\tthrow new IllegalArgumentException(\"The given argument is no array.\");\n\t\t}\n\t}\n\n\t/**\n\t * Replaces control characters by their escape-coded version. For example,\n\t * if the string contains a line break character ('\\n'), this character will\n\t * be replaced by the two characters backslash '\\' and 'n'. As a consequence, the\n\t * resulting string will not contain any more control characters.\n\t *\n\t * @param str The string in which to replace the control characters.\n\t * @return The string with the replaced characters.\n\t */\n\tpublic static String showControlCharacters(String str) {\n\t\tint len = str.length();\n\t\tStringBuilder sb = new StringBuilder();\n\n\t\tfor (int i = 0; i < len; i += 1) {\n\t\t\tchar c = str.charAt(i);","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-core/src/main/java/com/zhisheng/core/utils/StringUtils.java#L148-L184","documentation":"StringUtils.arrayToString renders an array (primitive or object) as a string. After trying all known array component types it falls back: if the object is not an array at all, it throws IllegalArgumentException('The given argument is no array.').","triggerScenarios":"Calling arrayToString (directly or via arrayAwareToString) with a non-array object such as a String, List, or Integer — the method requires Class.isArray() to be true.","commonSituations":"Passing a List or Collection expecting it to be formatted like an array, or after a refactor changed a parameter from T[] to List<T> while the call site still calls arrayToString.","solutions":["Pass an actual array (e.g. Object[], int[]) to arrayToString","Convert collections first: list.toArray()","Use arrayAwareToString which handles non-array objects by falling back to String.valueOf"],"exampleFix":"// before\nStringUtils.arrayToString(myList);\n// after\nStringUtils.arrayAwareToString(myList); // or myList.toArray()","handlingStrategy":"type-guard","validationCode":"if (obj == null || !obj.getClass().isArray()) {\n    throw new IllegalArgumentException(\"arrayToString requires an array, got: \" + (obj == null ? \"null\" : obj.getClass().getSimpleName()));\n}","typeGuard":"static boolean isArray(Object o) {\n    return o != null && o.getClass().isArray();\n}","tryCatchPattern":"try {\n    String s = StringUtils.arrayToString(arg);\n} catch (IllegalArgumentException e) {\n    if (\"The given argument is no array.\".equals(e.getMessage())) {\n        s = String.valueOf(arg);\n    } else throw e;\n}","preventionTips":["Use arrayAwareToString when the input type is unknown — it handles non-arrays","Convert Collections with toArray() before array formatting","Check Class.isArray() before calling array*ToString utilities"],"tags":["java","arrays","utils","validation"],"backgroundTag":"invalid-argument","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}