aboutsummaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2021-12-01 08:44:02 +0100
committerGitHub <noreply@github.com>2021-12-01 08:44:02 +0100
commitff8465b785fb92c7f9b69771a06106b38bba9181 (patch)
treeb1727ba109e3d54e1a2dbf2782483019ddff075b /document
parentd465d33318ce05af45a2925c73d527218e46864f (diff)
parent17adf78513ef850f9a20638bf06d8ea32ca35d4a (diff)
Merge pull request #20306 from vespa-engine/arnej/avoid-using-temp-data-types
Arnej/avoid using temp data types
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManager.java96
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java284
-rw-r--r--document/src/test/java/com/yahoo/document/DocInDocTestCase.java4
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentTestCase.java3
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java7
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java4
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java4
-rwxr-xr-xdocument/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java4
-rw-r--r--document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java4
-rwxr-xr-xdocument/src/test/java/com/yahoo/document/annotation/SystemTestCase.java4
-rw-r--r--document/src/test/java/com/yahoo/document/serialization/SerializeAnnotationsTestCase.java6
-rw-r--r--document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java3
12 files changed, 198 insertions, 225 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManager.java b/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
index 55320eb8501..80ceac457b9 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManager.java
@@ -190,6 +190,12 @@ public class DocumentTypeManager {
@SuppressWarnings("deprecation")
void registerSingleType(DataType type) {
if (type instanceof TensorDataType) return; // built-in dynamic: Created on the fly
+ if (type instanceof TemporaryDataType) {
+ throw new IllegalArgumentException("TemporaryDataType no longer supported: " + type);
+ }
+ if (type instanceof TemporaryStructuredDataType) {
+ throw new IllegalArgumentException("TemporaryStructuredDataType no longer supported: " + type);
+ }
if (dataTypes.containsKey(type.getId())) {
DataType existingType = dataTypes.get(type.getId());
if (((type instanceof TemporaryDataType) || (type instanceof TemporaryStructuredDataType))
@@ -310,96 +316,6 @@ public class DocumentTypeManager {
return annotationTypeRegistry;
}
- void replaceTemporaryTypes() {
- for (DataType type : dataTypes.values()) {
- List<DataType> seenStructs = new LinkedList<>();
- replaceTemporaryTypes(type, seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypes(DataType type, List<DataType> seenStructs) {
- if (type instanceof WeightedSetDataType) {
- replaceTemporaryTypesInWeightedSet((WeightedSetDataType) type, seenStructs);
- } else if (type instanceof MapDataType) {
- replaceTemporaryTypesInMap((MapDataType) type, seenStructs);
- } else if (type instanceof CollectionDataType) {
- replaceTemporaryTypesInCollection((CollectionDataType) type, seenStructs);
- } else if (type instanceof StructDataType) {
- replaceTemporaryTypesInStruct((StructDataType) type, seenStructs);
- } else if (type instanceof PrimitiveDataType) {
- //OK because these types are always present
- } else if (type instanceof AnnotationReferenceDataType) {
- //OK because this type is always present
- } else if (type instanceof DocumentType) {
- //OK because this type is always present
- } else if (type instanceof TensorDataType) {
- //OK because this type is always present
- } else if (type instanceof ReferenceDataType) {
- replaceTemporaryTypeInReference((ReferenceDataType) type);
- } else if (type instanceof TemporaryDataType) {
- throw new IllegalStateException("TemporaryDataType registered in DocumentTypeManager, BUG!!");
- } else {
- log.warning("Don't know how to replace temporary data types in " + type);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInStruct(StructDataType structDataType, List<DataType> seenStructs) {
- seenStructs.add(structDataType);
- for (Field field : structDataType.getFieldsThisTypeOnly()) {
- DataType fieldType = field.getDataType();
- if (fieldType instanceof TemporaryDataType) {
- field.setDataType(getDataType(fieldType.getCode(), ((TemporaryDataType)fieldType).getDetailedType()));
- } else {
- if (!seenStructs.contains(fieldType)) {
- replaceTemporaryTypes(fieldType, seenStructs);
- }
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypeInReference(ReferenceDataType referenceDataType) {
- if (referenceDataType.getTargetType() instanceof TemporaryStructuredDataType) {
- referenceDataType.setTargetType((DocumentType) getDataType(referenceDataType.getTargetType().getId()));
- }
- // TODO should we recursively invoke replaceTemporaryTypes for the target type? It should only ever be a doc type
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInCollection(CollectionDataType collectionDataType, List<DataType> seenStructs) {
- if (collectionDataType.getNestedType() instanceof TemporaryDataType) {
- collectionDataType.setNestedType(getDataType(collectionDataType.getNestedType().getCode(), ""));
- } else {
- replaceTemporaryTypes(collectionDataType.getNestedType(), seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInMap(MapDataType mapDataType, List<DataType> seenStructs) {
- if (mapDataType.getValueType() instanceof TemporaryDataType) {
- mapDataType.setValueType(getDataType(mapDataType.getValueType().getCode(), ""));
- } else {
- replaceTemporaryTypes(mapDataType.getValueType(), seenStructs);
- }
-
- if (mapDataType.getKeyType() instanceof TemporaryDataType) {
- mapDataType.setKeyType(getDataType(mapDataType.getKeyType().getCode(), ""));
- } else {
- replaceTemporaryTypes(mapDataType.getKeyType(), seenStructs);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void replaceTemporaryTypesInWeightedSet(WeightedSetDataType weightedSetDataType, List<DataType> seenStructs) {
- if (weightedSetDataType.getNestedType() instanceof TemporaryDataType) {
- weightedSetDataType.setNestedType(getDataType(weightedSetDataType.getNestedType().getCode(), ""));
- } else {
- replaceTemporaryTypes(weightedSetDataType.getNestedType(), seenStructs);
- }
- }
-
public void shutdown() {
if (subscriber!=null) subscriber.close();
}
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
index c545b6f1491..1f9e494aa29 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
@@ -76,141 +76,199 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
}
- private void apply(DocumentmanagerConfig config) {
- setupAnnotationTypesWithoutPayloads(config);
- setupAnnotationRefTypes(config);
- setupDatatypesWithRetry(config);
- addStructInheritance(config);
- addAnnotationTypePayloads(config);
- addAnnotationTypeInheritance(config);
- manager.replaceTemporaryTypes();
- }
+ private Map<Integer, DataType> typesById = new HashMap<>();
+ private Map<String, DataType> typesByName = new HashMap<>();
+ private Map<Integer, DocumentmanagerConfig.Datatype> configMap = new HashMap<>();
- private void setupDatatypesWithRetry(DocumentmanagerConfig config) {
- var tmp = new ArrayList<DocumentmanagerConfig.Datatype>(config.datatype());
- log.log(Level.FINE, "Configuring document manager with " + tmp.size() + " data types.");
- while (! tmp.isEmpty()) {
- int oldSz = tmp.size();
- var failed = new ArrayList<DocumentmanagerConfig.Datatype>();
- for (DocumentmanagerConfig.Datatype thisDataType : tmp) {
- int id = thisDataType.id();
- try {
- registerTypeIdMapping(thisDataType, id);
- } catch (IllegalArgumentException e) {
- failed.add(thisDataType);
- }
- }
- tmp = failed;
- if (tmp.size() == oldSz) {
- throw new IllegalArgumentException("No progress registering datatypes");
- }
+ private void inProgress(DataType type) {
+ var old = typesById.put(type.getId(), type);
+ if (old != null) {
+ throw new IllegalArgumentException("Multiple types with same id: "+old+" -> "+type);
+ }
+ old = typesByName.put(type.getName(), type);
+ if (old != null) {
+ log.warning("Multiple types with same name: "+old+" -> "+type);
}
}
- private void registerTypeIdMapping(DocumentmanagerConfig.Datatype thisDataType, int id) {
- for (var o : thisDataType.arraytype()) {
- registerArrayType(id, o);
- }
- for (var o : thisDataType.maptype()) {
- registerMapType(id, o);
- }
- for (var o : thisDataType.weightedsettype()) {
- registerWeightedSetType(id, o);
- }
- for (var o : thisDataType.structtype()) {
- registerStructType(id, o);
- }
- for (var o : thisDataType.documenttype()) {
- registerDocumentType(o);
+ private void startStructsAndDocs(DocumentmanagerConfig config) {
+ for (var thisDataType : config.datatype()) {
+ for (var o : thisDataType.structtype()) {
+ int id = thisDataType.id();
+ StructDataType type = new StructDataType(id, o.name());
+ inProgress(type);
+ configMap.remove(id);
+ }
}
- for (var o : thisDataType.referencetype()) {
- registerReferenceType(id, o);
+ for (var thisDataType : config.datatype()) {
+ for (var doc : thisDataType.documenttype()) {
+ int id = thisDataType.id();
+ StructDataType header = (StructDataType) typesById.get(doc.headerstruct());
+ var importedFields = doc.importedfield().stream()
+ .map(f -> f.name())
+ .collect(Collectors.toUnmodifiableSet());
+ DocumentType type = new DocumentType(doc.name(), header, importedFields);
+ if (id != type.getId()) {
+ // really old stuff, should rewrite tests using this:
+ int alt = (doc.name()+"."+doc.version()).hashCode();
+ if (id == alt) {
+ typesById.put(id, type);
+ } else {
+ throw new IllegalArgumentException("Document type "+doc.name()+
+ " wanted id "+id+" but got "+
+ type.getId()+", alternative id was: "+alt);
+ }
+ }
+ inProgress(type);
+ configMap.remove(id);
+ }
}
}
- private void registerArrayType(int id, DocumentmanagerConfig.Datatype.Arraytype array) {
- DataType nestedType = manager.getDataType(array.datatype(), "");
+ private DataType createArrayType(int id, DocumentmanagerConfig.Datatype.Arraytype array) {
+ DataType nestedType = getOrCreateType(array.datatype());
ArrayDataType type = new ArrayDataType(nestedType, id);
- manager.register(type);
+ inProgress(type);
+ return type;
}
- private void registerMapType(int id, DocumentmanagerConfig.Datatype.Maptype map) {
- DataType keyType = manager.getDataType(map.keytype(), "");
- DataType valType = manager.getDataType(map.valtype(), "");
+ private DataType createMapType(int id, DocumentmanagerConfig.Datatype.Maptype map) {
+ DataType keyType = getOrCreateType(map.keytype());
+ DataType valType = getOrCreateType(map.valtype());
MapDataType type = new MapDataType(keyType, valType, id);
- manager.register(type);
+ inProgress(type);
+ return type;
}
- private void registerWeightedSetType(int id, DocumentmanagerConfig.Datatype.Weightedsettype wset) {
- DataType nestedType = manager.getDataType(wset.datatype(), "");
- WeightedSetDataType type = new WeightedSetDataType(
- nestedType, wset.createifnonexistant(), wset.removeifzero(), id);
- manager.register(type);
+ private DataType createWeightedSetType(int id, DocumentmanagerConfig.Datatype.Weightedsettype wset) {
+ DataType nestedType = getOrCreateType(wset.datatype());
+ WeightedSetDataType type =
+ new WeightedSetDataType(nestedType, wset.createifnonexistant(), wset.removeifzero(), id);
+ inProgress(type);
+ return type;
}
- private void registerDocumentType(DocumentmanagerConfig.Datatype.Documenttype doc) {
- StructDataType header = (StructDataType) manager.getDataType(doc.headerstruct(), "");
- var importedFields = doc.importedfield().stream()
- .map(f -> f.name())
- .collect(Collectors.toUnmodifiableSet());
- DocumentType type = new DocumentType(doc.name(), header, importedFields);
- for (var parent : doc.inherits()) {
- DataTypeName name = new DataTypeName(parent.name());
- DocumentType parentType = manager.getDocumentType(name);
- if (parentType == null) {
- throw new IllegalArgumentException("Could not find document type '" + name + "'.");
- }
- type.inherit(parentType);
+ private DataType createReferenceType(int id, DocumentmanagerConfig.Datatype.Referencetype refType) {
+ int targetId = refType.target_type_id();
+ DocumentType targetDocType = (DocumentType) typesById.get(targetId);
+ var type = new ReferenceDataType(targetDocType, id);
+ inProgress(type);
+ return type;
+ }
+
+
+ private DataType getOrCreateType(int id) {
+ if (typesById.containsKey(id)) {
+ return typesById.get(id);
+ }
+ var config = configMap.remove(id);
+ if (config == null) {
+ return manager.getDataType(id);
+ }
+ assert(id == config.id());
+ for (var o : config.arraytype()) {
+ return createArrayType(id, o);
}
- Map<String, Collection<String>> fieldSets = new HashMap<>(doc.fieldsets().size());
- for (Map.Entry<String, DocumentmanagerConfig.Datatype.Documenttype.Fieldsets> entry: doc.fieldsets().entrySet()) {
- fieldSets.put(entry.getKey(), entry.getValue().fields());
+ for (var o : config.maptype()) {
+ return createMapType(id, o);
}
- type.addFieldSets(fieldSets);
- manager.register(type);
+ for (var o : config.weightedsettype()) {
+ return createWeightedSetType(id, o);
+ }
+ for (var o : config.referencetype()) {
+ return createReferenceType(id, o);
+ }
+ throw new IllegalArgumentException("Could not create type from config: "+config);
}
- private void registerStructType(int id, DocumentmanagerConfig.Datatype.Structtype struct) {
- StructDataType type = new StructDataType(id, struct.name());
+ private void createRemainingTypes(DocumentmanagerConfig config) {
+ for (var thisDataType : config.datatype()) {
+ int id = thisDataType.id();
+ var type = getOrCreateType(id);
+ assert(type != null);
+ }
+ }
- for (var field : struct.field()) {
- DataType fieldType = (field.datatype() == id)
- ? manager.getDataTypeAndReturnTemporary(field.datatype(), field.detailedtype())
- : manager.getDataType(field.datatype(), field.detailedtype());
+ private void fillStructs(DocumentmanagerConfig config) {
+ for (var thisDataType : config.datatype()) {
+ for (var struct : thisDataType.structtype()) {
+ int id = thisDataType.id();
+ StructDataType type = (StructDataType) typesById.get(id);
+ for (var parent : struct.inherits()) {
+ var parentStruct = (StructDataType) typesByName.get(parent.name());
+ type.inherit(parentStruct);
+ }
+ for (var field : struct.field()) {
+ if (field.datatype() == id) {
+ log.fine("Self-referencing struct "+struct.name()+" field: "+field);
+ }
+ DataType fieldType = typesById.get(field.datatype());
+ if (fieldType == null) {
+ fieldType = manager.getDataType(field.datatype(), field.detailedtype());
+ }
+ if (field.id().size() == 1) {
+ type.addField(new Field(field.name(), field.id().get(0).id(), fieldType));
+ } else {
+ type.addField(new Field(field.name(), fieldType));
+ }
+ }
+ }
+ }
+ }
- if (field.id().size() == 1) {
- type.addField(new Field(field.name(), field.id().get(0).id(), fieldType));
- } else {
- type.addField(new Field(field.name(), fieldType));
+ private void fillDocuments(DocumentmanagerConfig config) {
+ for (var thisDataType : config.datatype()) {
+ for (var doc : thisDataType.documenttype()) {
+ int id = thisDataType.id();
+ DocumentType type = (DocumentType) typesById.get(id);
+ for (var parent : doc.inherits()) {
+ DocumentType parentType = (DocumentType) typesByName.get(parent.name());
+ if (parentType == null) {
+ DataTypeName name = new DataTypeName(parent.name());
+ parentType = manager.getDocumentType(name);
+ }
+ if (parentType == null) {
+ throw new IllegalArgumentException("Could not find parent document type '" + parent.name() + "'.");
+ }
+ type.inherit(parentType);
+ }
+ Map<String, Collection<String>> fieldSets = new HashMap<>(doc.fieldsets().size());
+ for (Map.Entry<String, DocumentmanagerConfig.Datatype.Documenttype.Fieldsets> entry: doc.fieldsets().entrySet()) {
+ fieldSets.put(entry.getKey(), entry.getValue().fields());
+ }
+ type.addFieldSets(fieldSets);
}
}
- /*
- if (type.equals(PositionDataType.INSTANCE)) {
- if (this.usev8geopositions) {
- // do something special here
+ }
+
+ private void splitConfig(DocumentmanagerConfig config) {
+ for (var dataTypeConfig : config.datatype()) {
+ int id = dataTypeConfig.id();
+ var old = configMap.put(id, dataTypeConfig);
+ if (old != null) {
+ throw new IllegalArgumentException
+ ("Multiple configs for id "+id+" first: "+old+" second: "+dataTypeConfig);
}
}
- */
- manager.register(type);
}
- @SuppressWarnings("deprecation")
- private void registerReferenceType(int id, DocumentmanagerConfig.Datatype.Referencetype refType) {
- ReferenceDataType referenceType;
- if (manager.hasDataType(refType.target_type_id())) {
- DocumentType targetDocType = (DocumentType)manager.getDataType(refType.target_type_id());
- referenceType = new ReferenceDataType(targetDocType, id);
- } else {
- TemporaryStructuredDataType temporaryTargetType = TemporaryStructuredDataType.createById(refType.target_type_id());
- referenceType = new ReferenceDataType(temporaryTargetType, id);
+ private void apply(DocumentmanagerConfig config) {
+ splitConfig(config);
+ setupAnnotationTypesWithoutPayloads(config);
+ setupAnnotationRefTypes(config);
+ startStructsAndDocs(config);
+ createRemainingTypes(config);
+ fillStructs(config);
+ fillDocuments(config);
+ for (DataType type : typesById.values()) {
+ manager.register(type);
}
- // Note: can't combine the above new-statements, as they call different constructors.
- manager.register(referenceType);
+ addAnnotationTypePayloads(config);
+ addAnnotationTypeInheritance(config);
}
private void setupAnnotationRefTypes(DocumentmanagerConfig config) {
- for (int i = 0; i < config.datatype().size(); i++) {
- DocumentmanagerConfig.Datatype thisDataType = config.datatype(i);
+ for (var thisDataType : config.datatype()) {
int id = thisDataType.id();
for (var annRefType : thisDataType.annotationreftype()) {
AnnotationType annotationType = manager.getAnnotationTypeRegistry().getType(annRefType.annotation());
@@ -218,7 +276,8 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
throw new IllegalArgumentException("Found reference to " + annRefType.annotation() + ", which does not exist!");
}
AnnotationReferenceDataType type = new AnnotationReferenceDataType(annotationType, id);
- manager.register(type);
+ inProgress(type);
+ configMap.remove(id);
}
}
}
@@ -234,7 +293,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
for (DocumentmanagerConfig.Annotationtype annType : config.annotationtype()) {
AnnotationType annotationType = manager.getAnnotationTypeRegistry().getType(annType.id());
DataType payload = manager.getDataType(annType.datatype(), "");
- if (!payload.equals(DataType.NONE)) {
+ if (! payload.equals(DataType.NONE)) {
annotationType.setDataType(payload);
}
}
@@ -251,21 +310,6 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
}
}
- private void addStructInheritance(DocumentmanagerConfig config) {
- for (int i = 0; i < config.datatype().size(); i++) {
- DocumentmanagerConfig.Datatype thisDataType = config.datatype(i);
- int id = thisDataType.id();
- for (var struct : thisDataType.structtype()) {
- StructDataType thisStruct = (StructDataType) manager.getDataType(id, "");
-
- for (var parent : struct.inherits()) {
- StructDataType parentStruct = (StructDataType) manager.getDataType(parent.name());
- thisStruct.inherit(parentStruct);
- }
- }
- }
- }
-
private final boolean usev8geopositions;
private final DocumentTypeManager manager;
}
diff --git a/document/src/test/java/com/yahoo/document/DocInDocTestCase.java b/document/src/test/java/com/yahoo/document/DocInDocTestCase.java
index f5b6b4ea9bf..57972d20509 100644
--- a/document/src/test/java/com/yahoo/document/DocInDocTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocInDocTestCase.java
@@ -21,8 +21,8 @@ public class DocInDocTestCase {
@Test
public void testDocInDoc() {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/documentmanager.docindoc.cfg");
-
+ var sub = DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/documentmanager.docindoc.cfg");
+ sub.close();
Document inner1 = new Document(manager.getDocumentType("docindoc"), "id:inner:docindoc::one");
inner1.setFieldValue("name", new StringFieldValue("Donald Duck"));
inner1.setFieldValue("content", new StringFieldValue("Lives in Duckburg"));
diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTestCase.java
index 144c7d62894..3d7eb49f1f9 100644
--- a/document/src/test/java/com/yahoo/document/DocumentTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentTestCase.java
@@ -95,7 +95,8 @@ public class DocumentTestCase extends DocumentTestCaseBase {
static DocumentTypeManager setUpDocType(String filename) {
DocumentTypeManager dcMan = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(dcMan, filename);
+ var sub = DocumentTypeManagerConfigurer.configure(dcMan, filename);
+ sub.close();
return dcMan;
}
diff --git a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
index 3fa81dd8d5b..4040f3455da 100644
--- a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
@@ -217,8 +217,8 @@ public class DocumentTypeManagerTestCase {
assertNull(banana.getField("newfield"));
assertEquals(new Field("arrayfloat", 9489, new ArrayDataType(DataType.FLOAT, 99)), customtypes.getField("arrayfloat"));
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/document/documentmanager.updated.cfg");
-
+ var sub = DocumentTypeManagerConfigurer.configure(manager, "file:src/test/document/documentmanager.updated.cfg");
+ sub.close();
banana = manager.getDocumentType(new DataTypeName("banana"));
customtypes = manager.getDocumentType(new DataTypeName("customtypes"));
@@ -513,7 +513,8 @@ search annotationsimplicitstruct {
private static DocumentTypeManager createConfiguredManager(String configFilePath) {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, configFilePath);
+ var sub = DocumentTypeManagerConfigurer.configure(manager, configFilePath);
+ sub.close();
return manager;
}
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
index 77f0e1a9c20..fcaf96a788f 100644
--- a/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug4259784TestCase.java
@@ -23,7 +23,9 @@ public class Bug4259784TestCase {
@Test
public void testSerialize() {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4259784.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4259784.cfg");
+ sub.close();
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "id:this:blog::is:a:test");
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
index 7692d2643df..ae730ed8cb3 100644
--- a/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug4261985TestCase.java
@@ -23,7 +23,9 @@ public class Bug4261985TestCase {
@Test
public void testAnnotate() {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4261985.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4261985.cfg");
+ sub.close();
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "id:this:blog::is:a:test");
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java
index dbbe0cdfedf..69003ebd036 100755
--- a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java
@@ -23,7 +23,9 @@ public class Bug4475379TestCase {
@Test
public void testClone() {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.bug4475379.cfg");
+ sub.close();
DocumentType type = manager.getDocumentType("blog");
Document doc = new Document(type, "id:this:blog::is:a:test");
diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java
index 654965d1ee7..3ec858062be 100644
--- a/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java
@@ -19,7 +19,9 @@ public class Bug6394548TestCase {
@Test
public void testSerializeAndDeserializeMultipleAdjacentStructAnnotations() {
DocumentTypeManager manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.6394548.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.6394548.cfg");
+ sub.close();
AnnotationTypeRegistry registry = manager.getAnnotationTypeRegistry();
AnnotationType featureSetType = registry.getType("morty.RICK_FEATURESET");
diff --git a/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java b/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java
index 9978fd1b014..678639c89d9 100755
--- a/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java
+++ b/document/src/test/java/com/yahoo/document/annotation/SystemTestCase.java
@@ -114,7 +114,9 @@ public class SystemTestCase {
@Before
public void setUp() {
manager = new DocumentTypeManager();
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.systemtest.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (manager, "file:src/test/java/com/yahoo/document/annotation/documentmanager.systemtest.cfg");
+ sub.close();
}
@Test
diff --git a/document/src/test/java/com/yahoo/document/serialization/SerializeAnnotationsTestCase.java b/document/src/test/java/com/yahoo/document/serialization/SerializeAnnotationsTestCase.java
index d27a4ed6326..9e58e2540a0 100644
--- a/document/src/test/java/com/yahoo/document/serialization/SerializeAnnotationsTestCase.java
+++ b/document/src/test/java/com/yahoo/document/serialization/SerializeAnnotationsTestCase.java
@@ -44,9 +44,9 @@ public class SerializeAnnotationsTestCase {
@Before
public void setUp() {
- DocumentTypeManagerConfigurer.configure(docMan,
- "file:src/tests/serialization/" +
- "annotation.serialize.test.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure
+ (docMan, "file:src/tests/serialization/annotation.serialize.test.cfg");
+ sub.close();
}
@Test
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
index 769a73d536d..b2fa7014480 100644
--- a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
@@ -36,7 +36,8 @@ public class VespaXMLReaderTestCase {
@Before
public void setUp() {
- DocumentTypeManagerConfigurer.configure(manager, "file:src/test/vespaxmlparser/documentmanager2.cfg");
+ var sub = DocumentTypeManagerConfigurer.configure(manager, "file:src/test/vespaxmlparser/documentmanager2.cfg");
+ sub.close();
}
@Test