You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/01 01:11:00 UTC

[jira] [Commented] (SCB-562) Java Chassis will throw NPE when producer impl do not contain any method

    [ https://issues.apache.org/jira/browse/SCB-562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497433#comment-16497433 ] 

ASF GitHub Bot commented on SCB-562:
------------------------------------

WillemJiang closed pull request #729: [SCB-562] fix NPE when had empty interface (not have any method)
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/729
 
 
   

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/core/src/main/java/org/apache/servicecomb/core/definition/SchemaMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/SchemaMeta.java
index 565290479..1a4e6f91d 100644
--- a/core/src/main/java/org/apache/servicecomb/core/definition/SchemaMeta.java
+++ b/core/src/main/java/org/apache/servicecomb/core/definition/SchemaMeta.java
@@ -83,6 +83,12 @@ public String getPackageName() {
   }
 
   private void initOperations() {
+    if (swagger.getPaths() == null) {
+      LOGGER.warn(swagger.getInfo().getTitle() + " with path " + swagger.getBasePath()
+          + " is an empty interface, please delete it or fill with one method!");
+      return;
+    }
+
     for (Entry<String, Path> entry : swagger.getPaths().entrySet()) {
       String strPath = entry.getKey();
       Path path = entry.getValue();


 

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


> Java Chassis will throw NPE when producer impl do not contain any method
> ------------------------------------------------------------------------
>
>                 Key: SCB-562
>                 URL: https://issues.apache.org/jira/browse/SCB-562
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Java-Chassis
>    Affects Versions: java-chassis-1.0.0-m1
>            Reporter: yangyongzheng
>            Assignee: yangyongzheng
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m2
>
>
> If a producer impl do not contain any method like :
> ```java
> @RestSchema(schemaId = "hello")
> @Path("/")
> public class HelloImpl {
> }
> ```
> Then an NPE will throw  when startup:
> 2018-05-09 08:50:04,333 [ERROR] cse init failed, 
> Exception: java.lang.NullPointerException; null
> java.lang.NullPointerException
> 	at org.apache.servicecomb.swagger.generator.core.utils.ClassUtils.createInterface(ClassUtils.java:212)
> 	at org.apache.servicecomb.swagger.generator.core.utils.ClassUtils.getOrCreateInterface(ClassUtils.java:203)
> 	at org.apache.servicecomb.swagger.generator.core.utils.ClassUtils.getOrCreateInterface(ClassUtils.java:182)
> 	at org.apache.servicecomb.core.definition.schema.AbstractSchemaFactory.generateSwagger(AbstractSchemaFactory.java:112)
> 	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.createSchema(ProducerSchemaFactory.java:110)
> 	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.createSchema(ProducerSchemaFactory.java:47)
> 	at org.apache.servicecomb.core.definition.schema.AbstractSchemaFactory.getOrCreateSchema(AbstractSchemaFactory.java:65)
> 	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.getOrCreateProducerSchema(ProducerSchemaFactory.java:80)
> 	at org.apache.servicecomb.provider.rest.common.RestProducerProvider.init(RestProducerProvider.java:48)
> 	at org.apache.servicecomb.core.provider.producer.ProducerProviderManager.init(ProducerProviderManager.java:45)
> 	at org.apache.servicecomb.core.CseApplicationListener.onApplicationEvent(CseApplicationListener.java:118)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
> 	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
> 	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)
> 	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
> 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> 	at org.apache.servicecomb.foundation.common.utils.BeanUtils.init(BeanUtils.java:37)
> 	at org.apache.servicecomb.foundation.common.utils.BeanUtils.init(BeanUtils.java:33)
> 	at io.demo.Application.main(Application.java:40)
>  org.apache.servicecomb.core.CseApplicationListener.onApplicationEvent(CseApplicationListener.java:145)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)