Skip to content

Commit 92c9c3f

Browse files
committed
fix pmd SystemPrintln
1 parent c6b1de5 commit 92c9c3f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/custom-http-client/src/main/java/cloud/stackit/sdk/customhttpclient/examples/CustomHttpClientExample.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import cloud.stackit.sdk.iaas.model.*;
88
import java.io.IOException;
99
import java.util.UUID;
10+
import java.util.logging.Level;
11+
import java.util.logging.Logger;
1012
import okhttp3.OkHttpClient;
1113

1214
/*
@@ -22,6 +24,8 @@
2224
*
2325
* */
2426
public class CustomHttpClientExample {
27+
private static final Logger LOGGER = Logger.getLogger(CustomHttpClientExample.class.getName());
28+
2529
public static void main(String[] args) throws IOException {
2630
// Credentials are read from the credentialsFile in `~/.stackit/credentials.json` or the env
2731
// STACKIT_SERVICE_ACCOUNT_KEY_PATH / STACKIT_SERVICE_ACCOUNT_KEY
@@ -37,17 +41,19 @@ public static void main(String[] args) throws IOException {
3741
// the id of your STACKIT project, read from env var for this example
3842
String projectIdString = System.getenv("STACKIT_PROJECT_ID");
3943
if (projectIdString == null || projectIdString.isEmpty()) {
40-
System.err.println("Environment variable 'STACKIT_PROJECT_ID' not found.");
44+
LOGGER.severe("Environment variable 'STACKIT_PROJECT_ID' not found.");
4145
return;
4246
}
4347
UUID projectId = UUID.fromString(projectIdString);
4448

4549
try {
4650
/* list all servers */
4751
ServerListResponse servers = iaasApi.listServers(projectId, false, null);
48-
System.out.println("\nAvailable servers: ");
49-
for (Server server : servers.getItems()) {
50-
System.out.println("* " + server.getId() + " | " + server.getName());
52+
if (LOGGER.isLoggable(Level.INFO)) {
53+
LOGGER.info("\nAvailable servers: ");
54+
for (Server server : servers.getItems()) {
55+
LOGGER.info("* " + server.getId() + " | " + server.getName());
56+
}
5157
}
5258
} catch (ApiException e) {
5359
throw new RuntimeException(e);

0 commit comments

Comments
 (0)