Review Request: JDK-7142921,(fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04

Alan Bateman Alan.Bateman at
Mon Nov 26 05:46:28 PST 2012

On 26/11/2012 06:40, Dan Xu wrote:
> Hi,
> Please help review the code changes for CR 7142921 and CR 7144997. The 
> webrev is uploaded to,
> In the fix, I added two new file type detectors, one is 
> MimeTypesFileTypeDetector, and the other is 
> MagicFileTypeDetector.MimeTypesFileTypeDetector is using a file name 
> extension to look up its MIME type by checking mime.types files, which 
> can be used in Linux, Solaris, and Mac.MagicFileTypeDetector is using 
> libmagic to detect a file type in Linux. The library, libmagic, is 
> provided in the same package of file command, which is currently only 
> available in Linux platform.
> Thanks,
> -Dan
Thanks for taking this on. I don't have time to do a detailed review of 
the two new FileTypeDetector implementations but just some initial 
comments on the the other changes:

1. I don't think AbstractFileTypeDetector should be changed to check if 
the file exists and is a directory, maybe you intended this check to be 
in the libmagic based FileTypeDetector?

2. If we are using /etc/mime.types then we might also have to look at 
${user.home}/mime.types as I think that can be used to override the 
mapping in /etc.

3. It would be good to add a comment to UnixFileSystemProvider.chain. 
Also if the line length is a problem when you can probably drop 
protected as the usage is package-private anyway.

Otherwise the make file updates looks fine. I will get back to you soon 
on the magic and mimetypes detectors, just can't spend time on it today. 
The other big thing with this proposal is to agree the priority of the 
detectors, we also need to consider the diagnosability on each platform 
(needs to be easy for the user to understand how the file type is 
determined). Finally, we should double check that 
/private/etc/apache2/mime.types is the right place to look on Mac.


-------------- next part --------------
An HTML attachment was scrubbed...

More information about the nio-dev mailing list