-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8320943: Files/probeContentType/Basic.java fails on latest Windows 11 - content type mismatch #16916
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
Conversation
… - content type mismatch
👋 Welcome back bpb! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on my machine (w/o MS Office being installed).
private static final String EXTRA_BZ2 = IS_WIN11_PLUS ? "application/x-compressed" : ""; | ||
private static final String EXTRA_CSV = IS_WIN11_PLUS ? "application/vnd.ms-excel" : ""; | ||
private static final String EXTRA_RAR = IS_WIN11_PLUS ? "application/x-compressed" : ""; | ||
private static final String EXTRA_RTF = IS_WIN11_PLUS ? "application/msword" : ""; | ||
private static final String EXTRA_7Z = IS_WIN11_PLUS ? "application/x-compressed" : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be misleading to put a empty string into the expected set.
Could the lists be created depending on the OS?
private static final List<String> BZ2_TYPES = IS_WIN11_PLUS ?
List.of("application/bz2", "application/x-bzip2", "application/x-bzip", "application/x-compressed") ?
List.of("application/bz2", "application/x-bzip2", "application/x-bzip");
Does WIndows 11 have a (user) way to change the mapping?
For example, the mapping of .csv to vnd.ms-excel might not be correct if the user selected OpenOffice to handle .csv. I don't think we have a mechanism to cope with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does WIndows 11 have a (user) way to change the mapping?
The mapping comes from the Windows registry so it could be changed but I wouldn't expect that to be common. Part of me wonders if this test should be reduced to a small number of extensions, 30 seems a lot to have to keep up to date with changes like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the above comments, but it looks as if the Windows registry might only be able to handle one MIME type per extension. Also, I wonder how much other software was broken by this mapping change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be misleading to put a empty string into the expected set. Could the lists be created depending on the OS?
I agree. I'll see what I can change.
Does WIndows 11 have a (user) way to change the mapping? For example, the mapping of .csv to vnd.ms-excel might not be correct if the user selected OpenOffice to handle .csv. I don't think we have a mechanism to cope with that.
No, we don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of me wonders if this test should be reduced to a small number of extensions, 30 seems a lot to have to keep up to date with changes like this.
I have kept them all for the time being. If a similar problem crops up in the future, however, I agree that clamping it to a smaller number of extensions might be better. The main thing is to test whether the framework functions correctly, not that every last extension yields the expected value.
…itionally on whether it is Windows 11+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; the use of List makes it easier to customize.
@bplb This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 46 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
The tests here are just of the code that is using system APIs to map from extension to type. |
exTypes.add(new ExType("php", List.of("text/plain", "text/php", "application/x-php"))); | ||
exTypes.add(new ExType("png", List.of("image/png"))); | ||
exTypes.add(new ExType("ppt", List.of("application/vnd.ms-powerpoint"))); | ||
exTypes.add(new ExType("pptx",List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exTypes.add(new ExType("pptx",List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation"))); | |
exTypes.add(new ExType("pptx", List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation"))); |
if (OperatingSystem.isWindows() && | ||
(System.getProperty("os.name").endsWith("11") || | ||
new OSVersion(10, 0).compareTo(OSVersion.current()) > 0)) { | ||
System.out.println("Windows 11+ detected: using different types"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if the Windows 11+ types were appended to the list of types here instead of replacing the types altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/integrate |
Going to push as commit 87516e2.
Your commit was automatically rebased without conflicts. |
If Windows 11+ is detected, add an extra expected MIME type for certain file extensions.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16916/head:pull/16916
$ git checkout pull/16916
Update a local copy of the PR:
$ git checkout pull/16916
$ git pull https://git.openjdk.org/jdk.git pull/16916/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16916
View PR using the GUI difftool:
$ git pr show -t 16916
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16916.diff
Webrev
Link to Webrev Comment