8311081: KeytoolReaderP12Test.java fail on localized Windows platform

Reviewed-by: lancea, jpai, weijun
This commit is contained in:
Justin Lu 2023-08-28 20:36:32 +00:00
parent 31e26814db
commit b4b2fecb42

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -59,11 +59,14 @@ public class Utils {
public static OutputAnalyzer executeKeytoolCommand(String[] command,
int exitCode) {
String[] keytoolCmd = new String[command.length + 1];
String[] keytoolCmd = new String[command.length + 3];
OutputAnalyzer output = null;
try {
keytoolCmd[0] = JDKToolFinder.getJDKTool(KEYTOOL);
System.arraycopy(command, 0, keytoolCmd, 1, command.length);
// Ensure the keytool process is always ran under English locale
keytoolCmd[1] = "-J-Duser.language=en";
keytoolCmd[2] = "-J-Duser.country=US";
System.arraycopy(command, 0, keytoolCmd, 3, command.length);
output = ProcessTools.executeCommand(keytoolCmd);
output.shouldHaveExitValue(exitCode);
out.println("Executed keytool command sucessfully:"