Skip to content

Commit

Permalink
Fix compilation issues (after changes in main) (opensearch-project#423)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta authored Apr 4, 2023
1 parent 765c803 commit 76916f4
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 @@ -23,6 +23,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 @@ -34,7 +35,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 @@ -171,11 +171,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 76916f4

Please sign in to comment.