Restore @ThreadSafe and @Immutable annotations (#1613)

This commit is contained in:
Daniel Chao
2026-05-22 15:58:09 -07:00
committed by GitHub
parent 648f9143bf
commit a1eea47b3f
5 changed files with 10 additions and 0 deletions
@@ -15,11 +15,13 @@
*/
package org.pkl.core.http;
import com.google.errorprone.annotations.ThreadSafe;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandler;
/** An {@code HttpClient} implementation that throws {@code AssertionError} on every send. */
@ThreadSafe
final class DummyHttpClient implements HttpClient {
@Override
public <T> HttpResponse<T> send(HttpRequest request, BodyHandler<T> responseBodyHandler) {
@@ -15,6 +15,7 @@
*/
package org.pkl.core.http;
import com.google.errorprone.annotations.ThreadSafe;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -49,6 +50,7 @@ import org.pkl.core.util.ErrorMessages;
import org.pkl.core.util.Exceptions;
/** An {@code HttpClient} implementation backed by {@link java.net.http.HttpClient}. */
@ThreadSafe
final class JdkHttpClient implements HttpClient {
// non-private for testing
final java.net.http.HttpClient underlying;
@@ -15,6 +15,7 @@
*/
package org.pkl.core.http;
import com.google.errorprone.annotations.ThreadSafe;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import java.io.IOException;
import java.net.http.HttpRequest;
@@ -28,6 +29,7 @@ import org.jspecify.annotations.Nullable;
* An {@code HttpClient} decorator that defers creating the underlying HTTP client until the first
* send.
*/
@ThreadSafe
final class LazyHttpClient implements HttpClient {
private final Supplier<HttpClient> supplier;
private final Object lock = new Object();
@@ -15,6 +15,7 @@
*/
package org.pkl.core.http;
import com.google.errorprone.annotations.ThreadSafe;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -49,6 +50,7 @@ import org.pkl.core.util.Pair;
* <p>Both {@code User-Agent} header and default request timeout are configurable through {@link
* HttpClient.Builder}.
*/
@ThreadSafe
final class RequestRewritingClient implements HttpClient {
// non-private for testing
final String userAgent;
@@ -15,6 +15,7 @@
*/
package org.pkl.core.util;
import com.google.errorprone.annotations.Immutable;
import java.util.Arrays;
/**
@@ -27,6 +28,7 @@ import java.util.Arrays;
*
* @author Thibault Debatty
*/
@Immutable
public final class StringSimilarity {
private static final double DEFAULT_THRESHOLD = 0.7;
private static final int THREE = 3;