{"record":{"id":"8f6c46db3b788b9d","repo":"Activiti/Activiti","slug":"e","errorCode":null,"errorMessage":"e","messagePattern":"e","errorType":"exception","errorClass":"JSONException","httpStatus":null,"severity":"warning","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/util/json/JSONArray.java","lineNumber":884,"sourceCode":"\n            for (int i = 0; i < len; i += 1) {\n                if (b) {\n                    writer.write(',');\n                }\n                Object v = this.myArrayList.get(i);\n                if (v instanceof JSONObject) {\n                    ((JSONObject) v).write(writer);\n                } else if (v instanceof JSONArray) {\n                    ((JSONArray) v).write(writer);\n                } else {\n                    writer.write(JSONObject.valueToString(v));\n                }\n                b = true;\n            }\n            writer.write(']');\n            return writer;\n        } catch (IOException e) {\n            throw new JSONException(e);\n        }\n    }\n}\n","sourceCodeStart":866,"sourceCodeEnd":888,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/util/json/JSONArray.java#L866-L888","documentation":"Thrown by JSONArray.write(Writer) when the underlying Writer raises an IOException during serialization. The library wraps the IOException into a JSONException whose message is just 'e' (the exception's toString), so the real cause is in the wrapped cause.","triggerScenarios":"Writing a JSONArray to a Writer whose I/O fails mid-serialization: closed stream, disk full, broken pipe (e.g. servlet response already committed/closed), network socket error.","commonSituations":"Serializing large arrays to HTTP response output streams that the client closed; writing to a FileWriter on a full disk; reusing a closed Writer.","solutions":["Call getCause() on the JSONException to get the original IOException and address it (closed stream, disk full, broken pipe).","Ensure the Writer is open and the underlying connection (HTTP response, socket, file) is still writable for the whole serialization.","Buffer the JSON into a String (array.toString()) before writing to fragile streams.","Wrap the write call in try-catch and log the cause chain."],"exampleFix":"// before\njsonArray.write(writer);\n// after\ntry {\n    writer.write(jsonArray.toString());\n} catch (IOException e) {\n    log.warn(\"Client gone / stream closed: \" + e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"if (writer == null) throw new IllegalArgumentException(\"writer is null\");","typeGuard":null,"tryCatchPattern":"try { arr.write(writer); } catch (JSONException e) { IOException cause = (IOException) e.getCause(); log.warn(\"JSON write failed\", cause); }","preventionTips":["Always inspect JSONException.getCause() here — the message is only the exception's toString","Avoid serializing directly to client-facing streams; build the String first","Check that streams/connections are open and not already committed"],"tags":["json","io","serialization"],"backgroundTag":"broken-pipe","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}