diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java index 3b4b00acf86eb02ee902198ce597275c4c148695..26a16ea8b9a3320a7d2d00f1c31f6c93abc75822 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java @@ -385,9 +385,13 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { for (String tenant : tenantList) { String id = tenant + ":" + schemaId; String partitionKey = createSchemaInfoPartitionKey(schemaKindToSchemaIdentity(schemaId)); - Boolean exists = cosmosStore.findItem(tenant, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); - if (exists) { - return false; + try { + Boolean exists = cosmosStore.findItem(tenant, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); + if (exists) { + return false; + } + } catch (AppException ex) { + log.warning(String.format("Error occurred while performing uniqueness check in tenant '%s'", tenant), ex); } } return true; diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java index 053c260ca02c8f6564ffe00917ad874a8d14b118..ef80a0f222a42256a2922629357006ecf0126f44 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java @@ -256,6 +256,31 @@ public class AzureSchemaInfoStoreTest { } } + @Test + public void testIsUnique_ApplicationException() throws ApplicationException { + TenantInfo tenant1 = new TenantInfo(); + tenant1.setName(commonTenantId); + tenant1.setDataPartitionId(commonTenantId); + TenantInfo tenant2 = new TenantInfo(); + tenant2.setName(dataPartitionId); + tenant2.setDataPartitionId(dataPartitionId); + Collection tenants = Lists.newArrayList(tenant1, tenant2); + when(this.tenantFactory.listTenantInfo()).thenReturn(tenants); + Optional cosmosItem = Optional.of(schemaInfoDoc); + + // An error is encountered while checking uniqueness in one tenant. + doThrow(AppException.class) + .when(cosmosStore) + .findItem( + eq(dataPartitionId), + any(), + any(), + eq(dataPartitionId + ":" + schemaId), + eq(partitionKey), + any()); + assertTrue(schemaInfoStore.isUnique(schemaId, commonTenantId)); + } + @Test public void testIsUnique_True() throws ApplicationException {