mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 08:09:17 +02:00
Restore @ThreadSafe and @Immutable annotations (#1613)
This commit is contained in:
@@ -15,11 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.pkl.core.http;
|
package org.pkl.core.http;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.ThreadSafe;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.net.http.HttpResponse.BodyHandler;
|
import java.net.http.HttpResponse.BodyHandler;
|
||||||
|
|
||||||
/** An {@code HttpClient} implementation that throws {@code AssertionError} on every send. */
|
/** An {@code HttpClient} implementation that throws {@code AssertionError} on every send. */
|
||||||
|
@ThreadSafe
|
||||||
final class DummyHttpClient implements HttpClient {
|
final class DummyHttpClient implements HttpClient {
|
||||||
@Override
|
@Override
|
||||||
public <T> HttpResponse<T> send(HttpRequest request, BodyHandler<T> responseBodyHandler) {
|
public <T> HttpResponse<T> send(HttpRequest request, BodyHandler<T> responseBodyHandler) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.pkl.core.http;
|
package org.pkl.core.http;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.ThreadSafe;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -49,6 +50,7 @@ import org.pkl.core.util.ErrorMessages;
|
|||||||
import org.pkl.core.util.Exceptions;
|
import org.pkl.core.util.Exceptions;
|
||||||
|
|
||||||
/** An {@code HttpClient} implementation backed by {@link java.net.http.HttpClient}. */
|
/** An {@code HttpClient} implementation backed by {@link java.net.http.HttpClient}. */
|
||||||
|
@ThreadSafe
|
||||||
final class JdkHttpClient implements HttpClient {
|
final class JdkHttpClient implements HttpClient {
|
||||||
// non-private for testing
|
// non-private for testing
|
||||||
final java.net.http.HttpClient underlying;
|
final java.net.http.HttpClient underlying;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.pkl.core.http;
|
package org.pkl.core.http;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.ThreadSafe;
|
||||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.http.HttpRequest;
|
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
|
* An {@code HttpClient} decorator that defers creating the underlying HTTP client until the first
|
||||||
* send.
|
* send.
|
||||||
*/
|
*/
|
||||||
|
@ThreadSafe
|
||||||
final class LazyHttpClient implements HttpClient {
|
final class LazyHttpClient implements HttpClient {
|
||||||
private final Supplier<HttpClient> supplier;
|
private final Supplier<HttpClient> supplier;
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.pkl.core.http;
|
package org.pkl.core.http;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.ThreadSafe;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
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
|
* <p>Both {@code User-Agent} header and default request timeout are configurable through {@link
|
||||||
* HttpClient.Builder}.
|
* HttpClient.Builder}.
|
||||||
*/
|
*/
|
||||||
|
@ThreadSafe
|
||||||
final class RequestRewritingClient implements HttpClient {
|
final class RequestRewritingClient implements HttpClient {
|
||||||
// non-private for testing
|
// non-private for testing
|
||||||
final String userAgent;
|
final String userAgent;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.pkl.core.util;
|
package org.pkl.core.util;
|
||||||
|
|
||||||
|
import com.google.errorprone.annotations.Immutable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +28,7 @@ import java.util.Arrays;
|
|||||||
*
|
*
|
||||||
* @author Thibault Debatty
|
* @author Thibault Debatty
|
||||||
*/
|
*/
|
||||||
|
@Immutable
|
||||||
public final class StringSimilarity {
|
public final class StringSimilarity {
|
||||||
private static final double DEFAULT_THRESHOLD = 0.7;
|
private static final double DEFAULT_THRESHOLD = 0.7;
|
||||||
private static final int THREE = 3;
|
private static final int THREE = 3;
|
||||||
|
|||||||
Reference in New Issue
Block a user