Bug 45485: Agent now throws RuntimeException instead of Errors when jmxtools.jar is missing at runtime or other problems
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/trunk@682998 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/log4j/jmx/Agent.java b/src/main/java/org/apache/log4j/jmx/Agent.java
index a632cb1..a71a1ac 100644
--- a/src/main/java/org/apache/log4j/jmx/Agent.java
+++ b/src/main/java/org/apache/log4j/jmx/Agent.java
@@ -45,6 +45,7 @@
/**
* Create new instance.
+ * @deprecated
*/
public Agent() {
}
@@ -61,12 +62,8 @@
try {
newInstance = Class.forName(
"com.sun.jdmk.comm.HtmlAdapterServer").newInstance();
- } catch (ClassNotFoundException ex) {
- throw new NoClassDefFoundError(ex.toString());
- } catch (IllegalAccessException ex) {
- throw new IllegalAccessError(ex.toString());
- } catch (InstantiationException ex) {
- throw new InstantiationError(ex.toString());
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
}
return newInstance;
}
@@ -81,18 +78,22 @@
try {
server.getClass().getMethod("start", new Class[0]).
invoke(server, new Object[0]);
- } catch(NoSuchMethodException ex) {
- throw new NoSuchMethodError(ex.toString());
- } catch(IllegalAccessException ex) {
- throw new IllegalAccessError(ex.toString());
} catch(InvocationTargetException ex) {
- throw (RuntimeException) ex.getTargetException();
+ Throwable cause = ex.getTargetException();
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException) cause;
+ } else {
+ throw new RuntimeException(cause);
+ }
+ } catch(Exception ex) {
+ throw new RuntimeException(ex);
}
}
/**
* Starts instance of HtmlAdapterServer.
+ * @deprecated
*/
public void start() {