JDK-7025938 : Add bitmap mime type to content-types.properties
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-03-09
  • Updated: 2013-09-11
  • Resolved: 2011-09-07
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 7 JDK 8
7u40Fixed 8 b04Fixed
Description
It is a little odd to me that I find OpenJDK JarURLConnection does not support bmp file. The testcase below:

public static void main(String[] args) throws MalformedURLException, IOException {
        JarURLConnection conn = (JarURLConnection) new URL("jar:file:/somedir/somejar.jar!/somebmp.bmp").openConnection();
        System.out.printf("Returned type for the entry should be the known type " +
                "image/bmp, but it is " + conn.getContentType());
    }

    (Need create a somejar.jar containing a bmp file named somebmp.bmp)

    It should return image/bmp but it does not. I see we may add image/bmp support in the windows\lib\content-types.properties to make the testcase pass. However I am not sure if OpenJDK do want to support it, or there is some reason why OpenJDK don't? 

see discussion on net-dev mailing list:
  http://mail.openjdk.java.net/pipermail/net-dev/2011-March/002780.html

Comments
run the test in Openjdk b103, verified.
11-09-2013

EVALUATION Add bitmap mime type support to content-types.properties, so that URLConnection.getContentType() returns 'image/bmp' rather than 'content/unknown'. This is not a commonly used API, but the contribution seems reasonable. Changeset: 46b53f80ab0a Author: chegar Date: 2011-08-19 10:55 +0100 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/46b53f80ab0a 7025938: Add bitmap mime type to content-types.properties Reviewed-by: chegar, alanb, michaelm Contributed-by: lvjing at linux.vnet.ibm.com ! src/solaris/lib/content-types.properties ! src/windows/lib/content-types.properties
19-08-2011

SUGGESTED FIX diff -r af15e902cf08 src/solaris/lib/content-types.properties --- a/src/solaris/lib/content-types.properties Wed Aug 10 12:30:29 2011 +0100 +++ b/src/solaris/lib/content-types.properties Thu Aug 18 17:36:31 2011 +0100 @@ -225,6 +225,10 @@ image/png: \ icon=png;\ action=browser +image/bmp: \ + description=Bitmap Image;\ + file_extensions=.bmp; + text/html: \ description=HTML Document;\ file_extensions=.htm,.html;\ diff -r af15e902cf08 src/windows/lib/content-types.properties --- a/src/windows/lib/content-types.properties Wed Aug 10 12:30:29 2011 +0100 +++ b/src/windows/lib/content-types.properties Thu Aug 18 17:36:31 2011 +0100 @@ -222,6 +222,10 @@ image/png: \ icon=png;\ action=browser +image/bmp: \ + description=Bitmap Image;\ + file_extensions=.bmp; + text/html: \ description=HTML Document;\ file_extensions=.htm,.html;\
19-08-2011