Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/480#discussion_r101868849
  
    --- Diff: 
utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java 
---
    @@ -263,8 +264,41 @@ public static Throwable 
collapseIncludingAllCausalMessages(Throwable source) {
         public static Throwable collapse(Throwable source, boolean 
collapseCausalChain) {
             return collapse(source, collapseCausalChain, false, 
ImmutableSet.<Throwable>of(), new Object[0]);
         }
    +
    +    /** As {@link Throwables#getCausalChain(Throwable)} but safe in the 
face of perverse classes which return themselves as their cause or otherwise 
have a recursive causal chain. */
    +    public static List<Throwable> getCausalChain(Throwable t) {
    --- End diff --
    
    Add to `ExceptionsTest`:
    ```
        @Test
        public void testGetCausalChain() throws Exception {
            Exception e1 = new Exception("e1");
            Exception e2 = new Exception("e2", e1);
            assertEquals(Exceptions.getCausalChain(e2), ImmutableList.of(e2, 
e1));
        }
        
        @Test
        public void testGetCausalChainRecursive() throws Exception {
            Exception e1 = new Exception("e1") {
                public synchronized Throwable getCause() {
                    return this;
                }
            };
            Exception e2 = new Exception("e2", e1);
            assertEquals(Exceptions.getCausalChain(e2), ImmutableList.of(e2, 
e1));
        }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to