JDK-7144997 : (fs) Files.probeContentType returns null on Solaris 64-bit
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • CPU: generic
  • Submitted: 2012-02-13
  • Updated: 2013-03-26
  • Resolved: 2012-12-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b68Fixed
Related Reports
Relates :  
Relates :  
Description
On solaris 64bit machine, run with 64bit java, Files.probeContentType returns right type without -d64 but returns null with -d64

Test to reproduce the issue:
============================
import java.nio.file.*;
import java.io.*;

public class Basic {

    static Path createHtmlFile() throws IOException {
        Path file = Files.createTempFile("foo", ".html");
        try (OutputStream out = Files.newOutputStream(file)) {
            out.write("<html><body>foo</body></html>".getBytes());
        }

        return file;
    }

    public static void main(String[] args) throws IOException {

        // exercise default file type detector
        Path file = createHtmlFile();
        try {
            String type = Files.probeContentType(file);
            System.out.println("type=" + type);
            if (type == null) {
                System.err.println("Content type is null, should be text/html");
            } else {
                if (!type.equals("text/html"))
                    throw new RuntimeException("Unexpected type: " + type);
            }

        } finally {
            Files.delete(file);
        }


    }
}


Output without and with -d64 (on same machine)
============================
bash-3.00$ $JAVA_HOME/bin/java Basic 
type=text/html

bash-3.00$ $JAVA_HOME/bin/java -d64 Basic 
type=null
Content type is null, should be text/html

Comments
Verified in b80
26-03-2013

This issue is Solaris 10 64-bit only and therefore not a high priority. The changes proposed for JDK-7142921 will provide a solution although it won't use the GNOME libraries so it means there may be behavior difference between 32-bit and 64-bit.
03-12-2012

EVALUATION The FileTypeDetector that we include on Solaris uses GNOME GIO with fallback the Gnome VFS for older releases. Solaris does not ship with 64-bit versions of these libraries so it essentially means that the JDK does not have a default FileTypeDetector on Solaris 64-bit.
13-02-2012