Skip to content

Commit

Permalink
Remove calls to APIs unavailable in jdk17u (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
swesonga authored Nov 1, 2024
1 parent 6e49897 commit 4babac7
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -66,7 +67,7 @@ private static String getWindowsVersion() throws IOException {
OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
outputAnalyzer.shouldHaveExitValue(0);
outputAnalyzer.shouldContain(osVersionMessage);
List<String> lines = outputAnalyzer.stdoutAsLines();
List<String> lines = asLines(outputAnalyzer.getStdout());

String osVersion = null;
for (var line: lines) {
Expand All @@ -80,6 +81,10 @@ private static String getWindowsVersion() throws IOException {
return osVersion;
}

private static List<String> asLines(String buffer) {
return Arrays.asList(buffer.split("\\R"));
}

private static boolean getSchedulesAllProcessorGroups(boolean isWindowsServer) throws IOException {
String windowsVer = getWindowsVersion();
String[] parts = windowsVer.split(" ");
Expand Down Expand Up @@ -115,7 +120,7 @@ private static boolean getSchedulesAllProcessorGroups(boolean isWindowsServer) t
private static OutputAnalyzer getAvailableProcessorsOutput(boolean productFlagEnabled) throws IOException {
String productFlag = productFlagEnabled ? "-XX:+UseAllWindowsProcessorGroups" : "-XX:-UseAllWindowsProcessorGroups";

ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
new String[] {productFlag, "GetAvailableProcessors"}
);

Expand All @@ -128,7 +133,7 @@ private static OutputAnalyzer getAvailableProcessorsOutput(boolean productFlagEn

private static int getAvailableProcessors(OutputAnalyzer outputAnalyzer) {
int runtimeAvailableProcs = 0;
List<String> output = outputAnalyzer.stdoutAsLines();
List<String> output = asLines(outputAnalyzer.getStdout());

for (var line: output) {
if (line.startsWith(runtimeAvailableProcessorsMessage)) {
Expand Down Expand Up @@ -188,7 +193,7 @@ private static void testProcessorAvailability() throws IOException {
boolean isWindowsServer = false;
var processorGroupSizes = new HashSet<Integer>();

List<String> lines = outputAnalyzer.stdoutAsLines();
List<String> lines = asLines(outputAnalyzer.getStdout());

for (var line: lines) {
if (line.startsWith(totalProcessorCountMessage)) {
Expand Down

0 comments on commit 4babac7

Please sign in to comment.