You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/17 01:31:39 UTC

[2/7] brooklyn-server git commit: big fix when simplifying exceptions; it was including far too much and not bailing out when it should

big fix when simplifying exceptions; it was including far too much and not bailing out when it should


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/e6f6638e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/e6f6638e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/e6f6638e

Branch: refs/heads/master
Commit: e6f6638ebcc6f1bdae83ccedfbd439813d8302b2
Parents: c2fe5e9
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Feb 9 15:14:26 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Feb 16 17:53:03 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/util/exceptions/Exceptions.java    |  2 +-
 .../util/exceptions/ExceptionsTest.java         | 53 ++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e6f6638e/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java
index ef6fd47..31ccfaa 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java
@@ -227,7 +227,7 @@ public class Exceptions {
                 // everything in the tree is boring...
                 return source;
             }
-            if (visited.add(collapsed)) {
+            if (!visited.add(collapsed)) {
                 // there is a recursive loop
                 break;
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e6f6638e/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java b/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java
index 29a189e..2954f6a 100644
--- a/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java
+++ b/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
+import java.io.IOException;
 import java.util.ConcurrentModificationException;
 import java.util.concurrent.ExecutionException;
 
@@ -216,6 +217,58 @@ public class ExceptionsTest {
         Assert.assertEquals(Exceptions.collapseText(t), "Invalid java type: sample");
     }
 
+    @Test
+    public void testNestedPropWithMessage() {
+        Throwable t;
+        t = new IOException("1");
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException("A", t);
+        Assert.assertEquals(Exceptions.collapseText(t), "A: IOException: 1");
+    }
+    
+    @Test
+    public void testExec() {
+        Throwable t;
+        t = new IOException("1");
+        t = new java.util.concurrent.ExecutionException(t);
+        Assert.assertEquals(Exceptions.collapseText(t), "IOException: 1");
+    }
+    
+    @Test
+    public void testNestedExecAndProp() {
+        Throwable t;
+        t = new IOException("1");
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new java.util.concurrent.ExecutionException(t);
+        Assert.assertEquals(Exceptions.collapseText(t), "IOException: 1");
+    }
+    
+    @Test
+    public void testComplexJcloudsExample() {
+        Throwable t;
+        t = new IOException("POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1 -> HTTP/1.1 401 Unauthorized");
+        t = new IllegalStateException("Not authorized to access cloud JcloudsLocation[aws-ec2:foo/aws-ec2@SEk63t8T]", t);
+        t = new java.util.concurrent.ExecutionException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException("Error invoking start at EmptySoftwareProcessImpl{id=GVYo7Cth}", t);
+        t = new java.util.concurrent.ExecutionException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new java.util.concurrent.ExecutionException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new java.util.concurrent.ExecutionException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException(t);
+        t = new org.apache.brooklyn.util.exceptions.PropagatedRuntimeException("Error invoking start at BasicApplicationImpl{id=fbihp1mo}", t);
+        t = new java.util.concurrent.ExecutionException(t);
+        
+        String collapsed = Exceptions.collapseText(t);
+        // should say IOException and POST
+        Assert.assertTrue(collapsed.contains("IOException"), collapsed);
+        Assert.assertTrue(collapsed.matches(".*POST.*"), collapsed);
+        // should not contain propagated or POST twice
+        Assert.assertFalse(collapsed.contains("Propagated"), collapsed);
+        Assert.assertFalse(collapsed.matches(".*POST.*POST.*"), collapsed);
+    }
+    
     private void assert12StandardChecks(RuntimeException e, boolean isPropagated) {
         String collapseText = Exceptions.collapseText(e);
         log.info("Exception collapsing got: "+collapseText+" ("+e+")");