Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8346671: java/nio/file/Files/probeContentType/Basic.java fails on Windows 2025 #1377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions test/jdk/java/nio/file/Files/probeContentType/Basic.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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")));
Expand Down