zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject svn commit: r1381848 - in /zookeeper/bookkeeper/trunk: CHANGES.txt hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java
Date Fri, 07 Sep 2012 03:12:27 GMT
Author: sijie
Date: Fri Sep  7 03:12:27 2012
New Revision: 1381848

URL: http://svn.apache.org/viewvc?rev=1381848&view=rev
Log:
BOOKKEEPER-394: CompositeException message is not useful (Stu Hood via sijie)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1381848&r1=1381847&r2=1381848&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Sep  7 03:12:27 2012
@@ -76,6 +76,10 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-386: It should not be possible to replicate a ledger fragment which is
at the end of an open ledger (ivank & umamahesh via ivank)
 
+      hedwig-protocol:
+
+        BOOKKEEPER-394: CompositeException message is not useful (Stu Hood via sijie)
+
       hedwig-client:
 
         BOOKKEEPER-274: Hedwig cpp client library should not link to cppunit which is just
used for test. (sijie via ivank)

Modified: zookeeper/bookkeeper/trunk/hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java?rev=1381848&r1=1381847&r2=1381848&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java
(original)
+++ zookeeper/bookkeeper/trunk/hedwig-protocol/src/main/java/org/apache/hedwig/exceptions/PubSubException.java
Fri Sep  7 03:12:27 2012
@@ -18,6 +18,7 @@
 package org.apache.hedwig.exceptions;
 
 import java.util.Collection;
+import java.util.Iterator;
 
 import org.apache.hedwig.protocol.PubSubProtocol.StatusCode;
 
@@ -195,9 +196,6 @@ public abstract class PubSubException ex
         }
     }
 
-    /*
-     * Insert new ones here
-     */
     public static class UncertainStateException extends PubSubException {
         public UncertainStateException(String msg) {
             super(StatusCode.UNCERTAIN_STATE, msg);
@@ -218,19 +216,23 @@ public abstract class PubSubException ex
     public static class CompositeException extends PubSubException {
         private final Collection<PubSubException> exceptions;
         public CompositeException(Collection<PubSubException> exceptions) {
-            super(StatusCode.COMPOSITE, "composite exception");
+            super(StatusCode.COMPOSITE, compositeMessage(exceptions));
             this.exceptions = exceptions;
         }
+
         public Collection<PubSubException> getExceptions() {
             return exceptions;
         }
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append(super.toString()).append('\n');
-            for (PubSubException exception : exceptions)
-                builder.append(exception).append('\n');
-            return builder.toString();
+
+        /** Merges the message fields of the given Exceptions into a one line string. */
+        private static String compositeMessage(Collection<PubSubException> exceptions)
{
+            StringBuilder builder = new StringBuilder("Composite exception: [");
+            Iterator<PubSubException> iter = exceptions.iterator();
+            if (iter.hasNext())
+                builder.append(iter.next().getMessage());
+            while (iter.hasNext())
+                builder.append(" :: ").append(iter.next().getMessage());
+            return builder.append("]").toString();
         }
     }
 



Mime
View raw message