/*
* 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 6318664
* @summary Test deadlock in MBeanRegistration.preDeregister method
* @author Eamonn McManus
* @run clean PreDeregisterDeadlockTest
* @run build PreDeregisterDeadlockTest
* @run main PreDeregisterDeadlockTest
*/
import javax.management.*;
public class PreDeregisterDeadlockTest {
public static interface BlibbyMBean {}
}
return on;
}
public void preDeregister() {
return;
try {
public void run() {
try {
} catch (Throwable e) {
}
}
};
t.start();
t.join(5000L);
if (t.isAlive())
fail("Deadlock detected");
} catch (Throwable e) {
}
}
public void postDeregister() {}
}
public static interface BlobbyMBean {}
}
this.objectName = on;
return on;
}
public void run() {
try {
fail("Nested unregister succeeded");
} catch (InstanceNotFoundException e) {
} catch (Throwable e) {
}
}
};
t.start();
// Give the thread a chance to block so we are really
// testing parallelism. (On slow machines we might not
// really be testing it but we should be covered by our
// faster machines.)
}
public void postDeregister() {}
}
// Test 1: preDeregister starts a thread which unregisters a
// different MBean: this must not deadlock
// Test 2: preDeregister starts a thread which tries to
// unregister the same MBean: this thread should block until
// the original thread succeeds in unregistering, then
// get an InstanceNotFoundException. We wait for it to
// complete here, using the semaphore.
if (!ok)
fail("Second unregister thread did not complete");
else
}
}
}