-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
b157
-
x86
-
other
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175644 | 10 | Lance Andersen | P3 | Resolved | Fixed | b02 |
FULL PRODUCT VERSION :
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
OS X:
Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
The mime type for .png files as supplied by javax.activation.FileTypeMap and
javax.activation.MimetypesFileTypeMap seems to be missing. When using the getContentType() method from these classes to lookup the mime type for a file name, they return "application/octet-stream" and not "image/png".
REGRESSION. Last worked in version 7u51
ADDITIONAL REGRESSION INFORMATION:
Can confirm the issue does not exist in:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call one of the following methods:
MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(String);
FileTypeMap.getDefaultFileTypeMap().getContentType(String);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
With a file name ending in ".png", I expect them to return "application/png"
ACTUAL -
With a file name ending in ".png" they return "application/octet-stream"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Test Case:
import javax.activation.FileTypeMap;
import javax.activation.MimetypesFileTypeMap;
public class ContentTypeTest {
public static void main(String... args) throws Exception {
System.out.printf("Testing Java verision %s\n", System.getProperties().getProperty("java.version"));
String[] map[] = new String[][]{
{"foo.png", "image/png",},
{"foo.gif", "image/gif",},
{"foo.jpg", "image/jpeg",},
{"foo.jpeg", "image/jpeg"},
{"foo.tiff", "image/tiff"}
};
for (String pair[] : map) {
String ex = pair[0];
String tp = pair[1];
String mftm = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(ex);
String ftm = FileTypeMap.getDefaultFileTypeMap().getContentType(ex);
boolean ok = true;
if (!tp.equals(mftm)) {
ok = false;
}
if (!tp.equals(ftm)) {
ok = false;
}
if (ok) {
System.out.printf("%s: OK\n", tp);
} else {
System.out.printf("%s: ERROR, FileTypeMap = %s, MimetypesFileTypeMap = %s\n", tp, ftm, mftm);
}
}
}
}
---------- END SOURCE ----------
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
OS X:
Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
The mime type for .png files as supplied by javax.activation.FileTypeMap and
javax.activation.MimetypesFileTypeMap seems to be missing. When using the getContentType() method from these classes to lookup the mime type for a file name, they return "application/octet-stream" and not "image/png".
REGRESSION. Last worked in version 7u51
ADDITIONAL REGRESSION INFORMATION:
Can confirm the issue does not exist in:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call one of the following methods:
MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(String);
FileTypeMap.getDefaultFileTypeMap().getContentType(String);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
With a file name ending in ".png", I expect them to return "application/png"
ACTUAL -
With a file name ending in ".png" they return "application/octet-stream"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Test Case:
import javax.activation.FileTypeMap;
import javax.activation.MimetypesFileTypeMap;
public class ContentTypeTest {
public static void main(String... args) throws Exception {
System.out.printf("Testing Java verision %s\n", System.getProperties().getProperty("java.version"));
String[] map[] = new String[][]{
{"foo.png", "image/png",},
{"foo.gif", "image/gif",},
{"foo.jpg", "image/jpeg",},
{"foo.jpeg", "image/jpeg"},
{"foo.tiff", "image/tiff"}
};
for (String pair[] : map) {
String ex = pair[0];
String tp = pair[1];
String mftm = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(ex);
String ftm = FileTypeMap.getDefaultFileTypeMap().getContentType(ex);
boolean ok = true;
if (!tp.equals(mftm)) {
ok = false;
}
if (!tp.equals(ftm)) {
ok = false;
}
if (ok) {
System.out.printf("%s: OK\n", tp);
} else {
System.out.printf("%s: ERROR, FileTypeMap = %s, MimetypesFileTypeMap = %s\n", tp, ftm, mftm);
}
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8175644 No mime type for .png files
-
- Resolved
-
- relates to
-
JDK-8162745 content-types.properties files are missing some modern types
-
- Closed
-