Skip to content

Commit 44d44be

Browse files
Fix #92
1 parent eb8a3c3 commit 44d44be

File tree

1 file changed

+16
-7
lines changed
  • src/main/java/io/apigee/buildTools/enterprise4g/rest

1 file changed

+16
-7
lines changed

src/main/java/io/apigee/buildTools/enterprise4g/rest/RestUtil.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import com.google.api.client.util.Key;
5050
import com.google.gson.Gson;
5151
import com.google.gson.GsonBuilder;
52+
import com.google.gson.JsonSyntaxException;
5253

5354
import io.apigee.buildTools.enterprise4g.utils.PrintUtil;
5455
import io.apigee.buildTools.enterprise4g.utils.ServerProfile;
@@ -679,7 +680,7 @@ public static String activateBundleRevision(ServerProfile profile, String revisi
679680
throws IOException {
680681

681682
BundleActivationConfig deployment2 = new BundleActivationConfig();
682-
683+
HttpResponse response = null;
683684
try {
684685

685686
UrlEncodedContent urlEncodedContent = null;
@@ -716,12 +717,20 @@ public static String activateBundleRevision(ServerProfile profile, String revisi
716717
deployRestRequest.setReadTimeout(0);
717718
deployRestRequest.setHeaders(headers);
718719

719-
720-
HttpResponse response = null;
721720
response = executeAPI(profile, deployRestRequest);
722-
721+
String responseString = response.parseAsString();
722+
SeamLessDeploymentStatus deployment3 = null;
723+
try{
724+
deployment3 = new Gson().fromJson(responseString, SeamLessDeploymentStatus.class);
725+
}catch (JsonSyntaxException e){
726+
// https://github.com/apigee/apigee-deploy-maven-plugin/issues/92
727+
// Whenever an existing API is deployed with option as override and in the new revision, the proxy basepath is changed,
728+
// the Mgmt API response is different. It does not return the usual response if the proxy has no changes to the basepath
729+
// So catching the exception from above and setting the override flag to false so that it doesnt go that section of code below
730+
Options.override = false;
731+
}
723732
if (Options.override) {
724-
SeamLessDeploymentStatus deployment3 = response.parseAs(SeamLessDeploymentStatus.class);
733+
//SeamLessDeploymentStatus deployment3 = response.parseAs(SeamLessDeploymentStatus.class);
725734
Iterator<BundleActivationConfig> iter = deployment3.environment.iterator();
726735
while (iter.hasNext()){
727736
BundleActivationConfig config = iter.next();
@@ -746,8 +755,8 @@ public static String activateBundleRevision(ServerProfile profile, String revisi
746755
}
747756

748757
}
749-
750-
deployment2 = response.parseAs(BundleActivationConfig.class);
758+
//deployment2 = response.parseAs(BundleActivationConfig.class);
759+
deployment2 = new Gson().fromJson(responseString, BundleActivationConfig.class);
751760
logger.info(PrintUtil.formatResponse(response, gson.toJson(deployment2).toString()));
752761
logger.info("\nDeployed revision is: "+deployment2.revision);
753762

0 commit comments

Comments
 (0)