mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Merge pull request #2123 from rsvoboda/use.utf8.fixes
Avoid depending on platform's default charset
This commit is contained in:
@@ -528,7 +528,7 @@ public class NativeImagePhase implements AppCreationPhase<NativeImagePhase>, Nat
|
||||
|
||||
process = idPB.start();
|
||||
try (InputStream inputStream = process.getInputStream()) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
responseBuilder.append(line);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.Provider;
|
||||
@@ -183,7 +184,7 @@ public final class TestProcessor {
|
||||
if (is == null) {
|
||||
throw new IOException("Failed to load resource: " + path);
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||
String base64 = reader.readLine();
|
||||
reader.close();
|
||||
byte[] encoded = Base64.getDecoder().decode(base64);
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -205,9 +206,10 @@ public class ConfiguredBeanTest {
|
||||
// From config.xml
|
||||
Socket socket = new Socket("localhost", 12345);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write("testRuntimeXmlConfigService\n".getBytes());
|
||||
os.write("testRuntimeXmlConfigService\n".getBytes("UTF-8"));
|
||||
os.flush();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String reply = reader.readLine();
|
||||
Assertions.assertEquals("testRuntimeXmlConfigService-ack", reply);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
@@ -86,11 +87,11 @@ public class RuntimeXmlConfigService {
|
||||
}
|
||||
|
||||
void run() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||
String command = reader.readLine();
|
||||
log.infof("Received command: %s", command);
|
||||
String reply = command + "-ack";
|
||||
os.write(reply.getBytes());
|
||||
os.write(reply.getBytes("UTF-8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -90,7 +92,7 @@ class AddExtensionMojoTest {
|
||||
|
||||
private Model reload() throws IOException, XmlPullParserException {
|
||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
try (Reader fr = new FileReader(OUTPUT_POM)) {
|
||||
try (Reader fr = Files.newBufferedReader(OUTPUT_POM.toPath())) {
|
||||
return reader.read(fr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.IllegalClassFormatException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -107,7 +108,7 @@ public class ReflectionAgent {
|
||||
Set<String> known = new HashSet<>();
|
||||
try (InputStream in = Thread.currentThread().getContextClassLoader()
|
||||
.getResourceAsStream("META-INF/reflective-classes.txt")) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
known.add(line);
|
||||
|
||||
@@ -20,6 +20,7 @@ import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;
|
||||
import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -219,13 +220,13 @@ public final class HibernateOrmProcessor {
|
||||
@BuildStep
|
||||
void setupResourceInjection(BuildProducer<ResourceAnnotationBuildItem> resourceAnnotations,
|
||||
BuildProducer<GeneratedResourceBuildItem> resources,
|
||||
JpaEntitiesBuildItem jpaEntities, List<NonJpaModelBuildItem> nonJpaModels) {
|
||||
JpaEntitiesBuildItem jpaEntities, List<NonJpaModelBuildItem> nonJpaModels) throws UnsupportedEncodingException {
|
||||
if (!hasEntities(jpaEntities, nonJpaModels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
resources.produce(new GeneratedResourceBuildItem("META-INF/services/io.quarkus.arc.ResourceReferenceProvider",
|
||||
JPAResourceReferenceProvider.class.getName().getBytes()));
|
||||
JPAResourceReferenceProvider.class.getName().getBytes("UTF-8")));
|
||||
resourceAnnotations.produce(new ResourceAnnotationBuildItem(PERSISTENCE_CONTEXT));
|
||||
resourceAnnotations.produce(new ResourceAnnotationBuildItem(PERSISTENCE_UNIT));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.quarkus.kubernetes.deployment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,7 +37,7 @@ class KubernetesProcessor {
|
||||
@BuildStep
|
||||
public void build(ApplicationInfoBuildItem applicationInfo,
|
||||
KubernetesConfig kubernetesConfig,
|
||||
List<KubernetesPortBuildItem> kubernetesPortBuildItems) {
|
||||
List<KubernetesPortBuildItem> kubernetesPortBuildItems) throws UnsupportedEncodingException {
|
||||
|
||||
if (kubernetesPortBuildItems.isEmpty()) {
|
||||
return;
|
||||
@@ -69,7 +70,7 @@ class KubernetesProcessor {
|
||||
new GeneratedResourceBuildItem(
|
||||
// we need to make sure we are only passing the relative path to the build item
|
||||
resourceEntry.getKey().replace(root.toAbsolutePath() + "/", "META-INF/kubernetes/"),
|
||||
resourceEntry.getValue().getBytes()));
|
||||
resourceEntry.getValue().getBytes("UTF-8")));
|
||||
}
|
||||
|
||||
featureProducer.produce(new FeatureBuildItem(FeatureBuildItem.KUBERNETES));
|
||||
|
||||
@@ -135,11 +135,11 @@ public class SwaggerUiProcessor {
|
||||
}
|
||||
|
||||
private void updateApiUrl(Path indexHtml) throws IOException {
|
||||
String content = new String(Files.readAllBytes(indexHtml));
|
||||
String content = new String(Files.readAllBytes(indexHtml), "UTF-8");
|
||||
Matcher uriMatcher = SWAGGER_UI_DEFAULT_API_URL_PATTERN.matcher(content);
|
||||
if (uriMatcher.matches()) {
|
||||
content = uriMatcher.replaceFirst("$1" + openapi.path + "$3");
|
||||
Files.write(indexHtml, content.getBytes());
|
||||
Files.write(indexHtml, content.getBytes("UTF-8"));
|
||||
} else {
|
||||
log.warn("Unable to replace the default URL of Swagger UI");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JCATestCase {
|
||||
PublicKey publicKey = keyPair.getPublic();
|
||||
byte[] encoded = publicKey.getEncoded();
|
||||
byte[] pemEncoded = Base64.getEncoder().encode(encoded);
|
||||
String pemString = new String(pemEncoded);
|
||||
String pemString = new String(pemEncoded, "UTF-8");
|
||||
|
||||
RestAssured.given()
|
||||
.queryParam("pemEncoded", pemString)
|
||||
@@ -53,7 +53,7 @@ public class JCATestCase {
|
||||
PublicKey publicKey = keyPair.getPublic();
|
||||
byte[] encoded = publicKey.getEncoded();
|
||||
byte[] pemEncoded = Base64.getEncoder().encode(encoded);
|
||||
String pemString = new String(pemEncoded);
|
||||
String pemString = new String(pemEncoded, "UTF-8");
|
||||
|
||||
RestAssured.given()
|
||||
.queryParam("msg", "Hello verifyRSASig")
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -23,9 +24,10 @@ public class ExtensionTestCase {
|
||||
// From config.xml
|
||||
Socket socket = new Socket("localhost", 12345);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write("testRuntimeXmlConfigService\n".getBytes());
|
||||
os.write("testRuntimeXmlConfigService\n".getBytes("UTF-8"));
|
||||
os.flush();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String reply = reader.readLine();
|
||||
Assertions.assertEquals("testRuntimeXmlConfigService-ack", reply);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user