Skip to content

Commit

Permalink
Restore support for Java 8 for RestClient (#11562) (#11576)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
(cherry picked from commit 4e72741)
  • Loading branch information
reta authored Dec 12, 2023
1 parent 423f499 commit 7f7aa05
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Change error message when per shard document limit is breached ([#11312](https://github.com/opensearch-project/OpenSearch/pull/11312))
- Improve boolean parsing performance ([#11308](https://github.com/opensearch-project/OpenSearch/pull/11308))
- Interpret byte array as primitive using VarHandles ([#11362](https://github.com/opensearch-project/OpenSearch/pull/11362))
- Restore support for Java 8 for RestClient ([#11562](https://github.com/opensearch-project/OpenSearch/pull/11562))

### Deprecated

Expand Down
11 changes: 9 additions & 2 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ apply plugin: 'opensearch.build'
apply plugin: 'opensearch.publish'

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

base {
Expand Down Expand Up @@ -104,3 +104,10 @@ thirdPartyAudit.ignoreMissingClasses(
'javax.servlet.ServletContextEvent',
'javax.servlet.ServletContextListener'
)

tasks.withType(JavaCompile) {
// Suppressing '[options] target value 8 is obsolete and will be removed in a future release'
configure(options) {
options.compilerArgs << '-Xlint:-options'
}
}
10 changes: 8 additions & 2 deletions client/rest/src/main/java/org/opensearch/client/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1021,9 +1021,15 @@ public long getContentLength() {
if (chunkedEnabled.get()) {
return -1L;
} else {
long size;
long size = 0;
final byte[] buf = new byte[8192];
int nread = 0;

try (InputStream is = getContent()) {
size = is.readAllBytes().length;
// read to EOF which may read more or less than buffer size
while ((nread = is.read(buf)) > 0) {
size += nread;
}
} catch (IOException ex) {
size = -1L;
}
Expand Down
11 changes: 9 additions & 2 deletions client/test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
apply plugin: 'opensearch.build'

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

base {
Expand Down Expand Up @@ -69,3 +69,10 @@ dependenciesInfo.enabled = false
//we aren't releasing this jar
thirdPartyAudit.enabled = false
test.enabled = false

tasks.withType(JavaCompile) {
// Suppressing '[options] target value 8 is obsolete and will be removed in a future release'
configure(options) {
options.compilerArgs << '-Xlint:-options'
}
}

0 comments on commit 7f7aa05

Please sign in to comment.