Skip to content

Commit b0fdd64

Browse files
author
Myron Scott
committed
remove JMX detection, not needed
1 parent 542b151 commit b0fdd64

File tree

2 files changed

+0
-103
lines changed

2 files changed

+0
-103
lines changed

common/src/main/java/com/tc/lang/ThrowableHandlerImpl.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,6 @@ public void addCallbackOnExitExceptionHandler(Class c, CallbackOnExitHandler exi
9999
public void handleThrowable(final Thread thread, final Throwable t) {
100100
handlePossibleOOME(t);
101101

102-
if (isThreadGroupDestroyed(thread, t)) {
103-
logger.warn("Ignoring an attempt to start a JMX thread during shutdown.", t);
104-
return;
105-
}
106-
107-
if (isJMXTerminatedException(t)) {
108-
logger.warn("Ignoring a Thread Service termination error from JMX.", t);
109-
return;
110-
}
111-
112-
if (isNotificationFetcherThread(thread)) {
113-
// DEV-5006 -- Do not exit L2.
114-
logger.warn("Got Exception in JMX Notification forwarding", t);
115-
return;
116-
}
117-
118102
final CallbackOnExitState throwableState = new CallbackOnExitState(t);
119103
scheduleExit(throwableState);
120104

@@ -137,19 +121,6 @@ public void handleThrowable(final Thread thread, final Throwable t) {
137121
exit(throwableState);
138122
}
139123

140-
private static boolean isThreadGroupDestroyed(Thread thread, Throwable t) {
141-
// see EHCTERR-32
142-
if (t instanceof IllegalThreadStateException) {
143-
StackTraceElement[] stack = t.getStackTrace();
144-
StackTraceElement bottom = stack[stack.length - 1];
145-
if (stack[0].getClassName().equals("java.lang.ThreadGroup") && stack[0].getMethodName().equals("addUnstarted")
146-
&& bottom.getClassName().equals("javax.management.remote.generic.GenericConnectorServer$Receiver")
147-
&& bottom.getMethodName().equals("run")) { return true; }
148-
}
149-
150-
return false;
151-
}
152-
153124
/**
154125
* Makes sure we don't allocate any heap objects on OOME.
155126
* {@code -XX:+HeapDumpOnOutOfMemoryError} should take care of debug information.
@@ -227,26 +198,4 @@ protected synchronized void exit(int status) {
227198
ThreadUtil.reallySleep(2000);
228199
System.exit(status);
229200
}
230-
231-
private static boolean isNotificationFetcherThread(Thread thread) {
232-
// UGLY Way to Ignore exception in JMX Notification Forwarder Thread.
233-
try {
234-
Field runnableField = thread.getClass().getDeclaredField("target");
235-
runnableField.setAccessible(true);
236-
Object runnable = runnableField.get(thread);
237-
if (runnable != null && runnable.getClass().getSimpleName().equals("NotifFetcher")) {
238-
return true;
239-
} else {
240-
return false;
241-
}
242-
} catch (Throwable e) {
243-
return false;
244-
}
245-
246-
}
247-
248-
private static boolean isJMXTerminatedException(Throwable throwable) {
249-
return throwable instanceof IllegalStateException &&
250-
throwable.getMessage().contains("The Thread Service has been terminated.");
251-
}
252201
}

common/src/test/java/com/tc/lang/ThrowableHandlerTest.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,58 +54,6 @@ protected void exit(int status) {
5454
assertEquals(-1, exitCode.get());
5555
}
5656

57-
public void testHandleJMXThreadServiceTermination() throws Exception {
58-
final AtomicBoolean exited = new AtomicBoolean(false);
59-
ThrowableHandler throwableHandler = new ThrowableHandlerImpl(TCLogging.getLogger(getClass())) {
60-
@Override
61-
protected synchronized void exit(final int status) {
62-
exited.set(true);
63-
}
64-
};
65-
throwableHandler.handleThrowable(Thread.currentThread(),
66-
new IllegalStateException("The Thread Service has been terminated."));
67-
assertFalse(exited.get());
68-
}
69-
70-
public void testIsThreadGroupDestroyed() throws Exception {
71-
final AtomicBoolean exited = new AtomicBoolean(false);
72-
ThrowableHandler throwableHandler = new ThrowableHandlerImpl(TCLogging.getLogger(getClass())) {
73-
@Override
74-
protected synchronized void exit(final int status) {
75-
exited.set(true);
76-
}
77-
};
78-
79-
Runnable r = new Runnable() {
80-
@Override
81-
public void run() {
82-
//
83-
84-
}
85-
};
86-
87-
ThreadGroup threadGroup = new ThreadGroup("blah");
88-
Thread thread = new Thread(threadGroup, r);
89-
thread.start();
90-
thread.join();
91-
threadGroup.destroy();
92-
93-
Throwable t = null;
94-
try {
95-
new Thread(threadGroup, r);
96-
} catch (Throwable th) {
97-
t = th;
98-
}
99-
100-
StackTraceElement[] stack = t.getStackTrace();
101-
stack[stack.length - 1] = new StackTraceElement("javax.management.remote.generic.GenericConnectorServer$Receiver",
102-
"run", "Foo.java", 12);
103-
t.setStackTrace(stack);
104-
105-
throwableHandler.handleThrowable(thread, t);
106-
assertFalse(exited.get());
107-
}
108-
10957
private class TestCallbackOnExitHandler implements CallbackOnExitHandler {
11058

11159
@Override

0 commit comments

Comments
 (0)