Skip to content

Repository initialization should throw an Exception when index cannot be created [DATAES-481] #1056

Closed
@spring-projects-issues

Description

@spring-projects-issues

Mateusz Stefek opened DATAES-481 and commented

AbstractElasticSearchRepository creates an index on startup, if it isn't already there. \

If there's an error in this index creation, an exception is swallowed and the error is simply reported into the logs.

This renders the application unusable when the Elasticsearch server is unavailable during the application startup. (IndexNotFoundExceptionis thrown by all the operations on the repository).

I would like to have an option to force the application to crash, if anything fails in this constructor.

	public AbstractElasticsearchRepository(ElasticsearchEntityInformation<T, ID> metadata,
			ElasticsearchOperations elasticsearchOperations) {
		this(elasticsearchOperations);

		Assert.notNull(metadata, "ElasticsearchEntityInformation must not be null!");

		this.entityInformation = metadata;
		setEntityClass(this.entityInformation.getJavaType());
		try {
			if (createIndexAndMapping()) {
				createIndex();
				putMapping();
			}
		} catch (ElasticsearchException exception) {
			LOGGER.error("failed to load elasticsearch nodes : " + exception.getDetailedMessage());
		}
	}

Affects: 3.0.9 (Kay SR9)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions