JDK 9 RFR of 8146215: (fs) java/nio/file/Files/probeContentType/Basic.java failed frequently on Solaris-sparc with Unexpected type: text/plain

Brian Burkhalter brian.burkhalter at oracle.com
Thu Jul 28 23:55:09 UTC 2016


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.

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.

Thanks,

Brian

[1] http://docs.oracle.com/cd/E36784_01/html/E36871/apache2-1m.html


More information about the nio-dev mailing list