8000 chore: prepare showcase for GraalVM for JDK 17 (#3734) · googleapis/sdk-platform-java@b77a32b · GitHub
[go: up one dir, main page]

Skip to content

Commit b77a32b

Browse files
chore: prepare showcase for GraalVM for JDK 17 (#3734)
Full context in [GraalVM 17 migration doc](https://docs.google.com/document/d/1bOeGtVFLsq5ts71If5pFXCvHIeNpbtBRvF6XQfavLZs/edit?tab=t.loipy7ydvwga) Confirmation that this works: googleapis/java-shared-config@9530494 ### Problem JDK 17 `InputStreamReader` produces different bytes from JDK 18+. This affects `ITHttpAnnotation#testComplianceGroup` because of the way `compliance_suite.json` is parsed. ### Cause JDK 18 was released including commit [7fc854](openjdk/jdk@7fc8540) which enables usage of UTF-8 by default. Before this commit, each JVM will produce their own default Charset (_likely the reason we don't see this error in other CI setups using java 17_). As a confirmation, if we create an experiment test to print the default charset as in: ```java @test void verifyByteSizeOfExtremePayload() throws IOException { System.out.println(System.getProperty("file.encoding")); } ``` When using openjdk 17 we get the value `Cp1252`, and on openjdk 18 we get the value `UTF-8`. Solution ### Solution Finally, the solution is to explicitly use UTF-8 with the `InputStreamReader`
1 parent 1c0841f commit b77a32b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITHttpAnnotation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.google.showcase.v1beta1.it.util.TestClientInitializer;
3232
import java.io.IOException;
3333
import java.io.InputStreamReader;
34+
import java.nio.charset.StandardCharsets;
3435
import java.security.GeneralSecurityException;
3536
import java.util.List;
3637
import java.util.Map;
@@ -73,7 +74,8 @@ static void createClients() throws IOException, GeneralSecurityException {
7374
Objects.requireNonNull(
7475
ITHttpAnnotation.class
7576
.getClassLoader()
76-
.getResourceAsStream("compliance_suite.json"))),
77+
.getResourceAsStream("compliance_suite.json")),
78+
StandardCharsets.UTF_8),
7779
builder);
7880
complianceSuite = builder.build();
7981

0 commit comments

Comments
 (0)
0