Skip to content

Commit

Permalink
Fix compilation issues (after changes in main) (#423) (#427)
Browse files Browse the repository at this point in the history
(cherry picked from commit 76916f4)

Signed-off-by: Andriy Redko <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 04dc3ad commit defaa44
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.client.opensearch;

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

public final class IOUtils {
public static void closeQueitly(final Closeable closeable) {
try {
if (closeable != null) {
closeable.close();
}
} catch (final IOException | RuntimeException e) {
// Do nothing
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.opensearch.Version;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.opensearch.IOUtils;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.ExpandWildcard;
import org.opensearch.client.opensearch.cat.IndicesResponse;
Expand All @@ -28,7 +29,6 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.internal.io.IOUtils;
import org.opensearch.test.rest.OpenSearchRestTestCase;

import java.io.IOException;
Expand Down Expand Up @@ -147,11 +147,11 @@ protected void wipeAllOSIndices() throws IOException {
public static void cleanupJavaClient() throws IOException {
try {
if (javaClient != null) {
IOUtils.close(javaClient._transport());
IOUtils.closeQueitly(javaClient._transport());
}

if (adminJavaClient != null) {
IOUtils.close(adminJavaClient._transport());
IOUtils.closeQueitly(adminJavaClient._transport());
}
} finally {
clusterHosts = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.jackson.JacksonJsonpMapper;
import org.opensearch.client.json.jsonb.JsonbJsonpMapper;
import org.opensearch.client.opensearch.IOUtils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.MappingJsonFactory;
Expand All @@ -49,7 +51,6 @@
import jakarta.json.stream.JsonParser;
import org.junit.Assert;
import org.junit.Test;
import org.opensearch.core.internal.io.IOUtils;

import java.io.StringReader;
import java.io.StringWriter;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testJacksonCustomJsonFactory() {
}

testDeserialize(mapper, writer.toString());
IOUtils.closeWhileHandlingException(writer);
IOUtils.closeQueitly(writer);
}

@Test
Expand Down

0 comments on commit defaa44

Please sign in to comment.