From 1ff6fcce424328bb99b8eeb89c1df8c5cc4ca60a Mon Sep 17 00:00:00 2001 From: bjormel Date: Tue, 26 Jul 2022 19:09:28 +0200 Subject: Default to empty CompiledQueryProfileRegistry --- .../src/main/java/com/yahoo/application/Application.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'application') diff --git a/application/src/main/java/com/yahoo/application/Application.java b/application/src/main/java/com/yahoo/application/Application.java index 899e9d8675c..5d8123de48f 100644 --- a/application/src/main/java/com/yahoo/application/Application.java +++ b/application/src/main/java/com/yahoo/application/Application.java @@ -82,8 +82,7 @@ public final class Application implements AutoCloseable { this.deletePathWhenClosing = deletePathWhenClosing; contentClusters = ContentCluster.fromPath(path); container = JDisc.fromPath(path, networking, createVespaModel().configModelRepo()); - QueryProfileXMLReader queryProfileXMLReader = new QueryProfileXMLReader(); - compiledQueryProfileRegistry = queryProfileXMLReader.read(path + "/search/query-profiles").compile(); + compiledQueryProfileRegistry = readQueryProfilesFromApplicationPackage(path); } @Beta @@ -128,6 +127,17 @@ public final class Application implements AutoCloseable { return fromApplicationPackage(file.toPath(), networking); } + private CompiledQueryProfileRegistry readQueryProfilesFromApplicationPackage(Path path) { + String queryProfilePath = path + "/search/query-profiles"; + QueryProfileXMLReader queryProfileXMLReader = new QueryProfileXMLReader(); + + File f = new File(queryProfilePath); + if(f.exists() && f.isDirectory()) { + return queryProfileXMLReader.read(queryProfilePath).compile(); + } + return CompiledQueryProfileRegistry.empty; + } + private VespaModel createVespaModel() { try { List modelImporters = List.of(new VespaImporter(), -- cgit v1.2.3