Fix potential NPE when passing 'null' as params

This commit is contained in:
Moritz Halbritter 2025-03-07 08:17:37 +01:00
parent 67b0a26474
commit 5ec099756f

View File

@ -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();
}