Skip to content

Commit be1d26e

Browse files
committed
DATAES-47 - Spring Application(Context) is not getting started up if elasticsearch nodes are not available
1 parent d92f415 commit be1d26e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,10 @@
2525
import java.util.Collections;
2626
import java.util.List;
2727

28+
import org.elasticsearch.ElasticSearchException;
2829
import org.elasticsearch.index.query.QueryBuilder;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
2932
import org.springframework.dao.InvalidDataAccessApiUsageException;
3033
import org.springframework.data.domain.*;
3134
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
@@ -45,6 +48,7 @@
4548
public abstract class AbstractElasticsearchRepository<T, ID extends Serializable> implements
4649
ElasticsearchRepository<T, ID> {
4750

51+
static final Logger LOGGER = LoggerFactory.getLogger(AbstractElasticsearchRepository.class);
4852
protected ElasticsearchOperations elasticsearchOperations;
4953
protected Class<T> entityClass;
5054
protected ElasticsearchEntityInformation<T, ID> entityInformation;
@@ -63,8 +67,12 @@ public AbstractElasticsearchRepository(ElasticsearchEntityInformation<T, ID> met
6367
Assert.notNull(metadata);
6468
this.entityInformation = metadata;
6569
setEntityClass(this.entityInformation.getJavaType());
66-
createIndex();
67-
putMapping();
70+
try {
71+
createIndex();
72+
putMapping();
73+
} catch (ElasticSearchException exception) {
74+
LOGGER.error("failed to load elasticsearch nodes : " + exception.getDetailedMessage());
75+
}
6876
}
6977

7078
private void createIndex() {

0 commit comments

Comments
 (0)