in spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppResourceSpecFactory.java [104:122]
private static void deleteLocalFileFromPathKey(
Map<String, String> confOverrides, String pathKey) {
Optional<File> localFile = Optional.empty();
boolean deleted = false;
try {
localFile = getLocalFileFromPathKey(confOverrides, pathKey);
if (localFile.isPresent() && localFile.get().exists() && localFile.get().isFile()) {
deleted = localFile.get().delete();
} else {
log.warn("Local temp file not found at {}", pathKey);
}
} catch (Throwable t) {
log.warn("Failed to delete temp file. Attempting delete upon exit.", t);
} finally {
if (!deleted && localFile.isPresent() && localFile.get().exists()) {
localFile.get().deleteOnExit();
}
}
}