{"record":{"id":"b4ae8498e5f20650","repo":"flowable/flowable-engine","slug":"problem-reading-zip-input-stream-b4ae84","errorCode":null,"errorMessage":"problem reading zip input stream","messagePattern":"problem reading zip input stream","errorType":"exception","errorClass":"org.activiti.engine.ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java","lineNumber":103,"sourceCode":"    }\n\n    @Override\n    public DeploymentBuilder 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                    ResourceEntity resource = new ResourceEntity();\n                    resource.setName(entryName);\n                    resource.setBytes(bytes);\n                    deployment.addResource(resource);\n                }\n                entry = zipInputStream.getNextEntry();\n            }\n        } catch (Exception e) {\n            throw new ActivitiException(\"problem reading zip input stream\", e);\n        }\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder addBpmnModel(String resourceName, BpmnModel bpmnModel) {\n        BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();\n        String bpmn20Xml = new String(bpmnXMLConverter.convertToXML(bpmnModel), StandardCharsets.UTF_8);\n        addString(resourceName, bpmn20Xml);\n        return this;\n    }\n\n    @Override\n    public DeploymentBuilder name(String name) {\n        deployment.setName(name);\n        return this;\n    }\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/repository/DeploymentBuilderImpl.java#L85-L121","documentation":"addZipInputStream iterates zip entries and adds each as a deployment resource. Any exception while reading the stream (corrupt archive, truncated download, closed stream, unsupported compression) is caught and rethrown as an ActivitiException wrapping the original cause.","triggerScenarios":"Calling DeploymentBuilder.addZipInputStream(ZipInputStream) with a stream whose underlying data is corrupted, truncated, or fails mid-read (IOException or any other Exception inside the entry loop).","commonSituations":"Uploading a bar/zip file that was truncated during transfer, a zip built with an unsupported algorithm, passing a stream that was already fully consumed, network interruption while streaming a remote archive.","solutions":["Inspect the wrapped cause exception (e.getCause()) to see the underlying IO or zip error.","Validate the zip/bar archive opens with a normal unzip tool before deploying.","Ensure the stream is fresh and readable at call time; do not reuse a consumed stream.","Re-download or regenerate the archive; verify file integrity (size, checksum) after transfer."],"exampleFix":"// before\nbuilder.addZipInputStream(new ZipInputStream(new FileInputStream(zipFile)));\n// after\ntry (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile)))) {\n    builder.addZipInputStream(zis);\n} catch (ActivitiException e) {\n    logger.error(\"bad archive: \" + e.getCause(), e);\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"File f = new File(zipPath);\nif (!f.isFile() || f.length() == 0) throw new IllegalStateException(\"archive missing or empty: \" + zipPath);","typeGuard":null,"tryCatchPattern":"try {\n    builder.addZipInputStream(zis);\n} catch (ActivitiException e) {\n    logger.error(\"zip deploy failed: \" + e.getCause(), e);\n    throw new DeploymentException(e);\n}","preventionTips":["Verify archives with checksum after transfer.","Open the zip once with ZipFile to validate before streaming it.","Never reuse a consumed ZipInputStream."],"tags":["deployment","zip","io"],"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-14T21:17:11.552Z"}