quarkusio/quarkus · warning · RuntimeException
Error closing file:
Error message
Error closing file:
What it means
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.
Source
Thrown at extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java:236
deployResource(deploymentTarget, client, i, optionalResourceDefinitions);
log.info("Applied: " + i.getKind() + " " + i.getMetadata().getName() + ".");
});
printExposeInformation(client, list, openshiftConfig, applicationInfo);
HasMetadata m = list.getItems().stream()
.filter(r -> deploymentTarget.getDeploymentResourceKind().matches(r))
.findFirst().orElseThrow(() -> new IllegalStateException(
"No " + deploymentTarget.getDeploymentResourceKind() + " found under: "
+ manifest.getAbsolutePath()));
return new DeploymentResultBuildItem(m.getMetadata().getName(), m.getMetadata().getLabels());
} catch (FileNotFoundException e) {
throw new IllegalStateException("Can't find generated kubernetes manifest: " + manifest.getAbsolutePath());
} catch (KubernetesClientException e) {
KubernetesClientErrorHandler.handle(e);
throw e;
} catch (IOException e) {
throw new RuntimeException("Error closing file: " + manifest.getAbsolutePath());
}
}
private void deployResource(DeploymentTargetEntry deploymentTarget, KubernetesClient client, HasMetadata metadata,
List<KubernetesOptionalResourceDefinitionBuildItem> optionalResourceDefinitions) {
var r = findResource(client, metadata);
Optional<HasMetadata> existing = Optional.ofNullable(client.resource(metadata).get());
if (shouldDeleteExisting(deploymentTarget, metadata)) {
deleteResource(metadata, r);
}
try {
switch (deploymentTarget.getDeployStrategy()) {
case Create:
r.create();
break;
case Replace:View on GitHub (pinned to e1c734241f)
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
Example fix
// before mvn package -Dquarkus.kubernetes.deploy=true & mvn clean ... // after (avoid concurrent access to target/) mvn clean package -Dquarkus.kubernetes.deploy=true
Defensive patterns
Strategy: try-catch
Validate before calling
if (!java.nio.file.Files.isReadable(manifestPath)) throw new IllegalStateException("manifest not readable: " + manifestPath); Try / catch
try { deploy(manifest); } catch (RuntimeException e) {
if (e.getMessage().startsWith("Error closing file")) {
LOG.warnf("I/O issue closing %s — check disk/filesystem and retry", manifestPath);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Can't find generated kubernetes manifest:
- Unable to copy json config file from ${jsonPath} to ${thinJa
- Unable to determine groupId and artifactId of the jar that c
- Build:%s is no longer present!
- Build:%s has no status!
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/2ccc82da618a9f8c.
Report an issue: GitHub.