Skip to content

Commit

Permalink
8346671: java/nio/file/Files/probeContentType/Basic.java fails on Win…
Browse files Browse the repository at this point in the history
…dows 2025

Reviewed-by: jpai
  • Loading branch information
Brian Burkhalter committed Jan 8, 2025
1 parent 88fa3b2 commit 2e00816
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 2e00816

Please sign in to comment.