Skip to content

Commit

Permalink
Merge branch '2.5.x' into 2.6.x
Browse files Browse the repository at this point in the history
Closes gh-30670
  • Loading branch information
wilkinsona committed Apr 14, 2022
2 parents d434827 + f7d181e commit 1720290
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -108,7 +108,7 @@ public void properties(Action<BuildInfoProperties> action) {

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

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,7 @@
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
* Tests for {@link BuildInfo}.
Expand Down Expand Up @@ -186,6 +187,14 @@ void additionalPropertiesAreReflectedInProperties() {
assertThat(buildInfoProperties(task)).containsEntry("build.b", "bravo");
}

@Test
void nullAdditionalPropertyProducesInformativeFailure() {
BuildInfo task = createTask(createProject("test"));
task.getProperties().getAdditional().put("a", null);
assertThatThrownBy(() -> buildInfoProperties(task))
.hasMessage("Additional property 'a' is illegal as its value is null");
}

private Project createProject(String projectName) {
File projectDir = new File(this.temp, projectName);
Project project = GradleProjectBuilder.builder().withProjectDir(projectDir).withName(projectName).build();
Expand Down

0 comments on commit 1720290

Please sign in to comment.