JDK 9 RFR of 8146215: (fs) java/nio/file/Files/probeContentType/Basic.java failed frequently on Solaris-sparc with Unexpected type: text/plain
Roger Riggs
Roger.Riggs at Oracle.com
Tue Aug 2 14:21:07 UTC 2016
Hi Brian,
+1
Basic.java: Line 69: (pre-existing) Its probably useful to include the
message from the exception,
it may provide some clue as to what the problem was.
On 8/1/2016 6:11 PM, Brian Burkhalter wrote:
> On Jul 30, 2016, at 2:31 AM, Alan Bateman <Alan.Bateman at oracle.com
> <mailto: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/
> <http://cr.openjdk.java.net/%7Ebpb/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.
+1 that would provide a consistent cross-platform fallback based on the
system property "content.types.user.table".
Roger
>
> Thanks,
>
> Brian
More information about the nio-dev
mailing list