Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
<!-- Until http://github.com/diffplug/spotless/issues/2468 -->
<version>${palantir.java.format.version}</version>
</palantirJavaFormat>
<shortenFullyQualifiedTypes />

@Maciej-Sitarz-IBM Maciej-Sitarz-IBM Aug 25, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonesbusy
I think it's best to run the shortenFullyQualifiedTypes step before importOrder and removeUnusedImports steps.

Check the source code for reference:
https://github.com/diffplug/spotless/blob/6ac5b9de0c5dbf26cc52aac4cc32600359b7f62e/lib/src/main/java/com/diffplug/spotless/java/ShortenFullyQualifiedTypesStep.java#L36

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not know the order was important here 👀 Thanks for pointing this

@Maciej-Sitarz-IBM Maciej-Sitarz-IBM Aug 25, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a better place confirming and explaining why the order matters:

New imports are appended after the existing ones, so run this before importOrder():

https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md#shortenfullyqualifiedtypes

<removeUnusedImports />
<trimTrailingWhitespace />
</java>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/land/oras/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.io.ByteArrayInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -1176,7 +1177,7 @@ private String uploadChunks(ContainerRef ref, InputStream stream, long totalSize
Const.APPLICATION_OCTET_STREAM_HEADER_VALUE,
Const.CONTENT_RANGE_HEADER,
contentRange),
() -> new java.io.ByteArrayInputStream(chunk),
() -> new ByteArrayInputStream(chunk),
Scopes.of(ref),
authProvider);
logResponse(patchResponse);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/land/oras/auth/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Builder;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpTimeoutException;
Expand Down Expand Up @@ -87,12 +90,12 @@ public final class HttpClient {
/**
* The HTTP client builder
*/
private final java.net.http.HttpClient.Builder builder;
private final Builder builder;

/**
* The HTTP client
*/
private java.net.http.HttpClient client;
private HttpClient client;

/**
* Skip TLS verification
Expand Down Expand Up @@ -834,7 +837,7 @@ private static boolean isRetryableStatus(int statusCode) {
}

private static boolean isRetryableException(Exception e) {
return e instanceof HttpTimeoutException || e instanceof java.io.IOException;
return e instanceof HttpTimeoutException || e instanceof IOException;
}

private long computeRetryDelay(@Nullable HttpResponse<?> response, int attempt) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/land/oras/policy/SigstoreVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -287,7 +288,7 @@ static byte[] preAuthEncoding(String payloadType, byte[] payload) {
* @return a non-null (possibly empty) list of successfully loaded public keys.
*/
static List<PublicKey> loadKeys(PolicyRequirement.SigstoreSigned requirement) {
java.util.List<PublicKey> keys = new java.util.ArrayList<>();
List<PublicKey> keys = new ArrayList<>();

// Single-key fields
PublicKey single = loadKey(requirement);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/land/oras/RegistryMirrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void shouldSkipDigestOnlyMirrorWhenPullingByTag(@TempDir Path blobDir) throws Ex
// Pull by tag: digest-only mirror is skipped; fallback to "original" (also down) → must fail
ContainerRef ref = ContainerRef.parse("localhost:59998/test/digest-only-mirror:v1");
assertThrows(
land.oras.exception.OrasException.class,
OrasException.class,
() -> registry.getManifest(ref),
"digest-only mirror must be skipped for a tag-based pull");
});
Expand Down Expand Up @@ -468,7 +468,7 @@ void shouldApplyMirrorByDigestOnly(@TempDir Path blobDir) throws Exception {
// Tag pull, mirror-by-digest-only skips all mirrors. Fail with original down
ContainerRef tagRef = ContainerRef.parse("localhost:59998/test/mbd-mirror:v1");
assertThrows(
land.oras.exception.OrasException.class,
OrasException.class,
() -> registry.getManifest(tagRef),
"mirror-by-digest-only must skip mirrors for tag-based pulls");

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/land/oras/RegistryWireMockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
Expand Down Expand Up @@ -1517,8 +1518,7 @@ void shouldFailChunkedUploadWhenInitiationReturnsNon202(WireMockRuntimeInfo wmRu

OrasException exStream = assertThrows(
OrasException.class,
() -> registry.pushBlobChunked(
refStream, new java.io.ByteArrayInputStream(content), content.length, 4L));
() -> registry.pushBlobChunked(refStream, new ByteArrayInputStream(content), content.length, 4L));
assertEquals(
"Failed to initiate chunked blob upload: status 500",
exStream.getMessage(),
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/land/oras/auth/RegistryConfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
Expand Down Expand Up @@ -520,7 +521,7 @@ private Path writeTempToml(String content) {
temp.toFile().deleteOnExit();
Files.writeString(temp, content);
return temp;
} catch (java.io.IOException e) {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/land/oras/policy/SigstoreVerifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ void loadsKeysFromKeyPathsAndKeyDatas(@TempDir Path dir) throws Exception {
// keyPaths list
PolicyRequirement.SigstoreSigned fromPaths = new PolicyRequirement.SigstoreSigned(
null, null, List.of(keyFile1.toString(), keyFile2.toString()), null);
List<java.security.PublicKey> loadedFromPaths = SigstoreVerifier.loadKeys(fromPaths);
List<PublicKey> loadedFromPaths = SigstoreVerifier.loadKeys(fromPaths);
assertEquals(2, loadedFromPaths.size());

// keyDatas list
PolicyRequirement.SigstoreSigned fromDatas =
new PolicyRequirement.SigstoreSigned(null, null, null, List.of(keyData1, keyData2));
List<java.security.PublicKey> loadedFromDatas = SigstoreVerifier.loadKeys(fromDatas);
List<PublicKey> loadedFromDatas = SigstoreVerifier.loadKeys(fromDatas);
assertEquals(2, loadedFromDatas.size());
}

Expand Down
10 changes: 6 additions & 4 deletions src/test/java/land/oras/utils/ArchiveUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import land.oras.LocalPath;
import land.oras.exception.OrasException;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
Expand Down Expand Up @@ -410,17 +412,17 @@ void shouldUnzipOverwriteExistingFiles(@TempDir Path tmp) throws IOException {
byte[] secondContent = "second-overwritten".getBytes();

Path zip1 = tmp.resolve("first.zip");
try (java.util.zip.ZipOutputStream zout = new java.util.zip.ZipOutputStream(Files.newOutputStream(zip1))) {
zout.putNextEntry(new java.util.zip.ZipEntry("file.txt"));
try (ZipOutputStream zout = new ZipOutputStream(Files.newOutputStream(zip1))) {
zout.putNextEntry(new ZipEntry("file.txt"));
zout.write(firstContent);
zout.closeEntry();
}
ArchiveUtils.unzip(zip1, target);
assertEquals("first", Files.readString(target.resolve("file.txt")));

Path zip2 = tmp.resolve("second.zip");
try (java.util.zip.ZipOutputStream zout = new java.util.zip.ZipOutputStream(Files.newOutputStream(zip2))) {
zout.putNextEntry(new java.util.zip.ZipEntry("file.txt"));
try (ZipOutputStream zout = new ZipOutputStream(Files.newOutputStream(zip2))) {
zout.putNextEntry(new ZipEntry("file.txt"));
zout.write(secondContent);
zout.closeEntry();
}
Expand Down
Loading