Skip to content

Commit 7e97073

Browse files
committed
Merge branch '2.7.x'
2 parents 9658661 + 74494f1 commit 7e97073

File tree

2 files changed

+12
-3
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src

2 files changed

+12
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -110,7 +110,7 @@ public void properties(Action<BuildInfoProperties> action) {
110110

111111
private Map<String, String> coerceToStringValues(Map<String, Object> input) {
112112
Map<String, String> output = new HashMap<>();
113-
input.forEach((key, value) -> output.put(key, value.toString()));
113+
input.forEach((key, value) -> output.put(key, (value != null) ? value.toString() : null));
114114
return output;
115115
}
116116

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoTests.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
3434

3535
import static org.assertj.core.api.Assertions.assertThat;
36+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3637

3738
/**
3839
* Tests for {@link BuildInfo}.
@@ -186,6 +187,14 @@ void additionalPropertiesAreReflectedInProperties() {
186187
assertThat(buildInfoProperties(task)).containsEntry("build.b", "bravo");
187188
}
188189

190+
@Test
191+
void nullAdditionalPropertyProducesInformativeFailure() {
192+
BuildInfo task = createTask(createProject("test"));
193+
task.getProperties().getAdditional().put("a", null);
194+
assertThatThrownBy(() -> buildInfoProperties(task))
195+
.hasMessage("Additional property 'a' is illegal as its value is null");
196+
}
197+
189198
private Project createProject(String projectName) {
190199
File projectDir = new File(this.temp, projectName);
191200
Project project = GradleProjectBuilder.builder().withProjectDir(projectDir).withName(projectName).build();

0 commit comments

Comments
 (0)