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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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) { private URI buildUrl(String path, Object... params) {
try { try {
URIBuilder builder = new URIBuilder("/" + API_VERSION + path); URIBuilder builder = new URIBuilder("/" + API_VERSION + path);
int param = 0; if (params != null) {
while (param < params.length) { int param = 0;
builder.addParameter(Objects.toString(params[param++]), Objects.toString(params[param++])); while (param < params.length) {
builder.addParameter(Objects.toString(params[param++]), Objects.toString(params[param++]));
}
} }
return builder.build(); return builder.build();
} }