# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/jarda/src/netbeans/ergonomics/db # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: test/unit/src/org/netbeans/api/db/explorer/node/BaseNodeTest.java --- test/unit/src/org/netbeans/api/db/explorer/node/BaseNodeTest.java Base (BASE) +++ test/unit/src/org/netbeans/api/db/explorer/node/BaseNodeTest.java Locally New @@ -0,0 +1,119 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 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 + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.api.db.explorer.node; + +import java.awt.EventQueue; +import java.util.ResourceBundle; +import javax.swing.JComponent; +import javax.swing.JPanel; +import org.netbeans.junit.NbTestCase; +import org.netbeans.modules.db.explorer.node.DriverNode; +import static org.junit.Assert.*; +import org.openide.util.Exceptions; +import org.openide.util.lookup.Lookups; + +/** Simulates deadlock as in issue 156829, the AWT tree lock is accessed outside + * of AWT by BaseNode and its action support initialization: +
+  java.awt.KeyboardFocusManager.clearMostRecentFocusOwner:1777
+  java.awt.Component.setFocusable:6635
+  javax.swing.JSeparator.:88
+  javax.swing.JSeparator.:70
+  java.lang.reflect.Constructor.newInstance:513
+  java.lang.Class.newInstance0:355
+  java.lang.Class.newInstance:308
+  org.openide.loaders.InstanceSupport.instanceCreate:219
+  org.openide.loaders.InstanceDataObject$Ser.instanceCreate:1265
+  org.openide.loaders.InstanceDataObject.instanceCreate:749
+  org.openide.loaders.FolderLookup$ICItem.getInstance:584
+  org.openide.util.lookup.AbstractLookup$R.allInstances:974
+  org.openide.util.lookup.ProxyLookup$R.computeResult:548
+  org.openide.util.lookup.ProxyLookup$R.allInstances:489
+  org.openide.util.lookup.ProxyLookup$R.computeResult:548
+  org.openide.util.lookup.ProxyLookup$R.allInstances:489
+  org.netbeans.modules.db.explorer.action.ActionRegistry.initActions:108
+  org.netbeans.modules.db.explorer.action.ActionRegistry.loadActions:93
+  org.netbeans.modules.db.explorer.action.ActionRegistry.:80
+  org.netbeans.api.db.explorer.node.BaseNode.:156
+  org.netbeans.api.db.explorer.node.BaseNode.:131
+  org.netbeans.modules.db.explorer.node.DriverNode.:76
+  org.netbeans.modules.db.explorer.node.DriverNode.create:70
+  
+ * + * @author Jaroslav Tulach + */ +public class BaseNodeTest extends NbTestCase { + + public BaseNodeTest(String n) { + super(n); + } + + @Override + protected int timeOut() { + return 5000; + } + + @Override + protected void setUp() throws Exception { + assertNotNull("Lookup is created", Lookups.forPath("initialize")); + } + + public void testDeadlock156829() { + assertFalse("Not in AWT", EventQueue.isDispatchThread()); + class R implements Runnable { + JComponent c = new JPanel(); + public void run() { + synchronized (c.getTreeLock()) { + try { + Thread.sleep(10000); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } + } + } + } + R run = new R(); + EventQueue.invokeLater(run); + + BaseNode n = DriverNode.create(null, null); + assertNotNull("Really created without deadlock", n); + } + +} \ No newline at end of file