Skip to content

Commit 1c79d89

Browse files
committed
[6044] Properly catch ElasticsearchException
Bug: #6044 Signed-off-by: Gwendal Daniel <gwendal.daniel@obeosoft.com>
1 parent b7ebc9b commit 1c79d89

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ The node action icons are now a little smaller and only appear after the node ha
259259
- https://github.com/eclipse-sirius/sirius-web/issues/5910[#5910] [diagram] Preserve relative layout while dropping multi nodes.
260260
- https://github.com/eclipse-sirius/sirius-web/issues/6060[#6060] [diagram] Add a new edge marker named _ClosedArrowWith4Dots_ which is very similar to the existing _ClosedArrowWithDots_.
261261
The only difference is that this new marker has a second range of two dots after the first range.
262+
- https://github.com/eclipse-sirius/sirius-web/issues/6044[#6044] [sirius-web] Properly catch `ElasticsearchException`
262263

263264

264265

packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/elasticsearch/services/DefaultIndexCreationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.stereotype.Service;
2424

2525
import co.elastic.clients.elasticsearch.ElasticsearchClient;
26+
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
2627

2728
/**
2829
* The default implementation that creates the index for an editing context.
@@ -65,7 +66,7 @@ public boolean createIndex(String editingContextId) {
6566
textPropertyBuilder.index(false)))));
6667
indexCreated = true;
6768
}
68-
} catch (IOException exception) {
69+
} catch (IOException | ElasticsearchException exception) {
6970
this.logger.warn("An error occurred while creating the index", exception);
7071
}
7172
}

packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/elasticsearch/services/DefaultIndexDeletionService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.stereotype.Service;
2323

2424
import co.elastic.clients.elasticsearch.ElasticsearchClient;
25+
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
2526

2627
/**
2728
* The default implementation that deletes the index for an editing context.
@@ -49,7 +50,7 @@ public boolean deleteIndex(String editingContextId) {
4950
elasticSearchClient.indices().delete(deleteIndexRequest -> deleteIndexRequest.index(DefaultIndexCreationService.EDITING_CONTEXT_INDEX_NAME_PREFIX + editingContextId));
5051
indexDeleted = true;
5152
}
52-
} catch (IOException exception) {
53+
} catch (IOException | ElasticsearchException exception) {
5354
this.logger.warn("An error occurred while deleting the index", exception);
5455
}
5556
}

packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/elasticsearch/services/IndexQueryService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.stereotype.Service;
2727

2828
import co.elastic.clients.elasticsearch.ElasticsearchClient;
29+
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
2930
import co.elastic.clients.elasticsearch.core.SearchResponse;
3031
import co.elastic.clients.elasticsearch.core.search.Hit;
3132

@@ -67,7 +68,7 @@ public List<IIndexEntry> search(String query) {
6768
.allowLeadingWildcard(true)))
6869
, IIndexEntry.class);
6970
result = response.hits().hits().stream().map(Hit::source).toList();
70-
} catch (IOException exception) {
71+
} catch (IOException | ElasticsearchException exception) {
7172
this.logger.warn("An error occurred while querying indices", exception);
7273
}
7374
}

packages/sirius-web/backend/sirius-web/src/test/java/org/eclipse/sirius/web/application/controllers/omnibox/OmniboxControllerIntegrationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,15 @@ public void givenQueryWhenObjectsAreSearchedInProjectsOmniboxThenObjectsAreRetur
270270
assertThat(complexQueryObjectLabels).isNotEmpty()
271271
.anyMatch(label -> label.contains("org.eclipse.sirius.web.tests.data"))
272272
.anyMatch(label -> label.contains("Success"));
273+
274+
Map<String, Object> queryWithSyntaxErrorVariables = Map.of(
275+
"query", "name::Comp*"
276+
);
277+
278+
var queryWithSyntaxErrorResult = this.projectsOmniboxSearchQueryRunner.run(queryWithSyntaxErrorVariables);
279+
assertThat(queryWithSyntaxErrorResult.errors()).isEmpty();
280+
List<String> queryWithSyntaxErrorObjectLabels = JsonPath.read(queryWithSyntaxErrorResult.data(), "$.data.viewer.projectsOmniboxSearch.edges[*].node.label");
281+
assertThat(queryWithSyntaxErrorObjectLabels).isEmpty();
273282
}
274283

275284
}

0 commit comments

Comments
 (0)