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

Downgrade client to build with Java 8 #371

Closed
Closed
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [ 11 ]
java: [ 8, 11 ]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}

- name: Checkout Branch
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Build with Gradle
run: ./gradlew clean build -x test
4 changes: 2 additions & 2 deletions java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ checkstyle {
}

java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8

withJavadocJar()
withSourcesJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
Expand Down Expand Up @@ -294,9 +295,13 @@ private <RequestT> SdkHttpFullRequest prepareRequest(
Map<String, String> params = endpoint.queryParameters(request);
if (params != null && !params.isEmpty()) {
char sep = '?';
for (var ent : params.entrySet()) {
for (Map.Entry<String, String> ent : params.entrySet()) {
url.append(sep).append(ent.getKey()).append('=');
url.append(URLEncoder.encode(ent.getValue(), StandardCharsets.UTF_8));
try {
url.append(URLEncoder.encode(ent.getValue(), StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new AssertionError("UTF-8 is unknown");
}
sep = '&';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.opensearch.client.opensearch.core.SearchResponse;
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient;
import org.opensearch.client.opensearch.indices.CreateIndexRequest.Builder;

import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void testDoubleWrappedException() throws Exception {
resetTestIndex(false);
// attempt to create the same index a second time
OpenSearchIndicesClient client = getIndexesClient(false, null, null);
var req = new CreateIndexRequest.Builder().index(TEST_INDEX);
Builder req = new CreateIndexRequest.Builder().index(TEST_INDEX);
Exception exception = Assert.assertThrows(OpenSearchException.class, () -> {
client.create(req.build());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
import org.opensearch.client.opensearch.indices.IndexState;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient;
import org.opensearch.client.opensearch.indices.CreateIndexRequest.Builder;
import org.opensearch.client.transport.TransportOptions;
import org.opensearch.client.transport.aws.AwsSdk2Transport;
import org.opensearch.client.transport.aws.AwsSdk2TransportOptions;
Expand Down Expand Up @@ -207,13 +208,13 @@ public void resetTestIndex(boolean async) throws Exception {
if (indexExists) {
client.delete(b -> b.index(List.of(TEST_INDEX)));
}
var req = new CreateIndexRequest.Builder()
Builder req = new CreateIndexRequest.Builder()
.index(TEST_INDEX);
client.create(req.build());
}

protected SearchResponse<SimplePojo> query(OpenSearchClient client, String title, String text) throws Exception {
var query = Query.of(qb -> {
Query query = Query.of(qb -> {
if (title != null) {
qb.match(mb -> mb.field("title").query(vb -> vb.stringValue(title)));
}
Expand All @@ -237,7 +238,7 @@ protected SearchResponse<SimplePojo> query(OpenSearchClient client, String title

protected CompletableFuture<SearchResponse<SimplePojo>> query(
OpenSearchAsyncClient client, String title, String text) {
var query = Query.of(qb -> {
Query query = Query.of(qb -> {
if (title != null) {
qb.match(mb -> mb.field("title").query(vb -> vb.stringValue(title)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ default OpenSearchTransport buildTransport(Settings settings, HttpHost[] hosts)
return builder.setStrictDeprecationMode(true).build();
}

private void configure(ApacheHttpClient5TransportBuilder builder, Settings settings, HttpHost[] hosts) throws IOException {
default void configure(ApacheHttpClient5TransportBuilder builder, Settings settings, HttpHost[] hosts) throws IOException {
if (isHttps()) {
try {
final SSLContext sslcontext = SSLContextBuilder
Expand Down