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
Fri Jul 29 17:46:12 UTC 2016


On Jul 29, 2016, at 9:57 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> 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 [inconsistent] behavior across platforms again.

It depends where it is placed in the hierarchy. If it were second, after ~/.mime.types, then it could increase predictability across platforms.

> If do we use this one then I would think it has to be Linux too.

Agreed.

> 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,

OK.

>> 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.

It looks like it from [1] and it was also present in the base installation on our Solaris test systems.

Another across-the-board solution which would make things more predictable would be to bundle the Apache MIME types file, which is in the public domain [2], put it in “java.home”/mime.types, and add a MimeTypesFileTypeDetector using it to all chains.

Thanks,

Brian

[1] http://docs.oracle.com/cd/E36784_01/html/E36871/apache2-1m.html
[2] http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20160729/1474ad6c/attachment-0001.html>


More information about the nio-dev mailing list