Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation issues (after changes in main) #423

Merged
merged 1 commit into from
Apr 4, 2023
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
Fix compilation issues (after changes in main)
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Apr 3, 2023
commit 0dab37a9ee1c265494d45e66b466ac87d64ef627
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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing dependency on core module(s)

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
@@ -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;
@@ -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;
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
@@ -116,7 +117,7 @@ public void testJacksonCustomJsonFactory() {
}

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

@Test