aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorant <none@none>2009-12-04 15:07:15 +0300
committerant <none@none>2009-12-04 15:07:15 +0300
commita1502f8104176905209ae1d2cbec8ceab692e01d (patch)
treeda705858713e0f5f745dab7f449ccc8d001b0922
parentab351de0c91c0ea21acda50bf1325ac9c5a445a8 (diff)
6903354: deadlock involving Component.show & SunToolkit.getImageFromHash
Reviewed-by: art, bae
-rw-r--r--src/share/classes/sun/awt/SunToolkit.java38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java
index 3c7f16dff..0b1e7aab4 100644
--- a/src/share/classes/sun/awt/SunToolkit.java
+++ b/src/share/classes/sun/awt/SunToolkit.java
@@ -800,9 +800,9 @@ public abstract class SunToolkit extends Toolkit
}
- static SoftCache imgCache = new SoftCache();
+ static final SoftCache imgCache = new SoftCache();
- static synchronized Image getImageFromHash(Toolkit tk, URL url) {
+ static Image getImageFromHash(Toolkit tk, URL url) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
try {
@@ -830,32 +830,36 @@ public abstract class SunToolkit extends Toolkit
sm.checkConnect(url.getHost(), url.getPort());
}
}
- Image img = (Image)imgCache.get(url);
- if (img == null) {
- try {
- img = tk.createImage(new URLImageSource(url));
- imgCache.put(url, img);
- } catch (Exception e) {
+ synchronized (imgCache) {
+ Image img = (Image)imgCache.get(url);
+ if (img == null) {
+ try {
+ img = tk.createImage(new URLImageSource(url));
+ imgCache.put(url, img);
+ } catch (Exception e) {
+ }
}
+ return img;
}
- return img;
}
- static synchronized Image getImageFromHash(Toolkit tk,
+ static Image getImageFromHash(Toolkit tk,
String filename) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(filename);
}
- Image img = (Image)imgCache.get(filename);
- if (img == null) {
- try {
- img = tk.createImage(new FileImageSource(filename));
- imgCache.put(filename, img);
- } catch (Exception e) {
+ synchronized (imgCache) {
+ Image img = (Image)imgCache.get(filename);
+ if (img == null) {
+ try {
+ img = tk.createImage(new FileImageSource(filename));
+ imgCache.put(filename, img);
+ } catch (Exception e) {
+ }
}
+ return img;
}
- return img;
}
public Image getImage(String filename) {