From 34a6df73e228433985d941b1a805a8bece5b8eed Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Mon, 26 Aug 2024 15:24:26 +0700 Subject: [PATCH] grader: dont crash when zip file contains empty files (#659) --- .../java/judgels/gabriel/helpers/OutputOnlyEvaluator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/OutputOnlyEvaluator.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/OutputOnlyEvaluator.java index 7072bdbe4..313e82839 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/OutputOnlyEvaluator.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/helpers/OutputOnlyEvaluator.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Paths; +import java.util.zip.ZipException; import judgels.fs.FileSystem; import judgels.fs.local.LocalFileSystem; import judgels.gabriel.api.EvaluationException; @@ -33,7 +34,12 @@ public void prepare(Scorer scorer, File evaluationDir, File sourceFile) throws P try { fs.uploadZippedFiles(Paths.get(""), new FileInputStream(sourceFile)); } catch (RuntimeException | FileNotFoundException e) { - throw new PreparationException(e); + if (e.getCause() instanceof ZipException) { + // Pass through. + // A possible cause is when zip file contains empty output file(s). + } else { + throw new PreparationException(e); + } } for (File file : FileUtils.listFiles(evaluationDir, null, false)) {