Index: options.keymap/src/org/netbeans/modules/options/keymap/KeymapModel.java =================================================================== --- options.keymap/src/org/netbeans/modules/options/keymap/KeymapModel.java (revision 21) +++ options.keymap/src/org/netbeans/modules/options/keymap/KeymapModel.java (working copy) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -67,25 +67,29 @@ private static final Logger LOG = Logger.getLogger(KeymapModel.class.getName ()); private static final Logger UI_LOG = Logger.getLogger("org.netbeans.ui.options"); // NOI18N - private static ArrayList al = new ArrayList(); + private static ArrayList al = null; /** * @return All the registered implementations. */ public static Collection getKeymapManagerInstances() { - if (!al.isEmpty()) { + if (null != al) { return al; } - al.addAll(Lookup.getDefault().lookupAll(KeymapManager.class)); - - if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Dumping registered KeymapManagers: "); - for(KeymapManager m : al) { - LOG.fine(" KeymapManager: " + s2s(m)); + + synchronized (KeymapModel.class) { + if (null == al) { + al = new ArrayList(Lookup.getDefault().lookupAll(KeymapManager.class)); + al.trimToSize(); + if (LOG.isLoggable(Level.FINE)) { + LOG.fine("Dumping registered KeymapManagers: "); + for (KeymapManager m : al) { + LOG.fine(" KeymapManager: " + s2s(m)); + } + LOG.fine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + } } - LOG.fine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } - return al; }