Skip to content

Commit efee347

Browse files
committed
Merge pull request #43424 from vonZeppelin
* pr/43424: Polish "Only set imagePlatform if it has text" Only set imagePlatform if it has text Closes gh-43424
2 parents 48bc3b6 + 4dca6ee commit efee347

File tree

2 files changed

+11
-2
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src

2 files changed

+11
-2
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private BuildRequest customize(BuildRequest request) {
257257
if (StringUtils.hasText(this.runImage)) {
258258
request = request.withRunImage(ImageReference.of(this.runImage));
259259
}
260-
if (this.env != null && !this.env.isEmpty()) {
260+
if (!CollectionUtils.isEmpty(this.env)) {
261261
request = request.withEnv(this.env);
262262
}
263263
if (this.cleanCache != null) {
@@ -298,7 +298,7 @@ private BuildRequest customize(BuildRequest request) {
298298
if (this.securityOptions != null) {
299299
request = request.withSecurityOptions(this.securityOptions);
300300
}
301-
if (this.imagePlatform != null) {
301+
if (StringUtils.hasText(this.imagePlatform)) {
302302
request = request.withImagePlatform(this.imagePlatform);
303303
}
304304
return request;

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ImageTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* @author Scott Frederick
5050
* @author Jeroen Meijer
5151
* @author Rafael Ceccone
52+
* @author Moritz Halbritter
5253
*/
5354
class ImageTests {
5455

@@ -290,6 +291,14 @@ void getBuildRequestWhenHasImagePlatformUsesImagePlatform() {
290291
assertThat(request.getImagePlatform()).isEqualTo(ImagePlatform.of("linux/arm64"));
291292
}
292293

294+
@Test
295+
void getBuildRequestWhenImagePlatformIsEmptyDoesntSetImagePlatform() {
296+
Image image = new Image();
297+
image.imagePlatform = "";
298+
BuildRequest request = image.getBuildRequest(createArtifact(), mockApplicationContent());
299+
assertThat(request.getImagePlatform()).isNull();
300+
}
301+
293302
private Artifact createArtifact() {
294303
return new DefaultArtifact("com.example", "my-app", VersionRange.createFromVersion("0.0.1-SNAPSHOT"), "compile",
295304
"jar", null, new DefaultArtifactHandler());

0 commit comments

Comments
 (0)