You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cs...@apache.org on 2019/11/28 10:39:29 UTC

[sling-org-apache-sling-distribution-journal] branch master updated (3005671 -> 95aff37)

This is an automated email from the ASF dual-hosted git repository.

cschneider pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git.


    from 3005671  SLING-8863 - Only trigger circuit breaker once (#15)
     new da9d03d  SLING-8863 - Show more details in log message
     new 95aff37  Fix warning

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                            |  1 +
 .../journal/impl/shared/JournalAvailableChecker.java  | 19 ++++++++++++++++---
 .../journal/impl/shared/PackageViewerPlugin.java      |  1 -
 .../impl/shared/JournalAvailableCheckerTest.java      |  6 +++---
 4 files changed, 20 insertions(+), 7 deletions(-)


[sling-org-apache-sling-distribution-journal] 01/02: SLING-8863 - Show more details in log message

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git

commit da9d03d4053fad045b561fcfeefcba872831b0c8
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Wed Nov 27 20:12:43 2019 +0100

    SLING-8863 - Show more details in log message
---
 .gitignore                                            |  1 +
 .../journal/impl/shared/JournalAvailableChecker.java  | 19 ++++++++++++++++---
 .../impl/shared/JournalAvailableCheckerTest.java      |  6 +++---
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5b783ed..aa74147 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ maven-eclipse.xml
 .DS_Store
 jcr.log
 atlassian-ide-plugin.xml
+/.vscode/
diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java b/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
index eb878b2..ea479a5 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
@@ -18,8 +18,8 @@
  */
 package org.apache.sling.distribution.journal.impl.shared;
 
+import static java.time.temporal.ChronoUnit.MILLIS;
 import static java.time.temporal.ChronoUnit.MINUTES;
-import static java.time.temporal.ChronoUnit.SECONDS;
 import static java.util.Objects.requireNonNull;
 
 import java.time.Duration;
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
 )
 public class JournalAvailableChecker implements EventHandler {
     
-    private static final Duration INITIAL_RETRY_DELAY = Duration.of(1, SECONDS);
+    private static final Duration INITIAL_RETRY_DELAY = Duration.of(500, MILLIS);
     private static final Duration MAX_RETRY_DELAY = Duration.of(5, MINUTES);
 
     // Minimal number of errors before journal is considered unavailable
@@ -113,11 +113,24 @@ public class JournalAvailableChecker implements EventHandler {
         if (LOG.isDebugEnabled()) {
             LOG.warn(msg, e);
         } else {
-            LOG.warn(msg);
+            LOG.warn(accumulatedMessage(e));
         }
         this.marker.unRegister();
     }
     
+    private String accumulatedMessage(Exception e) {
+        StringBuilder msg = new StringBuilder();
+        Throwable th = e;
+        do {
+            msg.append(th.getMessage());
+            th = th.getCause();
+            if (th != null) {
+                msg.append(". Caused by: ");
+            }
+        } while (th != null);
+        return msg.toString();
+    }
+
     public boolean isAvailable() {
         return this.marker.isRegistered();
     }
diff --git a/src/test/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableCheckerTest.java b/src/test/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableCheckerTest.java
index fb407a2..40c7666 100644
--- a/src/test/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableCheckerTest.java
+++ b/src/test/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableCheckerTest.java
@@ -81,7 +81,7 @@ public class JournalAvailableCheckerTest {
     @Before
     public void before() throws Exception {
         when(metrics.createGauge(Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(gauge);
-        doThrow(new MessagingException("topic is invalid"))
+        doThrow(new MessagingException("topic is invalid", new RuntimeException("Nested exception")))
                 .when(provider).assertTopic(INVALID_TOPIC);
         when(context.registerService(Mockito.eq(JournalAvailable.class), Mockito.any(JournalAvailable.class), Mockito.any()))
                 .thenReturn(sreg);
@@ -108,7 +108,7 @@ public class JournalAvailableCheckerTest {
     }
 
     @Test
-    public void testActivateChecksOnEvent() {
+    public void testActivateChecksOnEvent() throws InterruptedException {
         await("At the start checks are triggers and should set the state available")
             .until(checker::isAvailable);
         
@@ -119,7 +119,7 @@ public class JournalAvailableCheckerTest {
         // Signal second exception to checker to start the checks. Now we should see not available
         checker.handleEvent(event);
         await().until(() -> !checker.isAvailable());
-        
+        Thread.sleep(1000); // Make sure we get at least one failed doCheck
         makeCheckSucceed();
         await().until(checker::isAvailable);
     }


[sling-org-apache-sling-distribution-journal] 02/02: Fix warning

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git

commit 95aff37fbe28226b0d0ee327d2ea529397223b61
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Thu Nov 28 11:36:47 2019 +0100

    Fix warning
---
 .../sling/distribution/journal/impl/shared/PackageViewerPlugin.java      | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/shared/PackageViewerPlugin.java b/src/main/java/org/apache/sling/distribution/journal/impl/shared/PackageViewerPlugin.java
index a1648e8..30f8836 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/shared/PackageViewerPlugin.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/shared/PackageViewerPlugin.java
@@ -25,7 +25,6 @@ import java.util.List;
 import java.util.Optional;
 
 import javax.servlet.Servlet;
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;