JDK 9 RFR of 8150204: (fs) Enhance java/nio/file/Files/probeContentType/Basic.java debugging output
Alan Bateman
Alan.Bateman at oracle.com
Fri Feb 19 16:17:54 UTC 2016
On 19/02/2016 00:32, Brian Burkhalter wrote:
> Please review at your convenience this sub-task of https://bugs.openjdk.java.net/browse/JDK-8146215:
>
> Issue: https://bugs.openjdk.java.net/browse/JDK-8150204
> Patch: http://cr.openjdk.java.net/~bpb/8150204/webrev.00/
>
> Summary:
>
> If the test is running on Unix and a content type (for the bogus “grape” and the real “html” types) is obtained which differs from that which would respectively have been expected, then check for the existence and readability of /etc/mime.types and $user.home/.mime.types and print information to the maximum extent available about each of these files: 1) contents, 2) readability, 3) existence.
>
> Note that this does not help to run down whether relevant native-based file type detectors had been loaded on Linux {libgio, libmagic} or Solaris {libgio}. It would be helpful if it were possible for that sort of native initialization information to be available somehow to the test.
At some point then I think we should look at dropping the GIO based
FileTypeDetector but that is something for a different discussion. It's
hard to tell if the issue is GNOME or a bad .mime.types on the system.
I'm curious about the use of GetPropertyAction as I don't think this
test runs with a security manager. If it's needed then this might be better:
PrivilegedAction<String> pa = () ->
System.getProperty("user.home");
String value = AccessController.doPrivileged(pa);
and it will avoid needing to add @modules to this test.
It might be cleaner if you can fit this on one line:
try (Stream<String> lines = Files.lines(etcMimeTypes)) {
Also you can use lines.forEach(System.out::println) if you want
something shorter.
-Alan.
More information about the nio-dev
mailing list