You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/23 01:17:46 UTC

[GitHub] WillemJiang closed pull request #523: [SCB-272] Edge find service instances null problem

WillemJiang closed pull request #523: [SCB-272] Edge find service instances null problem
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/523
 
 
   

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/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
index 64f9a9361..d48d0bc07 100644
--- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
+++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
@@ -583,6 +583,15 @@ public void watch(String selfMicroserviceId, AsyncResultCallback<MicroserviceIns
   @Override
   public MicroserviceInstances findServiceInstances(String consumerId, String appId, String serviceName,
       String versionRule, String revision) {
+    // must register self first, and then invoke findServiceInstances
+    if (consumerId == null) {
+      LOGGER.error("find microservice instance {}/{}/{} failed, not registered to serviceCenter.",
+          appId,
+          serviceName,
+          versionRule);
+      return null;
+    }
+
     MicroserviceInstances microserviceInstances = new MicroserviceInstances();
     IpPort ipPort = ipPortManager.getAvailableAddress();
 
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
index a171531a9..56af6d2bc 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
@@ -29,6 +29,7 @@
 import org.apache.log4j.Appender;
 import org.apache.log4j.Logger;
 import org.apache.log4j.spi.LoggingEvent;
+import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory;
 import org.apache.servicecomb.serviceregistry.api.response.GetExistenceResponse;
@@ -308,4 +309,16 @@ void httpDo(RequestContext requestContext, Handler<RestResponse> responseHandler
   public void testFindServiceInstance() {
     Assert.assertNull(oClient.findServiceInstance("aaa", "bbb"));
   }
+
+  @Test
+  public void findServiceInstance_consumerId_null() {
+    new MockUp<IpPortManager>(ipPortManager) {
+      @Mock
+      IpPort getAvailableAddress() {
+        throw new Error("must not invoke this.");
+      }
+    };
+
+    Assert.assertNull(oClient.findServiceInstance(null, "appId", "serviceName", "1.0.0+"));
+  }
 }
diff --git a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/AbstractConverter.java b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/AbstractConverter.java
index 94e1b88a9..aca0295c0 100644
--- a/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/AbstractConverter.java
+++ b/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/AbstractConverter.java
@@ -70,7 +70,10 @@ public JavaType convert(ClassLoader classLoader, String packageName, Swagger swa
 
       return result;
     } catch (IllegalArgumentException e) {
-      LOGGER.info("failed to load generic class, use {}.", result.getGenericSignature(), e);
+      LOGGER.info("failed to load generic class {}, use {}. cause: {}.",
+          rawClassName,
+          result.getGenericSignature(),
+          e.getMessage());
       return result;
     }
   }


 

----------------------------------------------------------------
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