commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r428147 - /jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
Date Wed, 02 Aug 2006 21:02:22 GMT
Author: rdonkin
Date: Wed Aug  2 14:02:21 2006
New Revision: 428147

URL: http://svn.apache.org/viewvc?rev=428147&view=rev
Log:
Improved error reporting in the case of a cycle reference. Based on JIRA BETWIXT-54 contributed
by Holger Haag. This reduces the level at which the error is reported to info but compensates
by adding more useful information to the exception.

Modified:
    jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java

Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java?rev=428147&r1=428146&r2=428147&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/AbstractBeanWriter.java
Wed Aug  2 14:02:21 2006
@@ -1019,15 +1019,23 @@
                 // use absolute equality rather than equals
                 // we're only really bothered if objects are actually the same
                 if ( bean == next ) {
-                    if ( log.isDebugEnabled() ) {
-                        log.debug("Element stack: ");
-                        Iterator debugStack = beanStack.iterator();
-                        while ( debugStack.hasNext() ) {
-                            log.debug(debugStack.next());
-                        }
+                    final String message = "Cyclic reference at bean: " + bean;
+                    log.error(message);
+                    StringBuffer buffer = new StringBuffer(message);
+                    buffer.append(" Stack: ");
+                    Iterator errorStack = beanStack.iterator();
+                    while ( errorStack.hasNext() ) {
+                          Object errorObj = errorStack.next();
+                          if(errorObj != null) {
+                              buffer.append(errorObj.getClass().getName());
+                              buffer.append(": ");
+                          }
+                          buffer.append(errorObj);
+                          buffer.append(";");
                     }
-                    log.error("Cyclic reference at bean: " + bean);
-                    throw new CyclicReferenceException();
+                    final String debugMessage = buffer.toString();
+                    log.info( debugMessage );
+                    throw new CyclicReferenceException( debugMessage );
                 }
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message