You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/08/03 00:44:20 UTC

[servicecomb-java-chassis] 01/02: [SCB-2056]print a verbose log when no registration is configured

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit 05eda5c2050573bf7fadd1015a67a0f9e614f985
Author: liubao <bi...@qq.com>
AuthorDate: Fri Jul 31 17:27:37 2020 +0800

    [SCB-2056]print a verbose log when no registration is configured
---
 .../org/apache/servicecomb/registry/RegistrationManager.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
index 14aaae5..36ac3d1 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/RegistrationManager.java
@@ -85,10 +85,19 @@ public class RegistrationManager {
   }
 
   public Microservice getMicroservice() {
+    assertPrimaryNotNull();
     return primary.getMicroservice();
   }
 
+  private void assertPrimaryNotNull() {
+    if (primary == null) {
+      throw new NullPointerException("At least one Registration implementation configured. Missed"
+          + " to include dependency ? e.g. <artifactId>registry-service-center</artifactId>");
+    }
+  }
+
   public String getAppId() {
+    assertPrimaryNotNull();
     return primary.getAppId();
   }