Skip to content

Commit 18f310d

Browse files
committed
chore(deps) update PMD (java 25), fix resulting linter issues
1 parent 818538d commit 18f310d

File tree

10 files changed

+13
-20
lines changed

10 files changed

+13
-20
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ allprojects {
6969

7070
pmd {
7171
consoleOutput = true
72-
toolVersion = "7.12.0"
72+
toolVersion = "7.20.0"
7373

7474
// This tells PMD to use your custom ruleset file.
7575
ruleSetFiles = rootProject.files("config/pmd/pmd-ruleset.xml")

core/src/main/java/cloud/stackit/sdk/core/KeyFlowAuthenticator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.security.NoSuchAlgorithmException;
2020
import java.security.interfaces.RSAPrivateKey;
2121
import java.security.spec.InvalidKeySpecException;
22-
import java.util.Date;
22+
import java.time.Instant;
2323
import java.util.Map;
2424
import java.util.UUID;
2525
import java.util.concurrent.ConcurrentHashMap;
@@ -200,7 +200,7 @@ public KeyFlowTokenResponse(
200200
}
201201

202202
protected boolean isExpired() {
203-
return expiresIn < new Date().toInstant().getEpochSecond();
203+
return expiresIn < Instant.now().getEpochSecond();
204204
}
205205

206206
protected String getAccessToken() {
@@ -342,8 +342,8 @@ private String generateSelfSignedJWT()
342342
.withSubject(saKey.getCredentials().getSub())
343343
.withJWTId(UUID.randomUUID().toString())
344344
.withAudience(saKey.getCredentials().getAud())
345-
.withIssuedAt(new Date())
346-
.withExpiresAt(new Date().toInstant().plusSeconds(10 * 60))
345+
.withIssuedAt(Instant.now())
346+
.withExpiresAt(Instant.now().plusSeconds(10 * 60))
347347
.withHeader(jwtHeader)
348348
.sign(algorithm);
349349
}

core/src/main/java/cloud/stackit/sdk/core/auth/SetupAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected static String readValueFromCredentialsFile(
327327
} catch (ClassCastException ignored) {
328328
}
329329
if (Utils.isStringSet(keyPath)) {
330-
return new String(Files.readAllBytes(Paths.get(keyPath)));
330+
return new String(Files.readAllBytes(Paths.get(keyPath)), StandardCharsets.UTF_8);
331331
}
332332
throw new CredentialsInFileNotFoundException(
333333
"could not find " + valueKey + " or " + pathKey + " in " + path);

examples/alb/src/main/java/cloud/stackit/sdk/alb/examples/AlbExample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ private AlbExample() {}
1818
"PMD.CognitiveComplexity",
1919
"PMD.CommentSize",
2020
"PMD.CyclomaticComplexity",
21-
"PMD.NPathComplexity",
2221
"PMD.NcssCount",
2322
"PMD.SystemPrintln",
2423
"PMD.AvoidThrowingRawExceptionTypes"

examples/authentication/src/main/java/cloud/stackit/sdk/authentication/examples/AuthenticationExample.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.File;
88
import java.io.FileNotFoundException;
99
import java.io.IOException;
10+
import java.nio.charset.StandardCharsets;
1011
import java.util.Scanner;
1112

1213
final class AuthenticationExample {
@@ -53,7 +54,7 @@ public static void main(String[] args) throws IOException {
5354
"examples/authentication/src/main/java/cloud/stackit/sdk/authentication/examples/dummy_credentials/dummy-service-account-key.json";
5455
File serviceAccountKeyFile = new File(serviceAccountKeyPath);
5556
StringBuilder serviceAccountKeyContent = new StringBuilder();
56-
try (Scanner myReader = new Scanner(serviceAccountKeyFile)) {
57+
try (Scanner myReader = new Scanner(serviceAccountKeyFile, StandardCharsets.UTF_8.name())) {
5758
while (myReader.hasNextLine()) {
5859
serviceAccountKeyContent.append(myReader.nextLine());
5960
}
@@ -66,7 +67,7 @@ public static void main(String[] args) throws IOException {
6667
"examples/authentication/src/main/java/cloud/stackit/sdk/authentication/examples/dummy_credentials/dummy-private-key.pem";
6768
File privateKeyFile = new File(privateKeyPath);
6869
StringBuilder privateKeyContent = new StringBuilder();
69-
try (Scanner myReader = new Scanner(privateKeyFile)) {
70+
try (Scanner myReader = new Scanner(privateKeyFile, StandardCharsets.UTF_8.name())) {
7071
while (myReader.hasNextLine()) {
7172
privateKeyContent.append(myReader.nextLine());
7273
}

examples/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/examples/LoadBalancerExample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ private LoadBalancerExample() {}
1818
"PMD.CognitiveComplexity",
1919
"PMD.CommentSize",
2020
"PMD.CyclomaticComplexity",
21-
"PMD.NPathComplexity",
2221
"PMD.NcssCount",
2322
"PMD.SystemPrintln",
2423
"PMD.AvoidThrowingRawExceptionTypes"

examples/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/examples/ObjectStorageExample.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ private ObjectStorageExample() {}
1919

2020
@SuppressWarnings({
2121
"PMD.CyclomaticComplexity",
22-
"PMD.CognitiveComplexity",
23-
"PMD.NPathComplexity",
2422
"PMD.NcssCount",
2523
"PMD.SystemPrintln",
2624
"PMD.AvoidThrowingRawExceptionTypes"

examples/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/examples/ResourcemanagerExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class ResourcemanagerExample {
2424
/** Prevent instantiation */
2525
private ResourcemanagerExample() {}
2626

27-
@SuppressWarnings({"PMD.SystemPrintln", "PMD.AvoidThrowingRawExceptionTypes"})
27+
@SuppressWarnings({"PMD.SystemPrintln"})
2828
public static void main(String[] args)
2929
throws IOException, ApiException, InterruptedException, ExecutionException {
3030
// Credentials are read from the credentialsFile in `~/.stackit/credentials.json` or the env

examples/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/examples/ServerUpdateExample.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private ServerUpdateExample() {}
2020
@SuppressWarnings({
2121
"PMD.CyclomaticComplexity",
2222
"PMD.CognitiveComplexity",
23-
"PMD.NPathComplexity",
2423
"PMD.NcssCount",
2524
"PMD.SystemPrintln",
2625
"PMD.AvoidThrowingRawExceptionTypes",

services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/wait/ResourcemanagerWait.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,12 @@ private static AsyncActionHandler<GetProjectResponse> createOrUpdateProjectWaitH
8787
() -> {
8888
GetProjectResponse projectResponse = apiClient.getProject(containerId, false);
8989
if (projectResponse.getContainerId().equals(containerId)
90-
&& projectResponse.getLifecycleState().equals(LifecycleState.ACTIVE)) {
90+
&& projectResponse.getLifecycleState() == LifecycleState.ACTIVE) {
9191
return new AsyncActionResult<>(true, projectResponse);
9292
}
9393

9494
if (projectResponse.getContainerId().equals(containerId)
95-
&& projectResponse
96-
.getLifecycleState()
97-
.equals(LifecycleState.CREATING)) {
95+
&& projectResponse.getLifecycleState() == LifecycleState.CREATING) {
9896
return new AsyncActionResult<>(false, null);
9997
}
10098
// An invalid state was received which should not be possible.
@@ -139,8 +137,7 @@ public static AsyncActionHandler<Void> deleteProjectWaitHandler(
139137
apiClient.getProject(containerId, false);
140138
if (projectResponse.getContainerId().equals(containerId)
141139
&& projectResponse
142-
.getLifecycleState()
143-
.equals(LifecycleState.DELETING)) {
140+
.getLifecycleState() == LifecycleState.DELETING) {
144141
return new AsyncActionResult<>(true, null);
145142
}
146143

0 commit comments

Comments
 (0)