-
Bug
-
Resolution: Fixed
-
P4
-
8u25, 8u40
-
b52
-
x86
-
other
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084528 | emb-9 | Sergey Bylokhov | P4 | Resolved | Fixed | team |
JDK-8086885 | 8u65 | Sergey Bylokhov | P4 | Resolved | Fixed | b01 |
JDK-8078692 | 8u60 | Sergey Bylokhov | P4 | Resolved | Fixed | b14 |
JDK-8138172 | emb-8u65 | Unassigned | P4 | Resolved | Fixed | b01 |
JDK-8079989 | emb-8u60 | Sergey Bylokhov | P4 | Resolved | Fixed | team |
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
OS-X 10.9.4 (but think this affects all versions)
A DESCRIPTION OF THE PROBLEM :
BufferedImage::getPropertyNames() always returns null
----------------------------
From the source of BufferedImage I see:
public String[] getPropertyNames() {
return null;
}
Whereas the implementation of getProperty(String name) is:
public Object getProperty(String name) {
if (name == null) {
throw new NullPointerException("null property name is not allowed");
}
if (properties == null) {
return java.awt.Image.UndefinedProperty;
}
Object o = properties.get(name);
if (o == null) {
o = java.awt.Image.UndefinedProperty;
}
return o;
}
This means you can create a BufferedImage with properties but there is no way to interrogate them to establish what properties a BufferedImage has.
getPropertyNames() should be fixed t something like:
public String[] getPropertyNames() {
if (properties == null) {
return null;
}
return properties.entrySet().toArray(new String[0]); }
}
ADDITIONAL REGRESSION INFORMATION:
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b16, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create BufferedImage with some Properties.
Try listing the property names with BufferedImages::getPropertyNames()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
getPropertyNames() should return String[] with property names
ACTUAL -
getPropertyNames() returns null
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package javabugs;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.util.Properties;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author michaelellis
*/
public class JavaBugsTest {
public JavaBugsTest() {
}
@Test
public void testBufferedImageProperties() {
// Create BufferedImage easy way to create the Raster and ColorModel used later
BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
WritableRaster raster = bi.getData().createCompatibleWritableRaster();
ColorModel cm = bi.getColorModel();
// Create properties
Properties props = new Properties();
props.setProperty("Animal", "Cat");
props.setProperty("Fruit", "Apple");
// Create new BufferedImage WITH Raster, ColorModel AND Properties
BufferedImage bufferedImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), props);
// Check the properties are there
assertEquals("Cat", bufferedImage.getProperty("Animal"));
assertEquals("Apple", bufferedImage.getProperty("Fruit"));
// List the Properties - OOPS!
assertNotNull(bufferedImage.getPropertyNames());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No real work around.
SUPPORT :
YES
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
OS-X 10.9.4 (but think this affects all versions)
A DESCRIPTION OF THE PROBLEM :
BufferedImage::getPropertyNames() always returns null
----------------------------
From the source of BufferedImage I see:
public String[] getPropertyNames() {
return null;
}
Whereas the implementation of getProperty(String name) is:
public Object getProperty(String name) {
if (name == null) {
throw new NullPointerException("null property name is not allowed");
}
if (properties == null) {
return java.awt.Image.UndefinedProperty;
}
Object o = properties.get(name);
if (o == null) {
o = java.awt.Image.UndefinedProperty;
}
return o;
}
This means you can create a BufferedImage with properties but there is no way to interrogate them to establish what properties a BufferedImage has.
getPropertyNames() should be fixed t something like:
public String[] getPropertyNames() {
if (properties == null) {
return null;
}
return properties.entrySet().toArray(new String[0]); }
}
ADDITIONAL REGRESSION INFORMATION:
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b16, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create BufferedImage with some Properties.
Try listing the property names with BufferedImages::getPropertyNames()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
getPropertyNames() should return String[] with property names
ACTUAL -
getPropertyNames() returns null
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package javabugs;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.util.Properties;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author michaelellis
*/
public class JavaBugsTest {
public JavaBugsTest() {
}
@Test
public void testBufferedImageProperties() {
// Create BufferedImage easy way to create the Raster and ColorModel used later
BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
WritableRaster raster = bi.getData().createCompatibleWritableRaster();
ColorModel cm = bi.getColorModel();
// Create properties
Properties props = new Properties();
props.setProperty("Animal", "Cat");
props.setProperty("Fruit", "Apple");
// Create new BufferedImage WITH Raster, ColorModel AND Properties
BufferedImage bufferedImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), props);
// Check the properties are there
assertEquals("Cat", bufferedImage.getProperty("Animal"));
assertEquals("Apple", bufferedImage.getProperty("Fruit"));
// List the Properties - OOPS!
assertNotNull(bufferedImage.getPropertyNames());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No real work around.
SUPPORT :
YES
- backported by
-
JDK-8078692 BufferedImage::getPropertyNames() always returns null
-
- Resolved
-
-
JDK-8079989 BufferedImage::getPropertyNames() always returns null
-
- Resolved
-
-
JDK-8084528 BufferedImage::getPropertyNames() always returns null
-
- Resolved
-
-
JDK-8086885 BufferedImage::getPropertyNames() always returns null
-
- Resolved
-
-
JDK-8138172 BufferedImage::getPropertyNames() always returns null
-
- Resolved
-