RFR: 8287237: (fs) Files.probeContentType returns null if filename contains hash mark on Linux
Jaikiran Pai
jpai at openjdk.java.net
Fri May 27 12:17:16 UTC 2022
On Thu, 26 May 2022 23:03:05 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Modify `sun.net.www.MimeTable.findByFileName(String)` to attempt to find the file extension in the entire file name if it is not found in the portion of the name preceding the optional fragment beginning with a hash (`#`).
src/java.base/share/classes/sun/net/www/MimeTable.java line 164:
> 162: public MimeEntry findByFileName(String fname) {
> 163: // attempt to find the entry with the fragment component removed
> 164: MimeEntry entry = findByFileName(fname, true);
I think we might need a check here first to see if the `fname` contains `#` and if it does, only then call the `findByFileName` with `true`. Without that check, with the change in this PR, it's now possible that the `findByFileName` will get called twice (once with `true` and once with `false`) for the case where the filename doesn't have a `#` and whose extension isn't in the MimeTable.
src/java.base/share/classes/sun/net/www/MimeTable.java line 183:
> 181: * @return the MIME entry associated with the file name
> 182: */
> 183: public MimeEntry findByFileName(String fname, boolean removeFragment) {
Hello Brian,
Perhaps this new method can be made `private` (and maybe even `static`)?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8909
More information about the nio-dev
mailing list