pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] merlimat closed pull request #938: Handle and log uncaught exception
Date Thu, 01 Jan 1970 00:00:00 GMT
merlimat closed pull request #938: Handle and log uncaught exception
URL: https://github.com/apache/incubator-pulsar/pull/938
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
index bed78fc76..596137933 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
@@ -511,7 +511,7 @@ public synchronized void asyncAddEntry(ByteBuf buffer, AddEntryCallback
callback
                         config.getAckQuorumSize(), config.getDigestType(), config.getPassword(),
this, ctx);
             }
         } else {
-            checkArgument(state == State.LedgerOpened);
+            checkArgument(state == State.LedgerOpened, "ledger=%s is not opened", state);
 
             // Write into lastLedger
             addOperation.setLedger(currentLedger);
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
index 9ebf6a84f..af28c11f0 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
@@ -106,7 +106,11 @@ public void failed(ManagedLedgerException e) {
 
     @Override
     public void addComplete(int rc, final LedgerHandle lh, long entryId, Object ctx) {
-        checkArgument(ledger.getId() == lh.getId());
+        if (ledger.getId() != lh.getId()) {
+            log.warn("[{}] ledgerId {} doesn't match with acked ledgerId {}", ml.getName(),
ledger.getId(), lh.getId());
+        }
+        checkArgument(ledger.getId() == lh.getId(), "ledgerId %s doesn't match with acked
ledgerId %s", ledger.getId(),
+                lh.getId());
         checkArgument(this.ctx == ctx);
 
         this.entryId = entryId;
@@ -173,7 +177,8 @@ public void safeRun() {
 
     @Override
     public void closeComplete(int rc, LedgerHandle lh, Object ctx) {
-        checkArgument(ledger.getId() == lh.getId());
+        checkArgument(ledger.getId() == lh.getId(), "ledgerId %s doesn't match with acked
ledgerId %s", ledger.getId(),
+                lh.getId());
 
         if (rc == BKException.Code.OK) {
             log.debug("Successfuly closed ledger {}", lh.getId());
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/StatsBuckets.java
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/StatsBuckets.java
index 037ad2ddf..6d08bf498 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/StatsBuckets.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/StatsBuckets.java
@@ -102,7 +102,9 @@ public double getAvg() {
     }
 
     public void addAll(StatsBuckets other) {
-        checkArgument(boundaries.length == other.boundaries.length);
+        checkArgument(boundaries.length == other.boundaries.length,
+                "boundaries size %s doesn't match with given boundaries size %s", boundaries.length,
+                other.boundaries.length);
 
         for (int i = 0; i < buckets.length; i++) {
             buckets[i].add(other.values[i]);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
index 6ddaea60d..5beebc52f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
@@ -215,7 +215,7 @@ protected void validateBrokerName(String broker) throws MalformedURLException
{
         String brokerUrl = String.format("http://%s", broker);
         if (!pulsar().getWebServiceAddress().equals(brokerUrl)) {
             String[] parts = broker.split(":");
-            checkArgument(parts.length == 2);
+            checkArgument(parts.length == 2, "Invalid broker url %s", broker);
             String host = parts[0];
             int port = Integer.parseInt(parts[1]);
 
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 45b464628..0ba8b762a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -776,7 +776,7 @@ public Semaphore getLookupRequestSemaphore() {
 
     public void checkGC(int gcIntervalInSeconds) {
         topics.forEach((n, t) -> {
-            Topic topic = t.getNow(null);
+            Topic topic = t.isCompletedExceptionally() ? null : t.getNow(null);
             if (topic != null) {
                 topic.checkGC(gcIntervalInSeconds);
             }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message