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
Mon Aug 1 22:11:39 UTC 2016
On Jul 30, 2016, at 2:31 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> The synchronization doesn't look right in FileNameMapFileTypeDetector. As fileNameMap is static then synchronized (this) { ... } doesn't do what you intend.
Thanks, that was a mistake in creating this class from the code of the previous NetFileTypeDetector class.
> It's not an issue if URLConnection.getFileNameMap() is invoked more than once so I think you can reduce this down to:
>
> FileNameMap map = fileNameMap;
> if (map == null) {
> fileNameMap = map = URLConnection.getFileNameMap();
> }
> return map.getContentTypeFor(…);
Modified accordingly: http://cr.openjdk.java.net/~bpb/8146215/webrev.02/
> Alternatively just call URLConnection.getFileNameMap() each time.
URLConnection.getFileNameMap() is synchronized and returns a new anonymous class instance at each invocation so this does not look to be a good idea.
> As regards ordering what what you have it okay. I assume it will be rare to set the property content.types.user.table and so the JDK's content-types.properties will be a fallback.
Question is whether this should be a fallback on OS X and Windows as well.
Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20160801/30355bd7/attachment.html>
More information about the nio-dev
mailing list