[ https://issues.apache.org/jira/browse/GEODE-8996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17294750#comment-17294750 ]
ASF GitHub Bot commented on GEODE-8996: --------------------------------------- kirklund commented on a change in pull request #6080: URL: https://github.com/apache/geode/pull/6080#discussion_r586693423 ########## File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + */ +package org.apache.geode.rest.internal.web.controllers; + +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.management.configuration.DiskStore; +import org.apache.geode.management.operation.RebalanceOperation; +import org.apache.geode.management.operation.RestoreRedundancyRequest; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; +import org.apache.geode.test.junit.rules.GfshCommandRule; +import org.apache.geode.test.junit.rules.MemberStarterRule; +import org.apache.geode.test.version.TestVersion; +import org.apache.geode.test.version.VersionManager; +import org.apache.geode.util.internal.GeodeJsonMapper; + +@Category({BackwardCompatibilityTest.class}) +@RunWith(Parameterized.class) +public class RestAPICompatibilityTest { + private final String oldVersion; + private static ObjectMapper mapper = GeodeJsonMapper.getMapper(); + + @Parameterized.Parameters(name = "{0}") + public static Collection<String> data() { + List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); + result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0); + return result; + } + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public GfshCommandRule gfsh = new GfshCommandRule(); + + public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException { + this.oldVersion = oldVersion; + DiskStore diskStore = new DiskStore(); + diskStore.setName("diskStore"); + postRESTAPICalls = new HashMap<>(); + // {REST endpoint,{Body, Successful Status Message, Introduced in version}} + postRESTAPICalls.put("/management/v1/operations/rebalances", + new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started", + "1.11.0"}); + postRESTAPICalls.put("/management/v1/operations/restoreRedundancy", + new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()), + "Operation started", "1.13.1"}); + } + + private static Map<String, String[]> postRESTAPICalls; + + + private static final String[][] getRESTAPICalls = { + // REST endpoint , status + {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"} + }; + + @Test + public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception { + // Initialize all cluster members with old versions + MemberVM locator1 = + cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService); + int locatorPort1 = locator1.getPort(); + MemberVM locator2 = + cluster.startLocatorVM(1, 0, oldVersion, + x -> x.withConnectionToLocator(locatorPort1).withHttpService()); + int locatorPort2 = locator2.getPort(); + cluster + .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + cluster + .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + + // Roll locators to the current version + cluster.stop(0); + // gradle sets a property telling us where the build is located + final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir")); + locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1) + .withConnectionToLocator(locatorPort2) + .withSystemProperty("geode.build.dir", buildDir)); + cluster.stop(1); + + cluster.startLocatorVM(1, + x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2) + .withConnectionToLocator(locatorPort1) + .withSystemProperty("geode.build.dir", buildDir)); + + gfsh.connectAndVerify(locator1); + gfsh.execute("list members"); + // Execute REST api calls to from the new locators to the old servers to ensure that backwards + // compatibility is maintained + + executeAndValidatePOSTRESTCalls(locator1.getHttpPort()); + executeAndValidateGETRESTCalls(locator1.getHttpPort()); + + } + + void executeAndValidatePOSTRESTCalls(int locator) throws Exception { + + CloseableHttpClient httpClient = HttpClients.createDefault(); + for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) { + // Skip the test is the version is before the REST api was introduced. + if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) { + continue; + } + HttpPost post = + new HttpPost("http://localhost:" + locator + entry.getKey()); + post.addHeader("Content-Type", "application/json"); + post.addHeader("Accept", "application/json"); + StringEntity jsonStringEntity = + new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT); + post.setEntity(jsonStringEntity); + CloseableHttpResponse response = httpClient.execute(post); + + HttpEntity entity = response.getEntity(); + InputStream content = entity.getContent(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); + String line; + StringBuilder sb = new StringBuilder(); + while ((line = reader.readLine()) != null) { + sb.append(line); + } + JsonNode jsonObject = mapper.readTree(sb.toString()); + String statusCode = jsonObject.findValue("statusCode").textValue(); + assertTrue(statusCode.equals("ACCEPTED") || statusCode.contains("OK")); + String statusMessage = jsonObject.findValue("statusMessage").textValue(); + assertTrue(statusMessage.contains(entry.getValue()[1])); Review comment: This assertion will also just fail with: ``` java.lang.AssertionError at org.junit.Assert.fail(Assert.java:87) at org.junit.Assert.assertTrue(Assert.java:42) at org.junit.Assert.assertTrue(Assert.java:53) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:170) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135) ``` While AssertJ failure will look like: ``` java.lang.AssertionError: Expecting: "A really long message that has other entry value" to contain: "expected entry value" at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:170) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135) ``` ########## File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + */ +package org.apache.geode.rest.internal.web.controllers; + +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.management.configuration.DiskStore; +import org.apache.geode.management.operation.RebalanceOperation; +import org.apache.geode.management.operation.RestoreRedundancyRequest; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; +import org.apache.geode.test.junit.rules.GfshCommandRule; +import org.apache.geode.test.junit.rules.MemberStarterRule; +import org.apache.geode.test.version.TestVersion; +import org.apache.geode.test.version.VersionManager; +import org.apache.geode.util.internal.GeodeJsonMapper; + +@Category({BackwardCompatibilityTest.class}) +@RunWith(Parameterized.class) +public class RestAPICompatibilityTest { + private final String oldVersion; + private static ObjectMapper mapper = GeodeJsonMapper.getMapper(); + + @Parameterized.Parameters(name = "{0}") + public static Collection<String> data() { + List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); + result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0); + return result; + } + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public GfshCommandRule gfsh = new GfshCommandRule(); + + public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException { + this.oldVersion = oldVersion; + DiskStore diskStore = new DiskStore(); + diskStore.setName("diskStore"); + postRESTAPICalls = new HashMap<>(); + // {REST endpoint,{Body, Successful Status Message, Introduced in version}} + postRESTAPICalls.put("/management/v1/operations/rebalances", + new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started", + "1.11.0"}); + postRESTAPICalls.put("/management/v1/operations/restoreRedundancy", + new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()), + "Operation started", "1.13.1"}); + } + + private static Map<String, String[]> postRESTAPICalls; + + + private static final String[][] getRESTAPICalls = { + // REST endpoint , status + {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"} + }; + + @Test + public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception { + // Initialize all cluster members with old versions + MemberVM locator1 = + cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService); + int locatorPort1 = locator1.getPort(); + MemberVM locator2 = + cluster.startLocatorVM(1, 0, oldVersion, + x -> x.withConnectionToLocator(locatorPort1).withHttpService()); + int locatorPort2 = locator2.getPort(); + cluster + .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + cluster + .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + + // Roll locators to the current version + cluster.stop(0); + // gradle sets a property telling us where the build is located + final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir")); + locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1) + .withConnectionToLocator(locatorPort2) + .withSystemProperty("geode.build.dir", buildDir)); + cluster.stop(1); + + cluster.startLocatorVM(1, + x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2) + .withConnectionToLocator(locatorPort1) + .withSystemProperty("geode.build.dir", buildDir)); + + gfsh.connectAndVerify(locator1); + gfsh.execute("list members"); + // Execute REST api calls to from the new locators to the old servers to ensure that backwards + // compatibility is maintained + + executeAndValidatePOSTRESTCalls(locator1.getHttpPort()); + executeAndValidateGETRESTCalls(locator1.getHttpPort()); + + } + + void executeAndValidatePOSTRESTCalls(int locator) throws Exception { + + CloseableHttpClient httpClient = HttpClients.createDefault(); + for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) { + // Skip the test is the version is before the REST api was introduced. + if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) { + continue; + } + HttpPost post = + new HttpPost("http://localhost:" + locator + entry.getKey()); + post.addHeader("Content-Type", "application/json"); + post.addHeader("Accept", "application/json"); + StringEntity jsonStringEntity = + new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT); + post.setEntity(jsonStringEntity); + CloseableHttpResponse response = httpClient.execute(post); + + HttpEntity entity = response.getEntity(); + InputStream content = entity.getContent(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); + String line; + StringBuilder sb = new StringBuilder(); + while ((line = reader.readLine()) != null) { + sb.append(line); + } + JsonNode jsonObject = mapper.readTree(sb.toString()); + String statusCode = jsonObject.findValue("statusCode").textValue(); + assertTrue(statusCode.equals("ACCEPTED") || statusCode.contains("OK")); Review comment: I strongly recommend AssertJ rather than JUnit Assert especially in this case. The AssertJ failure message has much better information about why it failed. The JUnit assertTrue will fail with a message like this: ``` java.lang.AssertionError at org.junit.Assert.fail(Assert.java:87) at org.junit.Assert.assertTrue(Assert.java:42) at org.junit.Assert.assertTrue(Assert.java:53) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:168) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135) ``` If you use AssertJ: ``` assertThat(statusCode).satisfiesAnyOf( value -> assertThat(value).isEqualTo("ACCEPTED"), value -> assertThat(value).contains("OK") ); ``` Then you will get a failure message like this: ``` org.assertj.core.error.MultipleAssertionsError: The following 2 assertions failed: 1) Expected :"[ACCEPTED]" Actual :"[FAIL]" at org.assertj.core.error.AssertionErrorCreator.multipleAssertionsError(AssertionErrorCreator.java:106) at org.assertj.core.api.AbstractAssert.multipleAssertionsError(AbstractAssert.java:947) at org.assertj.core.api.AbstractAssert.satisfiesAnyOfAssertionsGroups(AbstractAssert.java:942) at org.assertj.core.api.AbstractAssert.satisfiesAnyOf(AbstractAssert.java:855) at org.apache.geode.AwaitTest.executeAndValidatePOSTRESTCalls(AwaitTest.java:50) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.executeAndValidatePOSTRESTCalls(RestAPICompatibilityTest.java:168) at org.apache.geode.rest.internal.web.controllers.RestAPICompatibilityTest.restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible (RestAPICompatibilityTest.java:135) ``` ########## File path: geode-assembly/src/distributedTest/java/org/apache/geode/rest/internal/web/controllers/RestAPICompatibilityTest.java ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * + */ +package org.apache.geode.rest.internal.web.controllers; + +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.management.configuration.DiskStore; +import org.apache.geode.management.operation.RebalanceOperation; +import org.apache.geode.management.operation.RestoreRedundancyRequest; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.categories.BackwardCompatibilityTest; +import org.apache.geode.test.junit.rules.GfshCommandRule; +import org.apache.geode.test.junit.rules.MemberStarterRule; +import org.apache.geode.test.version.TestVersion; +import org.apache.geode.test.version.VersionManager; +import org.apache.geode.util.internal.GeodeJsonMapper; + +@Category({BackwardCompatibilityTest.class}) +@RunWith(Parameterized.class) +public class RestAPICompatibilityTest { + private final String oldVersion; + private static ObjectMapper mapper = GeodeJsonMapper.getMapper(); + + @Parameterized.Parameters(name = "{0}") + public static Collection<String> data() { + List<String> result = VersionManager.getInstance().getVersionsWithoutCurrent(); + result.removeIf(s -> TestVersion.compare(s, "1.11.0") < 0); + return result; + } + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public GfshCommandRule gfsh = new GfshCommandRule(); + + public RestAPICompatibilityTest(String oldVersion) throws JsonProcessingException { + this.oldVersion = oldVersion; + DiskStore diskStore = new DiskStore(); + diskStore.setName("diskStore"); + postRESTAPICalls = new HashMap<>(); + // {REST endpoint,{Body, Successful Status Message, Introduced in version}} + postRESTAPICalls.put("/management/v1/operations/rebalances", + new String[] {mapper.writeValueAsString(new RebalanceOperation()), "Operation started", + "1.11.0"}); + postRESTAPICalls.put("/management/v1/operations/restoreRedundancy", + new String[] {mapper.writeValueAsString(new RestoreRedundancyRequest()), + "Operation started", "1.13.1"}); + } + + private static Map<String, String[]> postRESTAPICalls; + + + private static final String[][] getRESTAPICalls = { + // REST endpoint , status + {"/geode-mgmt/v1/management/commands?cmd=rebalance", "OK"} + }; + + @Test + public void restCommandExecutedOnLatestLocatorShouldBeBackwardsCompatible() throws Exception { + // Initialize all cluster members with old versions + MemberVM locator1 = + cluster.startLocatorVM(0, 0, oldVersion, MemberStarterRule::withHttpService); + int locatorPort1 = locator1.getPort(); + MemberVM locator2 = + cluster.startLocatorVM(1, 0, oldVersion, + x -> x.withConnectionToLocator(locatorPort1).withHttpService()); + int locatorPort2 = locator2.getPort(); + cluster + .startServerVM(2, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + cluster + .startServerVM(3, oldVersion, s -> s.withRegion(RegionShortcut.PARTITION, "region") + .withConnectionToLocator(locatorPort1, locatorPort2)); + + // Roll locators to the current version + cluster.stop(0); + // gradle sets a property telling us where the build is located + final String buildDir = System.getProperty("geode.build.dir", System.getProperty("user.dir")); + locator1 = cluster.startLocatorVM(0, l -> l.withHttpService().withPort(locatorPort1) + .withConnectionToLocator(locatorPort2) + .withSystemProperty("geode.build.dir", buildDir)); + cluster.stop(1); + + cluster.startLocatorVM(1, + x -> x.withConnectionToLocator(locatorPort1).withHttpService().withPort(locatorPort2) + .withConnectionToLocator(locatorPort1) + .withSystemProperty("geode.build.dir", buildDir)); + + gfsh.connectAndVerify(locator1); + gfsh.execute("list members"); + // Execute REST api calls to from the new locators to the old servers to ensure that backwards + // compatibility is maintained + + executeAndValidatePOSTRESTCalls(locator1.getHttpPort()); + executeAndValidateGETRESTCalls(locator1.getHttpPort()); + + } + + void executeAndValidatePOSTRESTCalls(int locator) throws Exception { + + CloseableHttpClient httpClient = HttpClients.createDefault(); + for (Map.Entry<String, String[]> entry : postRESTAPICalls.entrySet()) { + // Skip the test is the version is before the REST api was introduced. + if (TestVersion.compare(oldVersion, entry.getValue()[2]) < 0) { + continue; + } + HttpPost post = + new HttpPost("http://localhost:" + locator + entry.getKey()); + post.addHeader("Content-Type", "application/json"); + post.addHeader("Accept", "application/json"); + StringEntity jsonStringEntity = + new StringEntity(entry.getValue()[0], ContentType.DEFAULT_TEXT); + post.setEntity(jsonStringEntity); + CloseableHttpResponse response = httpClient.execute(post); + + HttpEntity entity = response.getEntity(); + InputStream content = entity.getContent(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(content)); Review comment: BufferedReader should be used in a try-with-resources statement which auto-closes it: ``` try (BufferedReader readerĀ = new BufferedReader(new InputStreamReader(content))) { while ((line = reader.readLine()) != null) { sb.append(line); } } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Rebalance GFSH commands and restore redundancy commands were not backward > compatible > ------------------------------------------------------------------------------------ > > Key: GEODE-8996 > URL: https://issues.apache.org/jira/browse/GEODE-8996 > Project: Geode > Issue Type: Bug > Components: gfsh, rest (admin) > Reporter: Nabarun Nag > Assignee: Nabarun Nag > Priority: Major > Labels: pull-request-available > > Issue: > * Rebalance command when executed with 1.12.0+ locator and older servers, > the command failed > * This was because the Rebalance function moved to a new package > * Similar problem with REST calls because of moving CacheRealizationFunction > to a new package > * There was another problem where Serializable classes with UIDs were > changed in couple of releases > * The variation of the UIDs caused deserialization issues when REST commands > were executed from new locators and old servers. -- This message was sent by Atlassian Jira (v8.3.4#803005)