From 3ab5867fd0b9910151d9c674e43d64c75be0c07b Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Thu, 2 Sep 2021 16:43:22 +0200 Subject: [PATCH] More descriptive error messages for unsupported Jandex storage format versions --- .../java/io/quarkus/deployment/index/IndexingUtil.java | 7 ++++++- .../main/java/io/quarkus/test/common/TestClassIndexer.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java index bf57c34763c83..84c056ff863ea 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java @@ -21,6 +21,7 @@ import org.jboss.jandex.IndexReader; import org.jboss.jandex.IndexView; import org.jboss.jandex.Indexer; +import org.jboss.jandex.UnsupportedVersion; import org.jboss.logging.Logger; import io.quarkus.deployment.util.IoUtil; @@ -61,7 +62,11 @@ public static Index indexJar(File file, Set removed) throws IOException file); return indexJar(jarFile, removed); } else { - return reader.read(); + try { + return reader.read(); + } catch (UnsupportedVersion e) { + throw new UnsupportedVersion("Can't read Jandex index from " + file + ": " + e.getMessage()); + } } } } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/TestClassIndexer.java b/test-framework/common/src/main/java/io/quarkus/test/common/TestClassIndexer.java index c0f39e31a29a7..c278c35f2ff72 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/TestClassIndexer.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/TestClassIndexer.java @@ -20,6 +20,7 @@ import org.jboss.jandex.IndexReader; import org.jboss.jandex.IndexWriter; import org.jboss.jandex.Indexer; +import org.jboss.jandex.UnsupportedVersion; public final class TestClassIndexer { @@ -60,6 +61,8 @@ public static Index readIndex(Class testClass) { if (path.toFile().exists()) { try (FileInputStream fis = new FileInputStream(path.toFile())) { return new IndexReader(fis).read(); + } catch (UnsupportedVersion e) { + throw new UnsupportedVersion("Can't read Jandex index from " + path + ": " + e.getMessage()); } catch (IOException e) { // be lenient since the error is recoverable return indexTestClasses(testClass);