summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-10-15 15:41:46 +0200
committerJon Bratseth <bratseth@gmail.com>2021-10-15 15:41:46 +0200
commit8ad977890fefb1f4cf1b118ec7e4b4d05a5b7b5f (patch)
tree783189f814e413ddbe90d053f5172d8acfb8fb1e
parent22d198fc9df6578ee89030fe490e3dc6d9cebe40 (diff)
Warn don't throw
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/Search.java4
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java17
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java8
4 files changed, 21 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java
index b22c64f4882..415fcd1d34e 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java
@@ -670,9 +670,9 @@ public class Search implements ImmutableSearch {
return this;
}
- public void validate() {
+ public void validate(DeployLogger logger) {
for (var summary : summaries.values())
- summary.validate();
+ summary.validate(logger);
}
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java
index 6056ca49abf..0f7ead43868 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java
@@ -223,7 +223,7 @@ public class SearchBuilder {
if (isBuilt) throw new IllegalStateException("Model already built");
if (validate)
- searchList.forEach(search -> search.validate());
+ searchList.forEach(search -> search.validate(deployLogger));
List<Search> built = new ArrayList<>();
List<SDDocumentType> sdocs = new ArrayList<>();
diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java
index 8d0661ba8d3..23c1a48b6fe 100644
--- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java
+++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java
@@ -1,12 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.documentmodel;
+import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.searchdefinition.Search;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.logging.Level;
/**
* A document summary definition - a list of summary fields.
@@ -117,11 +119,18 @@ public class DocumentSummary extends FieldView {
return "document summary '" + getName() + "'";
}
- public void validate() {
+ public void validate(DeployLogger logger) {
if (inherited != null) {
- if ( ! owner.getSummaries().containsKey(inherited))
- throw new IllegalArgumentException(this + " inherits " + inherited + " but this" +
- " is not present in " + owner);
+ if ( ! owner.getSummaries().containsKey(inherited)) {
+ logger.log(Level.WARNING,
+ this + " inherits " + inherited + " but this" + " is not present in " + owner);
+ logger.logApplicationPackage(Level.WARNING,
+ this + " inherits " + inherited + " but this" + " is not present in " + owner);
+ // TODO: When safe, replace the above by
+ // throw new IllegalArgumentException(this + " inherits " + inherited + " but this" +
+ // " is not present in " + owner);
+ // ... and update SummaryTestCase.testValidationOfInheritedSummary
+ }
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
index d871a863dcd..35a775d7ad5 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
@@ -228,11 +228,13 @@ public class SummaryTestCase {
"}");
DeployLoggerStub logger = new DeployLoggerStub();
SearchBuilder.createFromStrings(logger, schema);
- fail("Expected failure");
+ assertEquals("document summary 'test_summary' inherits nonesuch but this is not present in schema 'test'",
+ logger.entries.get(0).message);
+ // fail("Expected failure");
}
catch (IllegalArgumentException e) {
- assertEquals("document summary 'test_summary' inherits nonesuch but this is not present in schema 'test'",
- e.getMessage());
+ // assertEquals("document summary 'test_summary' inherits nonesuch but this is not present in schema 'test'",
+ // e.getMessage());
}
}