Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-9862 - Some tests in oak-search are not cleaning up Elastic Search indexes after the test #721

Merged
merged 1 commit into from Sep 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.index.elastic;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.rules.ExternalResource;
import org.junit.runner.Description;
Expand Down Expand Up @@ -74,10 +75,11 @@ protected void after() {
ElasticConnection esConnection = getElasticConnection();
if (esConnection != null) {
try {
esConnection.getClient().indices().delete(d->d.index(esConnection.getIndexPrefix() + "*"));
esConnection.close();
esConnection.getClient().indices().delete(d -> d.index(this.indexPrefix + "*"));
} catch (IOException e) {
LOG.error("Unable to delete indexes with prefix {}", esConnection.getIndexPrefix());
LOG.error("Unable to delete indexes with prefix {}", this.indexPrefix);
} finally {
IOUtils.closeQuietly(esConnection, e -> LOG.debug("Error closing Elasticsearch connection", e));
}
}
}
Expand Down