diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java index bd0627b22552..4267082afea5 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java @@ -34,7 +34,6 @@ import java.util.*; * @author yole */ public class NativeFileIconProvider implements FileIconProvider { - private final JFileChooser myFileChooser = new JFileChooser(); private final Map myIconCache = new HashMap(); // on Windows .exe and .ico files provide their own icons which can differ for each file, cache them by full file path private final Set myCustomIconExtensions = @@ -68,8 +67,8 @@ public class NativeFileIconProvider implements FileIconProvider { return null; } Icon icon; - try { - icon = myFileChooser.getIcon(f); + try { // VM will ensure lock to init -static final field--, note we should have no read access here, to avoid deadlock with EDT needed to init component + icon = SwingComponentHolder.ourFileChooser.getIcon(f); } catch (Exception e) { // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4854174 return null; @@ -89,6 +88,10 @@ public class NativeFileIconProvider implements FileIconProvider { }); } + static class SwingComponentHolder { + private static final JFileChooser ourFileChooser = new JFileChooser(); + } + protected boolean isNativeFileType(VirtualFile file) { return ElementBase.isNativeFileType(file.getFileType()); }