{"record":{"id":"c20572991b24d692","repo":"flowable/flowable-engine","slug":"byte-array-for-resource-resourcename-is-null-c20572","errorCode":null,"errorMessage":"byte array for resource '${resourceName}' is null","messagePattern":"byte array for resource '(.+?)' is null","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java","lineNumber":68,"sourceCode":"        this.deployment = dmnEngineConfiguration.getDeploymentEntityManager().create();\n        this.resourceEntityManager = dmnEngineConfiguration.getResourceEntityManager();\n    }\n\n    @Override\n    public DmnDeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {\n        if (inputStream == null) {\n            throw new FlowableException(\"inputStream for resource '\" + resourceName + \"' is null\");\n        }\n\n        byte[] bytes = null;\n        try {\n            bytes = IOUtils.toByteArray(inputStream);\n        } catch (Exception e) {\n            throw new FlowableException(\"could not get byte array from resource '\" + resourceName + \"'\", e);\n        }\n\n        if (bytes == null) {\n            throw new FlowableException(\"byte array for resource '\" + resourceName + \"' is null\");\n        }\n\n        DmnResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public DmnDeploymentBuilder addClasspathResource(String resource) {\n        try (final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(resource)) {\n            if (inputStream == null) {\n                throw new FlowableException(\"resource '\" + resource + \"' not found\");\n            }\n            return addInputStream(resource, inputStream);\n            \n        } catch (IOException ex) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/repository/DmnDeploymentBuilderImpl.java#L50-L86","documentation":"After reading the InputStream, addInputStream checks that the produced byte array is not null and throws FlowableException if it is. IOUtils.toByteArray never returns null on success, so reaching this check indicates an exotic/null-returning stream wrapper or a defensive guard against empty/invalid stream implementations. The resource cannot be added to the DMN deployment without bytes.","triggerScenarios":"Calling addInputStream(name, is) with a non-null but degenerate InputStream implementation whose read path yields a null byte array (custom or mocking stream), or a wrapper that returns null content. Practically rare — most real failures hit the earlier 'could not get byte array' error instead.","commonSituations":"Custom InputStream subclasses or test doubles that violate the InputStream contract; framework-provided stream wrappers returning null bytes; passing a placeholder stream from uninitialized code under test.","solutions":["Replace the custom/wrapper InputStream with a standard one: new ByteArrayInputStream(byteArray) or FileInputStream/Files.newInputStream.","If you hold the content already, use builder.addInputStream(name, new ByteArrayInputStream(bytes)) after verifying bytes != null.","Check that no test mock is leaking into production code paths; restore the real resource source.","Log/inspect the stream class to find which non-standard implementation returns null and fix its read() contract."],"exampleFix":"// before\nInputStream is = myCustomStreamWrapper.getStream(); // returns null bytes\nbuilder.addInputStream(\"decision.dmn\", is);\n\n// after\nbyte[] bytes = Files.readAllBytes(Paths.get(\"src/main/resources/decision.dmn\"));\nbuilder.addInputStream(\"decision.dmn\", new ByteArrayInputStream(bytes));","handlingStrategy":"type-guard","validationCode":"byte[] bytes = readSourceBytes();\nif (bytes == null || bytes.length == 0) {\n    throw new IllegalArgumentException(\"Resource content is empty/null: \" + resourceName);\n}\nbuilder.addInputStream(resourceName, new ByteArrayInputStream(bytes));","typeGuard":"boolean isValidStream(InputStream is) {\n    return is != null && !(is instanceof NullInputStream);\n}","tryCatchPattern":"try {\n    builder.addInputStream(name, is);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"byte array for resource\")) {\n        // stream implementation returned null bytes; rebuild from a standard stream\n    } else { throw e; }\n}","preventionTips":["Use only standard InputStream implementations (ByteArrayInputStream, FileInputStream, ClassLoader streams).","Do not let test mocks or placeholder streams reach the deployment builder.","Buffer content to byte[] yourself and validate before adding resources.","Keep custom stream wrappers conforming to the InputStream contract."],"tags":["flowable","dmn","deployment","null-value"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}