Skip to content

Commit b85a573

Browse files
authored
Update spotless to 3.10.2 and formatting (#883)
Signed-off-by: Valentin Delaye <jonesbusy@users.noreply.github.com>
1 parent f832cd2 commit b85a573

8 files changed

Lines changed: 22 additions & 22 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<!-- Plugin version -->
8282
<build.helper-maven-plugin.version>3.6.1</build.helper-maven-plugin.version>
8383
<jacoco-maven-plugin.version>0.8.15</jacoco-maven-plugin.version>
84-
<spotless-maven-plugin.version>3.10.1</spotless-maven-plugin.version>
84+
<spotless-maven-plugin.version>3.10.2</spotless-maven-plugin.version>
8585
<maven-compiler-plugin.version>3.16.0</maven-compiler-plugin.version>
8686
<maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
8787
<maven-install-plugin.version>3.1.4</maven-install-plugin.version>

src/main/java/land/oras/OCILayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void pullArtifact(LayoutRef ref, Path path, PullOptions options) {
191191
.formatted(layer.getAnnotations().get(Const.ANNOTATION_TITLE)));
192192
}
193193
if (options.isOverwrite()) {
194-
Files.copy(blobPath, targetPath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
194+
Files.copy(blobPath, targetPath, StandardCopyOption.REPLACE_EXISTING);
195195
} else {
196196
Files.copy(blobPath, targetPath);
197197
}

src/main/java/land/oras/Registry.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.security.MessageDigest;
3636
import java.security.NoSuchAlgorithmException;
3737
import java.util.ArrayList;
38+
import java.util.Arrays;
3839
import java.util.HashMap;
3940
import java.util.HexFormat;
4041
import java.util.List;
@@ -1167,7 +1168,7 @@ private String uploadChunks(ContainerRef ref, InputStream stream, long totalSize
11671168
}
11681169
long rangeEnd = offset + read - 1;
11691170
String contentRange = "%d-%d".formatted(offset, rangeEnd);
1170-
final byte[] chunk = java.util.Arrays.copyOf(buffer, read);
1171+
final byte[] chunk = Arrays.copyOf(buffer, read);
11711172
URI patchUri = URI.create(location);
11721173
HttpClient.ResponseWrapper<String> patchResponse = client.patch(
11731174
patchUri,

src/main/java/land/oras/auth/AbstractUsernamePasswordProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package land.oras.auth;
2222

23+
import java.util.Base64;
2324
import land.oras.ContainerRef;
2425
import org.jspecify.annotations.NonNull;
2526

@@ -67,7 +68,7 @@ public String getPassword() {
6768
@Override
6869
@NonNull
6970
public String getAuthHeader(ContainerRef registry) {
70-
return "Basic " + java.util.Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
71+
return "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
7172
}
7273

7374
@Override

src/main/java/land/oras/auth/AuthStore.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.nio.file.Files;
2828
import java.nio.file.Path;
2929
import java.util.ArrayList;
30+
import java.util.Base64;
3031
import java.util.List;
3132
import java.util.Map;
3233
import java.util.Objects;
@@ -183,7 +184,7 @@ static ConfigFile fromCredential(Credential credential) {
183184
"auths",
184185
Map.of(
185186
"auth",
186-
java.util.Base64.getEncoder()
187+
Base64.getEncoder()
187188
.encodeToString(
188189
(credential.username + ":" + credential.password).getBytes()))),
189190
Map.of(),
@@ -229,8 +230,7 @@ public static Config load(List<ConfigFile> configFiles) throws OrasException {
229230
configFile.auths.forEach((host, value) -> {
230231
String auth = value.get("auth");
231232
if (auth != null) {
232-
String base64Decoded =
233-
new String(java.util.Base64.getDecoder().decode(auth), StandardCharsets.UTF_8);
233+
String base64Decoded = new String(Base64.getDecoder().decode(auth), StandardCharsets.UTF_8);
234234
String[] parts = base64Decoded.split(":", 2);
235235
if (parts.length != 2) {
236236
LOG.warn(

src/main/java/land/oras/utils/Const.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.time.Instant;
2424
import java.time.ZoneOffset;
2525
import java.time.format.DateTimeFormatter;
26+
import java.time.temporal.ChronoUnit;
2627
import org.jspecify.annotations.NullMarked;
2728

2829
/**
@@ -376,7 +377,7 @@ private Const() {
376377
*/
377378
public static String currentTimestamp() {
378379
return Instant.now()
379-
.truncatedTo(java.time.temporal.ChronoUnit.SECONDS)
380+
.truncatedTo(ChronoUnit.SECONDS)
380381
.atOffset(ZoneOffset.UTC)
381382
.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
382383
}

src/test/java/land/oras/RegistryWireMockTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.github.tomakehurst.wiremock.WireMockServer;
3434
import com.github.tomakehurst.wiremock.client.WireMock;
3535
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
36+
import com.github.tomakehurst.wiremock.http.Fault;
3637
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
3738
import com.github.tomakehurst.wiremock.junit5.WireMockTest;
3839
import com.github.tomakehurst.wiremock.stubbing.Scenario;
@@ -1226,16 +1227,15 @@ void pullArtifactShouldRejectInvalidTitleAnnotation(WireMockRuntimeInfo wmRuntim
12261227
String registryUrl = wmRuntimeInfo.getHttpBaseUrl().replace("http://", "");
12271228

12281229
// Craft a blob and build a manifest whose layer title contains a invalid sequence
1229-
byte[] blobContent = "malicious content".getBytes(java.nio.charset.StandardCharsets.UTF_8);
1230+
byte[] blobContent = "malicious content".getBytes(StandardCharsets.UTF_8);
12301231
String blobDigest = SupportedAlgorithm.SHA256.digest(blobContent);
12311232

12321233
Layer maliciousLayer = Layer.fromDigest(blobDigest, blobContent.length)
12331234
.withAnnotations(Map.of(Const.ANNOTATION_TITLE, "../traversed-file.txt"));
12341235

12351236
Manifest manifest = Manifest.empty().withLayers(List.of(maliciousLayer));
12361237
String manifestJson = JsonUtils.toJson(manifest);
1237-
String manifestDigest =
1238-
SupportedAlgorithm.SHA256.digest(manifestJson.getBytes(java.nio.charset.StandardCharsets.UTF_8));
1238+
String manifestDigest = SupportedAlgorithm.SHA256.digest(manifestJson.getBytes(StandardCharsets.UTF_8));
12391239

12401240
// Stub HEAD manifest
12411241
wireMock.register(head(urlEqualTo("/v2/library/malicious-artifact/manifests/latest"))
@@ -1372,7 +1372,7 @@ void shouldRetryOnNetworkError(WireMockRuntimeInfo wmRuntimeInfo) {
13721372
wireMock.register(get(urlEqualTo("/v2/library/network-error-retry/tags/list"))
13731373
.inScenario("network-error-retry")
13741374
.whenScenarioStateIs(Scenario.STARTED)
1375-
.willReturn(aResponse().withFault(com.github.tomakehurst.wiremock.http.Fault.CONNECTION_RESET_BY_PEER))
1375+
.willReturn(aResponse().withFault(Fault.CONNECTION_RESET_BY_PEER))
13761376
.willSetStateTo("retry"));
13771377

13781378
wireMock.register(get(urlEqualTo("/v2/library/network-error-retry/tags/list"))

src/test/java/land/oras/auth/AuthStoreTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import static org.junit.jupiter.api.Assumptions.assumeFalse;
2525
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2626

27+
import java.nio.charset.StandardCharsets;
2728
import java.nio.file.Files;
2829
import java.nio.file.Path;
30+
import java.util.Base64;
2931
import java.util.List;
3032
import land.oras.ContainerRef;
3133
import land.oras.exception.OrasException;
@@ -482,8 +484,7 @@ void testConfigLoad_success() throws Exception {
482484
void testPasswordContainingColonIsPreserved() throws Exception {
483485
String user = "user";
484486
String password = "p@ss:with:colons";
485-
String auth = java.util.Base64.getEncoder()
486-
.encodeToString((user + ":" + password).getBytes(java.nio.charset.StandardCharsets.UTF_8));
487+
String auth = Base64.getEncoder().encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8));
487488
// language=json
488489
String config = """
489490
{
@@ -505,10 +506,8 @@ void testPasswordContainingColonIsPreserved() throws Exception {
505506

506507
@Test
507508
void testMalformedEntryIsSkippedWithoutDroppingOtherCredentials() throws Exception {
508-
String malformed = java.util.Base64.getEncoder()
509-
.encodeToString("no-colon-here".getBytes(java.nio.charset.StandardCharsets.UTF_8));
510-
String valid = java.util.Base64.getEncoder()
511-
.encodeToString("user:password".getBytes(java.nio.charset.StandardCharsets.UTF_8));
509+
String malformed = Base64.getEncoder().encodeToString("no-colon-here".getBytes(StandardCharsets.UTF_8));
510+
String valid = Base64.getEncoder().encodeToString("user:password".getBytes(StandardCharsets.UTF_8));
512511
// language=json
513512
String config = """
514513
{
@@ -531,8 +530,7 @@ void testMalformedEntryIsSkippedWithoutDroppingOtherCredentials() throws Excepti
531530

532531
@Test
533532
void testEmptyPasswordIsPreserved() throws Exception {
534-
String auth =
535-
java.util.Base64.getEncoder().encodeToString("user:".getBytes(java.nio.charset.StandardCharsets.UTF_8));
533+
String auth = Base64.getEncoder().encodeToString("user:".getBytes(StandardCharsets.UTF_8));
536534
// language=json
537535
String config = """
538536
{
@@ -556,8 +554,7 @@ void testEmptyPasswordIsPreserved() throws Exception {
556554
void testPasswordWithArbitraryCharactersIsPreserved() throws Exception {
557555
String user = "user";
558556
String password = "p:ä ss\"w0rd\\:with=🔒:tail";
559-
String auth = java.util.Base64.getEncoder()
560-
.encodeToString((user + ":" + password).getBytes(java.nio.charset.StandardCharsets.UTF_8));
557+
String auth = Base64.getEncoder().encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8));
561558
// language=json
562559
String config = """
563560
{

0 commit comments

Comments
 (0)