PostRegisterDeadlockTest.java revision 2362
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6417044
* @summary Test deadlock in MBeanRegistration.postRegister method
* @author Eamonn McManus, Daniel Fuchs
* @run clean PostRegisterDeadlockTest
* @run build PostRegisterDeadlockTest
* @run main PostRegisterDeadlockTest
*/
import javax.management.*;
public class PostRegisterDeadlockTest {
public static interface BlibbyMBean {}
}
return on;
}
public void preDeregister() {}
// If no other MBean was registered
// do nothing.
//
// Check that we can unregister
// other MBean
try {
public void run() {
try {
try {
} catch (InstanceNotFoundException x) {
// Race condition!
" was unregistered by main thread.");
}
} catch (Throwable e) {
}
}
};
t.start();
t.join(5000L);
if (t.isAlive()) {
fail("Deadlock detected");
else
fail("Test not conclusive: "+
"Thread is alive but not blocked.");
}
} catch (Throwable e) {
}
}
public void postDeregister() {}
private final MBeanServer mbs;
private final ObjectName otherName;
}
// Test 1:
// 1 MBean is registered with on1
// Another MBean is registered with on1, postRegister(FALSE) is
// called, and the second MBean attempts to unregister first MBean in
// postRegister:
// postRegister starts a thread which unregisters the first MBean:
// this must not deadlock
//
try {
} catch (InstanceAlreadyExistsException x) {
}
try {
} catch (InstanceNotFoundException x) {
// Race condition!
}
} else {
}
// Test 2:
// 1 MBean is registered with on1
// Another MBean is registered with on2, postRegister(TRUE) is
// called, and the second MBean attempts to unregister first MBean in
// postRegister:
// postRegister starts a thread which unregisters the first MBean:
// this must not deadlock
//
try {
} catch (InstanceNotFoundException x) {
// Race condition!
}
} else {
}
else
}
}
}