Author: barrettj
Date: Sun Feb 27 14:11:00 2011
New Revision: 1075057
URL: http://svn.apache.org/viewvc?rev=1075057&view=rev
Log:
Prevent index out of bounds exception, or any exception, from attempting to
log. Add TDD/UT for same.
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/WebServiceExceptionLoggerTests.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java?rev=1075057&r1=1075056&r2=1075057&view=diff
==
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java
Sun Feb 27 14:11:00 2011
@@ -52,68 +52,80 @@ public class WebServiceExceptionLogger {
Class serviceImplClass,
Object serviceInstance,
Object[] args) {
-
-// Must have debug or error logging enabled
-if (!log.isDebugEnabled() && !log.isErrorEnabled()) {
-return;
-}
-
-// Get the root of the exception
-Throwable rootT = null;
-if (throwable instanceof InvocationTargetException) {
-rootT = ((InvocationTargetException)
throwable).getTargetException();
-}
-
-
-String name = rootT.getClass().getName();
-String stack = stackToString(rootT);
-
-// Determine if this is a checked exception or non-checked exception
-Class checkedException = JavaUtils.getCheckedException(rootT, method);
-
-if (checkedException == null) {
-// Only log errors for non-checked exceptions
-if (log.isErrorEnabled()) {
-String text = "";
-if (logFully) {
-text = Messages.getMessage("failureLogger", name,
rootT.toString());
-
-} else {
-text = Messages.getMessage("failureLogger", name, stack);
-}
-log.error(text);
+
+// No matter what happens in this logging method, do not surface that
exception. We don't want a logging
+// failure to mask the real exception we are trying to log or affect
subsequent processing.
+try {
+
+// Must have debug or error logging enabled
+if (!log.isDebugEnabled() && !log.isErrorEnabled()) {
+return;
}
-}
-
-// Full logging if debug is enabled.
-if (log.isDebugEnabled()) {
-log.debug("Exception invoking a method of " +
serviceImplClass.toString()
-+ " of instance " + serviceInstance.toString());
-log.debug("Exception type thrown: " +
throwable.getClass().getName());
-if (rootT != null) {
-log.debug("Root Exception type thrown: " +
rootT.getClass().getName());
-}
-if (checkedException != null) {
-log.debug("The exception is an instance of checked exception:
" +
- checkedException.getName());
+// Get the root of the exception
+Throwable rootT = null;
+if (throwable instanceof InvocationTargetException) {
+rootT = ((InvocationTargetException)
throwable).getTargetException();
+} else {
+rootT = throwable;
}
-// Extra trace if ElementNSImpl incompatibility problem.
-// The incompatibility exception occurs if the JAXB Unmarshaller
-// unmarshals to a dom element instead of a generated object.
This can
-// result in class cast exceptions. The solution is usually a
missing
-// @XmlSeeAlso annotation in the jaxws or jaxb classes.
-if (rootT.toString().contains("org.apache.xerces.dom.ElementNSImpl
incompatible")) {
- log.debug("This exception may be due to a missing @XmlSeeAlso
in the client's jaxws or" +
- " jaxb classes.");
+String name = rootT.getClass().getName();
+log.debug("693210: root Throwable, may cause index error: " +
rootT.toString(), rootT);
+String stack = stackToString(rootT);
+
+// Determine if this is a checked exception or non-checked
exception
+Class checkedException = JavaUtils.getCheckedException(rootT,
method);
+
+if (checkedException == null) {
+