{"record":{"id":"b1796c2b0fb858fe","repo":"flowable/flowable-engine","slug":"byte-array-for-resource-resourcename-is-null-b1796c","errorCode":null,"errorMessage":"byte array for resource '${resourceName}' is null","messagePattern":"byte array for resource '(.+?)' is null","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/repository/EventDeploymentBuilderImpl.java","lineNumber":65,"sourceCode":"        this.deployment = eventRegistryEngineConfiguration.getDeploymentEntityManager().create();\n        this.resourceEntityManager = eventRegistryEngineConfiguration.getResourceEntityManager();\n    }\n\n    @Override\n    public EventDeploymentBuilder 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        EventResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(bytes);\n        deployment.addResource(resource);\n        return this;\n    }\n\n    @Override\n    public EventDeploymentBuilder 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":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/repository/EventDeploymentBuilderImpl.java#L47-L83","documentation":"After attempting to read the InputStream into a byte array, addInputStream checks whether the result is null and throws this error. IOUtils.toByteArray normally throws on failure rather than returning null, so this is a defensive guard against a null conversion result.","triggerScenarios":"addInputStream where the byte conversion yields null (defensive path — practically only if IOUtils.toByteArray returns null, e.g. unusual IOUtil behavior or custom subclasses).","commonSituations":"Rare in practice; encountered when using custom IO utilities, exotic stream wrappers, or modified/copied code where the byte reading logic differs from stock Apache Commons IO behavior.","solutions":["Verify you are using the standard org.flowable version of EventDeploymentBuilderImpl and commons-io IOUtils; upgrade Flowable if a patched version fixes this path","Check the InputStream implementation for a toByteArray path that returns null and replace it with a plain stream (FileInputStream, ByteArrayInputStream)","Log stream contents/availability before the call to confirm bytes exist"],"exampleFix":"// before\ndeploymentBuilder.addInputStream(name, weirdStream); // custom stream returning null bytes\n// after\ndeploymentBuilder.addInputStream(name, new FileInputStream(file)); // normal stream","handlingStrategy":"try-catch","validationCode":"byte[] check = IOUtils.toByteArray(inputStream);\nif (check == null) throw new IllegalStateException(\"byte conversion produced null for \" + resourceName);","typeGuard":null,"tryCatchPattern":"try {\n    deploymentBuilder.addInputStream(name, stream);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"byte array for resource\")) {\n        // replace custom stream wrapper with a standard stream implementation\n    } else { throw e; }\n}","preventionTips":["Use standard stream implementations (FileInputStream, ByteArrayInputStream)","Avoid custom InputStream subclasses with unusual read semantics","Keep Flowable and commons-io at stock versions"],"tags":["flowable","deployment","io","defensive-check"],"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"}