DATACOUCH-229 - Check N1QL error codes rather than message

This should avoid problems when the message changes on the server side
(like in Couchbase Server 4.5).
This commit is contained in:
Simon Baslé
2016-05-25 18:39:32 +02:00
parent 9713b34801
commit b5ae111787

View File

@@ -172,7 +172,8 @@ public class IndexManager {
if (json == SUCCESS_MARKER) {
LOGGER.debug("N1QL primary index created for repository {}", metadata.getRepositoryInterface().getSimpleName());
return Observable.empty();
} else if (json.getString("msg").contains("Index #primary already exist")) {
} else if (json.getString("msg").contains("Index #primary already exist") ||
(json.containsKey("code") && json.getLong("code") == 4300L)) {
LOGGER.debug("Primary index already exist, skipping");
return Observable.empty(); //ignore, the index already exist
} else {
@@ -209,7 +210,8 @@ public class IndexManager {
if (json == SUCCESS_MARKER) {
LOGGER.debug("N1QL secondary index created for repository {}", metadata.getRepositoryInterface().getSimpleName());
return Observable.empty();
} else if (json.getString("msg").contains("Index " + indexName + " already exist")) {
} else if (json.getString("msg").contains("Index " + indexName + " already exist") ||
(json.containsKey("code") && json.getLong("code") == 4300L)) {
LOGGER.debug("Secondary index already exist, skipping");
return Observable.empty(); //ignore, the index already exist
} else {