Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

package org.craftercms.deployer.utils.opensearch;

import java.util.ArrayList;

import org.craftercms.commons.config.ConfigurationException;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.AbstractFactoryBean;

import java.util.ArrayList;

/**
* Base implementation for factories capable of build single or multi-cluster OpenSearch services
*
Expand Down Expand Up @@ -56,6 +56,14 @@ public void setBeanName(final String name) {
this.name = name;
}

@Override
protected void destroyInstance(T instance) throws Exception {
logger.debug("Closing OpenSearch service for '{}'", name);
if (instance instanceof AutoCloseable closeable) {
closeable.close();
}
}

@Override
protected T createInstance() throws ConfigurationException {
logger.debug("Creating instance for '{}'", name);
Expand Down