JDK 9 RFR of 8146215: (fs) java/nio/file/Files/probeContentType/Basic.java failed frequently on Solaris-sparc with Unexpected type: text/plain
Alan Bateman
Alan.Bateman at oracle.com
Fri Jul 29 16:57:08 UTC 2016
On 29/07/2016 00:55, Brian Burkhalter wrote:
> Please review at your convenience.
>
> Issue: https://bugs.openjdk.java.net/browse/JDK-8146215
> Patch: http://cr.openjdk.java.net/~bpb/8146215/webrev.00/
>
> On Solaris only, append to the FileTypeDetectors chain a FileTypeDetector which uses the java.net.FileNameMap returned by URLConnection.getFileNameMap() to probe for the MIME type. Also clean up probeContentType/Basic a little.
>
> Note that this FileNameMap-based detector is not really platform-specific, so if desired it could as well be used on other platforms perhaps as a fallback detector, i.e., the last one in each of the respective chains.
A concern with this increases the potential behavior across platforms
again. If do we use this one then I would think it has to be Linux too.
On the implementation then fileNameMap should be volatile. You can
introduce a local `map` when reading it. You should also make
fileNameMap static as you only need to obtain the FileNameMap once,
> On Solaris there is also the possibility of using a MimeTypesFileTypeDetector with the Apache MIME types file /etc/apache2/2.2/mime.types which is available by default on Solaris 11 [1]. There does not however appear to be a straightforward programmatic way of locating this file, so if for example the version number were to change to 2.3, the file would not be found if the name were hard-coded. This suggests that if it were desirable to use the Apache MIME types file, some provision for dynamically locating it in the file system would be needed.
>
I don't know if this Apache bundling is documented or not but I think
would just make things very unpredictable.
-Alan
More information about the nio-dev
mailing list