From 5ec099756f0fa3afca79bc2378a281b8202cbcc4 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Fri, 7 Mar 2025 08:17:37 +0100 Subject: [PATCH] Fix potential NPE when passing 'null' as params --- .../boot/buildpack/platform/docker/DockerApi.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java index c149b5b137a..b953082ba26 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -117,9 +117,11 @@ public class DockerApi { private URI buildUrl(String path, Object... params) { try { URIBuilder builder = new URIBuilder("/" + API_VERSION + path); - int param = 0; - while (param < params.length) { - builder.addParameter(Objects.toString(params[param++]), Objects.toString(params[param++])); + if (params != null) { + int param = 0; + while (param < params.length) { + builder.addParameter(Objects.toString(params[param++]), Objects.toString(params[param++])); + } } return builder.build(); }