-
CSR
-
Resolution: Approved
-
P4
-
None
-
minimal
-
Java API
-
SE
Summary
The java.awt.image.BufferedImage class is not thread-safe, but one of its methods was marked as synchronized.
Problem
The method setRGB(int x, int y, int rgb) in BufferedImage is synchronized, but all other methods in this class are not. For example the similar methods:
setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) and get methods:
getRGB(int x, int y)
getRGB(int, int, int, int, int[], int, int).
Solution
The synchronized keyword should be removed.
Specification
src/java.desktop/share/classes/java/awt/image/BufferedImage.java:
* @param y the Y coordinate of the pixel to set
* @param rgb the RGB value
* @see #getRGB(int, int)
* @see #getRGB(int, int, int, int, int[], int, int)
*/
- public synchronized void setRGB(int x, int y, int rgb) {
+ public void setRGB(int x, int y, int rgb) {
raster.setDataElements(x, y, colorModel.getDataElements(rgb, null));
}
- csr of
-
JDK-8183576 Synchronization in BufferedImage.setRGB(int x, int y, int rgb) is not necessary
- Resolved