-
CSR
-
Resolution: Approved
-
P3
-
behavioral
-
minimal
-
-
Java API
-
SE
Summary
Synchronize the methods of FilteredImageSource to avoid NullPointerExceptions while accessing the HashTable.
Problem
A NullPointerException was observed at java.awt.image.FilteredImageSource.startProduction method.
FilteredImageSource instantiates a HashTable for its operation. The methods- startProduction and requestTopDownLeftRightResend of FilteredImageSource read or update this HashTable in un-synchronized manner. In a multi-threaded environment, the un-synchronized access to the HashTable is susceptible to the exceptions as reported in the bug.
Solution
The proposed solution makes the concerned methods 'synchronized' after duly evaluating possibilities for deadlocks.
Specification
/**
* This class is an implementation of the ImageProducer interface which
* takes an existing image and a filter object and uses them to produce
-- * image data for a new filtered version of the original image.
++ * image data for a new filtered version of the original image. Furthermore,
++ * {@code FilteredImageSource} is safe for use by multiple threads.
-- public void startProduction(ImageConsumer ic) {
++ public synchronized void startProduction(ImageConsumer ic) {
-- public void requestTopDownLeftRightResend(ImageConsumer ic) {
++ public synchronized void requestTopDownLeftRightResend(ImageConsumer ic) {
- csr of
-
JDK-8188083 NullPointerExcpn-java.awt.image.FilteredImageSource.startProduction JDK-8079607
-
- Resolved
-