RFR: 8314094: java/lang/ProcessHandle/InfoTest.java fails on Windows when run as user with Administrator privileges
Arno Zeller
azeller at openjdk.org
Fri Aug 25 07:50:09 UTC 2023
On Wed, 16 Aug 2023 18:33:01 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> On Windows, the test java/lang/ProcessHandle/InfoTest.java can fail when run as user that is member of the Administrators group. In that case new files are not owned by the user but instead by BUILTIN\ADMINISTRATORS. This breaks the assumptions of the test's whoami check. My suggestion is to cater for this case and don't fail the test but write a warning message to stdout that a whoami check is not correctly possible.
>
> test/jdk/java/lang/ProcessHandle/InfoTest.java line 304:
>
>> 302: if (Platform.isWindows() && "BUILTIN\\Administrators".equals(whoami)) {
>> 303: System.out.println("Test seems to be run as Administrator. " +
>> 304: "Check for user correctness is not possible.");
>
> Is there an alternative way to determine the expected username?
> Perhaps by running a windows command or extracting it from the environment (System.getEnv("XX"))?
I think you might use System.getProperty("user.name"). But I am not sure about domain names of users on Windows.
I am also not sure why the user name is currently determined by creating a file - there might be a reason for this that is not obvious to me.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15222#discussion_r1305312497
More information about the core-libs-dev
mailing list