Skip to content

Commit 62a207b

Browse files
committed
Handle Null Cases
Previously, a change went in that created or updated applications with environment variables from a manifest. This change did not handle null cases properly. This change updates the code to handle that case.
1 parent a8e8b32 commit 62a207b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/DefaultApplications.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ private static Mono<String> getApplicationId(CloudFoundryClient cloudFoundryClie
709709
.singleOrEmpty()
710710
.then(application -> {
711711
Map<String, Object> environmentJsons = new HashMap<>(ResourceUtils.getEntity(application).getEnvironmentJsons());
712-
environmentJsons.putAll(manifest.getEnvironmentVariables());
712+
Optional.ofNullable(manifest.getEnvironmentVariables()).ifPresent(environmentJsons::putAll);
713713

714714
return requestUpdateApplication(cloudFoundryClient, ResourceUtils.getId(application), environmentJsons, manifest, stackId)
715715
.map(ResourceUtils::getId);

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/DefaultApplicationsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ public void pushExistingApplication() throws IOException {
11701170
requestApplications(this.cloudFoundryClient, "test-name", TEST_SPACE_ID, "test-application-id");
11711171
requestUpdateApplication(this.cloudFoundryClient, "test-application-id", ApplicationManifest.builder()
11721172
.path(testApplication)
1173+
.environmentVariable("test-var", "test-value")
11731174
.domain("test-shared-domain")
11741175
.name("test-name")
11751176
.build(), null);

0 commit comments

Comments
 (0)