Migrate a bug fix for printStackTrace which was done before the JAXP 1.3 integration
back to the head. git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3fa88a3b2
commit
57c5a282f3
@ -312,49 +312,62 @@ public class TransformerException extends Exception {
|
|||||||
super.printStackTrace(s);
|
super.printStackTrace(s);
|
||||||
} catch (Throwable e) {}
|
} catch (Throwable e) {}
|
||||||
|
|
||||||
Throwable exception = getException();
|
boolean isJdk14OrHigher = false;
|
||||||
|
try {
|
||||||
|
Throwable.class.getMethod("getCause",null);
|
||||||
|
isJdk14OrHigher = true;
|
||||||
|
} catch (NoSuchMethodException nsme) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; (i < 10) && (null != exception); i++) {
|
// The printStackTrace method of the Throwable class in jdk 1.4
|
||||||
s.println("---------");
|
// and higher will include the cause when printing the backtrace.
|
||||||
|
// The following code is only required when using jdk 1.3 or lower
|
||||||
|
if (!isJdk14OrHigher) {
|
||||||
|
Throwable exception = getException();
|
||||||
|
|
||||||
try {
|
for (int i = 0; (i < 10) && (null != exception); i++) {
|
||||||
if (exception instanceof TransformerException) {
|
s.println("---------");
|
||||||
String locInfo =
|
|
||||||
((TransformerException) exception)
|
try {
|
||||||
|
if (exception instanceof TransformerException) {
|
||||||
|
String locInfo =
|
||||||
|
((TransformerException) exception)
|
||||||
.getLocationAsString();
|
.getLocationAsString();
|
||||||
|
|
||||||
if (null != locInfo) {
|
if (null != locInfo) {
|
||||||
s.println(locInfo);
|
s.println(locInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exception.printStackTrace(s);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
s.println("Could not print stack trace...");
|
||||||
}
|
}
|
||||||
|
|
||||||
exception.printStackTrace(s);
|
try {
|
||||||
} catch (Throwable e) {
|
Method meth =
|
||||||
s.println("Could not print stack trace...");
|
((Object) exception).getClass().getMethod("getException",
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Method meth =
|
|
||||||
((Object) exception).getClass().getMethod("getException",
|
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (null != meth) {
|
if (null != meth) {
|
||||||
Throwable prev = exception;
|
Throwable prev = exception;
|
||||||
|
|
||||||
exception = (Throwable) meth.invoke(exception, null);
|
exception = (Throwable) meth.invoke(exception, null);
|
||||||
|
|
||||||
if (prev == exception) {
|
if (prev == exception) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exception = null;
|
||||||
}
|
}
|
||||||
} else {
|
} catch (InvocationTargetException ite) {
|
||||||
|
exception = null;
|
||||||
|
} catch (IllegalAccessException iae) {
|
||||||
|
exception = null;
|
||||||
|
} catch (NoSuchMethodException nsme) {
|
||||||
exception = null;
|
exception = null;
|
||||||
}
|
}
|
||||||
} catch (InvocationTargetException ite) {
|
|
||||||
exception = null;
|
|
||||||
} catch (IllegalAccessException iae) {
|
|
||||||
exception = null;
|
|
||||||
} catch (NoSuchMethodException nsme) {
|
|
||||||
exception = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// insure output is written
|
// insure output is written
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user