{"record":{"id":"f35519231b027220","repo":"flowable/flowable-engine","slug":"byte-array-for-resource-resourcename-is-null-f35519","errorCode":null,"errorMessage":"byte array for resource '${resourceName}' is null","messagePattern":"byte array for resource '(.+?)' is null","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java","lineNumber":63,"sourceCode":"        this.deployment = cmmnEngineConfiguration.getCmmnDeploymentEntityManager().create();\n        this.resourceEntityManager = cmmnEngineConfiguration.getCmmnResourceEntityManager();\n    }\n\n    @Override\n    public CmmnDeploymentBuilder 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 = IoUtil.readInputStream(inputStream, resourceName);\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        CmmnResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public CmmnDeploymentBuilder 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":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java#L45-L81","documentation":"CmmnDeploymentBuilderImpl.addInputStream throws FlowableException with \"byte array for resource '<resourceName>' is null\" when IoUtil.readInputStream returns null instead of the expected byte array. This is a defensive post-read check: the stream appeared readable but yielded no content, so the deployment resource would be empty.","triggerScenarios":"addInputStream called with a stream whose read produces a null byte result — practically a stream reporting no content (e.g. a degenerate/unusable stream implementation) — via addInputStream or addClasspathResource.","commonSituations":"Custom or mocked InputStream implementations returning null; reading from an empty or zero-length file/source; a wrapper stream that silently returns nothing instead of throwing.","solutions":["Verify the source actually has content before adding it (file size > 0, stream available()).","Replace degenerate stream implementations (mocks, custom wrappers) with real byte-producing streams like ByteArrayInputStream.","If reading manually, validate the byte array is non-null and non-empty before deploying."],"exampleFix":"// before\nbuilder.addInputStream(name, maybeBrokenStream);\n\n// after\nbyte[] bytes = IoUtil.readInputStream(maybeBrokenStream, name);\nif (bytes == null || bytes.length == 0) {\n    throw new IllegalStateException(\"resource is empty: \" + name);\n}\nbuilder.addInputStream(name, new ByteArrayInputStream(bytes));","handlingStrategy":"validation","validationCode":"byte[] bytes = IoUtil.readInputStream(is, name);\nif (bytes == null || bytes.length == 0) {\n    throw new IllegalStateException(\"resource has no content: \" + name);\n}\nbuilder.addInputStream(name, new ByteArrayInputStream(bytes));","typeGuard":"boolean hasContent(byte[] b) { return b != null && b.length > 0; }","tryCatchPattern":"try {\n    builder.addInputStream(name, is);\n} catch (FlowableException e) {\n    if (!e.getMessage().contains(\"is null\")) throw e;\n    throw new DeploymentException(\"empty resource: \" + name, e);\n}","preventionTips":["Verify source files are non-empty before deploying","Avoid custom/mocked streams that can return null reads in production paths","Log resource sizes during deployment for early detection"],"tags":["io","empty-resource","deployment","cmmn"],"backgroundTag":"empty-required-field","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}