diff --git a/_clients/java.md b/_clients/java.md index c186d794..64d887dd 100644 --- a/_clients/java.md +++ b/_clients/java.md @@ -140,10 +140,17 @@ public class OpenSearchClientExample { DeleteResponse deleteResponse = client.indices().delete(deleteRequest); restClient.close(); - } - catch (IOException e){ + } catch (IOException e){ System.out.println(e.toString()); - } + } finally { + try { + if (client != null) { + client.close(); + } + } catch (IOException e) { + System.out.println(e.toString()); + } + } } } ```