Skip to content

Commit

Permalink
Implements Closeable for SDKClients
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
  • Loading branch information
owaiskazi19 committed Jan 6, 2023
1 parent f57c047 commit 7bf6921
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.opensearch.sdk;

import java.io.Closeable;
import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down Expand Up @@ -39,7 +40,7 @@
/**
* This class creates SDKClient for an extension to make requests to OpenSearch
*/
public class SDKClient {
public class SDKClient implements Closeable {
private OpenSearchClient javaClient;
private RestClient restClient;
private RestHighLevelClient highLevelClient;
Expand Down Expand Up @@ -98,6 +99,7 @@ public OpenSearchClient initializeJavaClient(String hostAddress, int port) {
}

/**
* @Deprecated @deprecated Provided for compatibility with existing plugins to permit migration. New development should not use this client
* Creates High Level Rest Client for SDK.
* @param hostAddress The address of OpenSearch cluster, client can connect to
* @param port The port of OpenSearch cluster
Expand Down Expand Up @@ -131,4 +133,10 @@ public void doCloseHighLevelClient() throws IOException {
highLevelClient.close();
}
}

@Override
public void close() throws IOException {
doCloseJavaClient();
doCloseHighLevelClient();
}
}

0 comments on commit 7bf6921

Please sign in to comment.