{"record":{"id":"71aa08522739cbcd","repo":"flowable/flowable-engine","slug":"could-not-read-from-inputstream","errorCode":null,"errorMessage":"Could not read from inputstream","messagePattern":"Could not read from inputstream","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/util/io/InputStreamSource.java","lineNumber":47,"sourceCode":"    // The bpmn parsers needs to go over the stream at least twice:\n    // Once for the schema validation and once for the parsing itself.\n    // So we keep the content of the inputstream in memory so we can\n    // re-read it.\n\n    protected BufferedInputStream inputStream;\n    protected byte[] bytes;\n\n    public InputStreamSource(InputStream inputStream) {\n        this.inputStream = new BufferedInputStream(inputStream);\n    }\n\n    @Override\n    public InputStream getInputStream() {\n        if (bytes == null) {\n            try {\n                bytes = getBytesFromInputStream(inputStream);\n            } catch (IOException e) {\n                throw new FlowableException(\"Could not read from inputstream\", e);\n            }\n        }\n        return new BufferedInputStream(new ByteArrayInputStream(bytes));\n    }\n\n    @Override\n    public String toString() {\n        return \"InputStream\";\n    }\n\n    public byte[] getBytesFromInputStream(InputStream inStream) throws IOException {\n        long length = inStream.available();\n        byte[] bytes = new byte[(int) length];\n\n        int offset = 0;\n        int numRead = 0;\n        while (offset < bytes.length && (numRead = inStream.read(bytes, offset, bytes.length - offset)) >= 0) {\n            offset += numRead;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/util/io/InputStreamSource.java#L29-L65","documentation":"Thrown by InputStreamSource.getInputStream() when reading the wrapped InputStream into a byte array fails with an IOException. The source caches bytes lazily, so this occurs on the first getInputStream() call. The original IOException is the cause.","triggerScenarios":"getBytesFromInputStream throws IOException while draining the wrapped stream — e.g. the stream was already consumed and closed, or the underlying resource became unreadable mid-read.","commonSituations":"Deploying a process definition where the resource stream was already read elsewhere; network-backed streams (URLs, remote repos) dropping mid-read; file removed between open and read.","solutions":["Inspect the cause IOException for the underlying read failure","Ensure the InputStream is fresh/unconsumed when constructing InputStreamSource","Check the underlying resource (file/URL/network) is available and readable","Retry the deployment with a newly opened stream"],"exampleFix":"// before\nInputStreamSource src = new InputStreamSource(sharedStream); // stream already consumed upstream\n// after\nInputStreamSource src = new InputStreamSource(new FileInputStream(\"process.bpmn20.xml\"));","handlingStrategy":"try-catch","validationCode":"if (inputStream == null) throw new IllegalArgumentException(\"stream must not be null\");\nif (inputStream.available() <= 0 && expectsData) logger.warn(\"stream may be empty/already consumed\");","typeGuard":null,"tryCatchPattern":"try {\n    InputStream is = source.getInputStream();\n} catch (FlowableException e) {\n    logger.error(\"Reading deployment resource failed\", e.getCause());\n    throw new IOException(\"retry with a fresh stream\", e);\n}","preventionTips":["Always pass a freshly opened stream, never one already consumed","Check underlying file/URL availability before deployment","Read the cause IOException for the root read failure"],"tags":["io","inputstream","deployment"],"backgroundTag":"file-read-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}