From 2e00816ac30373df28a29dc938f7ce5489a3edfc Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 8 Jan 2025 20:46:57 +0000 Subject: [PATCH] 8346671: java/nio/file/Files/probeContentType/Basic.java fails on Windows 2025 Reviewed-by: jpai --- .../java/nio/file/Files/probeContentType/Basic.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/jdk/java/nio/file/Files/probeContentType/Basic.java b/test/jdk/java/nio/file/Files/probeContentType/Basic.java index 8add9e76104b0..aee1b19a01dbb 100644 --- a/test/jdk/java/nio/file/Files/probeContentType/Basic.java +++ b/test/jdk/java/nio/file/Files/probeContentType/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, 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 @@ -40,6 +40,7 @@ import jdk.internal.util.OperatingSystem; import jdk.internal.util.OSVersion; +import jdk.internal.util.StaticProperty; /** * Uses Files.probeContentType to probe html file, custom file type, and minimal @@ -83,7 +84,7 @@ private static int checkContentTypes(String expected, String actual) { if (!expected.equals(actual)) { if (!OperatingSystem.isWindows()) { Path userMimeTypes = - Path.of(System.getProperty("user.home"), ".mime.types"); + Path.of(StaticProperty.userHome(), ".mime.types"); checkMimeTypesFile(userMimeTypes); Path etcMimeTypes = Path.of("/etc/mime.types"); @@ -188,9 +189,10 @@ public static void main(String[] args) throws IOException { exTypes.add(new ExType("xlsx", List.of("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))); exTypes.add(new ExType("wasm", List.of("application/wasm"))); - // extensions with content type that differs on Windows 11+ + // extensions with content type that differs on Windows 11+ and + // Windows Server 2025 if (OperatingSystem.isWindows() && - (System.getProperty("os.name").endsWith("11") || + (StaticProperty.osName().matches("^.*[11|2025]$") || new OSVersion(10, 0).compareTo(OSVersion.current()) > 0)) { System.out.println("Windows 11+ detected: using different types"); exTypes.add(new ExType("bz2", List.of("application/bz2", "application/x-bzip2", "application/x-bzip", "application/x-compressed")));