{"record":{"id":"264a1cec554de070","repo":"flowable/flowable-engine","slug":"bytes-array-is-null-264a1c","errorCode":null,"errorMessage":"bytes array is null","messagePattern":"bytes array is null","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java","lineNumber":102,"sourceCode":"    }\n\n    @Override\n    public CmmnDeploymentBuilder addString(String resourceName, String text) {\n        if (text == null) {\n            throw new FlowableException(\"text is null\");\n        }\n\n        CmmnResourceEntity resource = resourceEntityManager.create();\n        resource.setName(resourceName);\n        resource.setBytes(text.getBytes(StandardCharsets.UTF_8));\n        deployment.addResource(resource);\n        return this;\n    }\n    \n    @Override\n    public CmmnDeploymentBuilder addBytes(String resourceName, byte[] bytes) {\n        if (bytes == null) {\n            throw new FlowableException(\"bytes array 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 addZipInputStream(ZipInputStream zipInputStream) {\n        try {\n            ZipEntry entry = zipInputStream.getNextEntry();\n            while (entry != null) {\n                if (!entry.isDirectory()) {\n                    String entryName = entry.getName();\n                    byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);\n                    CmmnResourceEntity resource = resourceEntityManager.create();","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/repository/CmmnDeploymentBuilderImpl.java#L84-L120","documentation":"FlowableException thrown by CmmnDeploymentBuilderImpl.addBytes when the bytes parameter is null. The resource entity needs a byte array to store, so null is rejected immediately. Fail-fast validation for programmatic deployment building.","triggerScenarios":"Calling addBytes(resourceName, null) or passing a byte[] variable produced by a read/conversion step that returned null (failed serialization, missing file conversion, unassigned field).","commonSituations":"Converting a model to bytes via code that silently returns null on failure, loading binary resources from storage that returned null, test fixtures with uninitialized arrays.","solutions":["Ensure the byte[] is non-null and populated before calling addBytes","Check the code producing the byte array for silent null returns on failure","Initialize or load the bytes explicitly and fail early with your own message"],"exampleFix":"// before\nbyte[] modelBytes = toBytes(model); // may return null\nbuilder.addBytes(\"model.cmmn.xml\", modelBytes);\n// after\nbyte[] modelBytes = toBytes(model);\nObjects.requireNonNull(modelBytes, \"model bytes must not be null\");\nbuilder.addBytes(\"model.cmmn.xml\", modelBytes);","handlingStrategy":"validation","validationCode":"if (bytes == null || bytes.length == 0) { throw new IllegalArgumentException(\"Resource bytes must be non-empty: \" + resourceName); }","typeGuard":"static boolean hasContent(byte[] b) { return b != null && b.length > 0; }","tryCatchPattern":"try {\n    builder.addBytes(resourceName, bytes);\n} catch (FlowableException e) {\n    if (\"bytes array is null\".equals(e.getMessage())) {\n        throw new IllegalArgumentException(\"Missing byte content for \" + resourceName, e);\n    }\n    throw e;\n}","preventionTips":["Require serialization helpers to throw on failure rather than return null","Use Optional<byte[]> or explicit exceptions in byte-producing code","Check byte[] length, not just null, to also catch empty content","Unit-test the bytes-producing step independently of Flowable"],"tags":["null-check","argument-validation","deployment","cmmn"],"backgroundTag":"null-argument","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"}