{"record":{"id":"2ccc82da618a9f8c","repo":"quarkusio/quarkus","slug":"error-closing-file","errorCode":null,"errorMessage":"Error closing file: ","messagePattern":"Error closing file: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java","lineNumber":236,"sourceCode":"                deployResource(deploymentTarget, client, i, optionalResourceDefinitions);\n                log.info(\"Applied: \" + i.getKind() + \" \" + i.getMetadata().getName() + \".\");\n            });\n\n            printExposeInformation(client, list, openshiftConfig, applicationInfo);\n\n            HasMetadata m = list.getItems().stream()\n                    .filter(r -> deploymentTarget.getDeploymentResourceKind().matches(r))\n                    .findFirst().orElseThrow(() -> new IllegalStateException(\n                            \"No \" + deploymentTarget.getDeploymentResourceKind() + \" found under: \"\n                                    + manifest.getAbsolutePath()));\n            return new DeploymentResultBuildItem(m.getMetadata().getName(), m.getMetadata().getLabels());\n        } catch (FileNotFoundException e) {\n            throw new IllegalStateException(\"Can't find generated kubernetes manifest: \" + manifest.getAbsolutePath());\n        } catch (KubernetesClientException e) {\n            KubernetesClientErrorHandler.handle(e);\n            throw e;\n        } catch (IOException e) {\n            throw new RuntimeException(\"Error closing file: \" + manifest.getAbsolutePath());\n        }\n\n    }\n\n    private void deployResource(DeploymentTargetEntry deploymentTarget, KubernetesClient client, HasMetadata metadata,\n            List<KubernetesOptionalResourceDefinitionBuildItem> optionalResourceDefinitions) {\n        var r = findResource(client, metadata);\n        Optional<HasMetadata> existing = Optional.ofNullable(client.resource(metadata).get());\n        if (shouldDeleteExisting(deploymentTarget, metadata)) {\n            deleteResource(metadata, r);\n        }\n\n        try {\n            switch (deploymentTarget.getDeployStrategy()) {\n                case Create:\n                    r.create();\n                    break;\n                case Replace:","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java#L218-L254","documentation":"While finishing deployment, deploy() closes the reader over the generated manifest; if closing throws IOException it is rethrown as RuntimeException 'Error closing file: <path>'. This indicates an I/O problem releasing the manifest file handle rather than a deployment logic problem.","triggerScenarios":"The try-with-resources/finally close of the manifest file reader in deploy() throws IOException — e.g. disk/descriptor issues while the file handle is released.","commonSituations":"Filesystem issues (full disk, NFS stalls, container volume unmounted) during builds; file being modified/removed concurrently by another process while being read; rare JDK-level I/O failures.","solutions":["Retry the build; transient filesystem contention is the usual cause","Ensure no other process deletes/replaces target/kubernetes manifests while the build runs (parallel builds, IDE cleaners)","Check disk space and filesystem health on the machine running the build"],"exampleFix":"// before\nmvn package -Dquarkus.kubernetes.deploy=true &  mvn clean ...\n// after (avoid concurrent access to target/)\nmvn clean package -Dquarkus.kubernetes.deploy=true","handlingStrategy":"try-catch","validationCode":"if (!java.nio.file.Files.isReadable(manifestPath)) throw new IllegalStateException(\"manifest not readable: \" + manifestPath);","typeGuard":null,"tryCatchPattern":"try { deploy(manifest); } catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Error closing file\")) {\n        LOG.warnf(\"I/O issue closing %s — check disk/filesystem and retry\", manifestPath);\n    }\n    throw e;\n}","preventionTips":["Avoid parallel builds or IDE cleaners touching target/ during deploy","Monitor disk space and filesystem health on build machines","Retry transient I/O failures once before investigating deeper"],"tags":["kubernetes","io-exception","file-close","deploy"],"backgroundTag":"file-close-io-error","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}