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

Alan Bateman Alan.Bateman at oracle.com
Thu Aug 4 04:21:30 UTC 2016


On 02/08/2016 17:59, Brian Burkhalter wrote:

> I’ve incorporated the previous comments:
>
> http://cr.openjdk.java.net/~bpb/8146215/webrev.03/
>
> With respect to the previous version of the patch the class FileNameMapFileTypeDetector class has been removed and the references to it removed from the Linux and Solaris FileTypeDetectors. The functionality of FileNameMapFileTypeDetector is now moved to be a fallback for all platforms directly in AbstractFileTypeDetector.probeContentType() in the event that all detected FileTypeDetectors return null for the content type.
>
> URLConnection.getFileNameMap() is modified to create and retain a single static reference to an instance of an anonymous FileNameMap class instead of creating a new instance on each invocation. The method is also no longer synchronized instead relying on an internal lock in a hopefully correct manner.
>
Does getFileNameMap() need the synchronization? I assume not, in which 
case fileNameMapLock could be removed and it could be reduced down to:

FileNameMap map = fileNameMap;
if (map == null) {
     fileNameMap = map = new FileNameMap() { ... }
}
return map;

The rest looks okay to me.

-Alan



More information about the nio-dev mailing list