Use StandardCharsets in OkHttpUtil.

okhttp3.internal.Util.UTF_8 was never meant to be used outside of
okhttp3 library; and it has been deleted in later versions.
Signal should use java.nio.charset.StandardCharsets instead.
No functional change.

Closes #12413
This commit is contained in:
Victor Ding
2022-08-23 12:53:17 +00:00
committed by Greyson Parrelli
parent 13f3a8cf8a
commit b92dd19a4c

View File

@@ -6,13 +6,12 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import static okhttp3.internal.Util.UTF_8;
public final class OkHttpUtil {
private OkHttpUtil() {}
@@ -42,7 +41,7 @@ public final class OkHttpUtil {
byte[] data = readAsBytes(body.byteStream(), sizeLimit);
MediaType contentType = body.contentType();
Charset charset = contentType != null ? contentType.charset(UTF_8) : UTF_8;
Charset charset = contentType != null ? contentType.charset(StandardCharsets.UTF_8) : StandardCharsets.UTF_8;
return new String(data, Objects.requireNonNull(charset));
}