You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/03/04 08:33:55 UTC

[GitHub] [servicecomb-java-chassis] 936645 opened a new issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

936645 opened a new issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275


   对比两份swagger文件之后发现是属性顺序不一致,请问这种问题怎么解决? service center schema and local schema both are different:
   
    service center schema如下:
   
   definitions:
     PersnCompVo:
       type: "object"
       properties:
         aab300:
           type: "string"
         aab003:
           type: "string"
         aab300D:
           type: "string"
         aab004:
           type: "string"
       x-java-class: "com.tecsun.common.response.datacerter.persnCompQuey.PersnCompVo"
   
   local schema如下:
   definitions:
     PersnCompVo:
       type: "object"
       properties:
         aab300D:
           type: "string"
         aab300:
           type: "string"
         aab003:
           type: "string"
         aab004:
           type: "string"
       x-java-class: "com.tecsun.common.response.datacerter.persnCompQuey.PersnCompVo"
   
   两份文件中属性顺序不一致。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-792410304


   2.1.2版本做个一次修改, 可以比较语义的, 参考: https://github.com/apache/servicecomb-java-chassis/pull/2023/files
   
   你给的截图看起来swagger语义是一样的, 你能否结合上诉bug修改的内容, 调试下MicroserviceRegisterTask.java 看看是否语义比较返回了false? 
   
   如果你能够提供一个重现的用例就更好了。 
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] 936645 commented on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
936645 commented on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-790474712


   按照另外一篇文章中提到的,加了@JsonPropertyOrder之后,发现还是存在注册不上的服务,并且注册不上的服务对应的属性数量都不同。实际类中原有四个属性:
   
   第一个注册不上的实例:只有一个属性
   
   ![image](https://user-images.githubusercontent.com/79905356/109943368-16c6ad00-7d10-11eb-9fbe-66f65fa58f0e.png)
   
   第二个注册不上的实例:只有两个属性
   
   ![image](https://user-images.githubusercontent.com/79905356/109943426-27772300-7d10-11eb-9144-c2f462e2e42a.png)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-792417648


   可以参考下这个案例: https://bbs.huaweicloud.com/forum/thread-12624-1-1.html
   
   这种情况的发生通常是 getter/setter 没有对应的 field 导致的。 即业务可能认为有 getter, 但是 getter 不符合 JDK 规范。 这种情况下, 会根据 getter 生成 swagger, 而 JDK 对于方法加载的顺序是随机的。 所以会出现 swagger 内容字段顺序乱掉的情况。 
   
   不过 2.1.2 以后使用了语义比较, 可以识别字段顺序乱掉的情况也是同一个 swagger, 所以还不是很清楚你问题中语义检查的结果为什么是 false. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] 936645 closed issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
936645 closed issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] 936645 commented on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
936645 commented on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-790429882


   类中属性定义未按照驼峰命令,比如属性命名未AAB300,但是swagger文件中显示的字段属性为aab300


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-792410304


   2.1.2版本做个一次修改, 可以比较语义的, 参考: https://github.com/apache/servicecomb-java-chassis/pull/2023/files
   
   你给的截图看起来swagger语义是一样的, 你能否结合上诉bug修改的内容, 调试下MicroserviceRegisterTask.java 看看是否语义比较返回了false? 
   
   相关代码:
   
   ```
         //if content of local schema and service center schema is equal then return true.
         if (!StringUtils.isEmpty(scSchemaContent) && !StringUtils.isEmpty(localSchemaContent)) {
           Swagger scSwagger = SwaggerUtils.parseSwagger(scSchemaContent);
           Swagger localSwagger = SwaggerUtils.parseSwagger(localSchemaContent);
           if (scSwagger.equals(localSwagger)) {
             return true;
           }
         }
   ```
   
   
   如果你能够提供一个重现的用例就更好了。 
   
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [servicecomb-java-chassis] 936645 commented on issue #2275: 由于编码过程中属性命名未按照驼峰命名,导致服务注册时只能成功注册第一个微服务,第二个微服务注册时提示swagger不一致。升级ServiceComb到2.1.3、2.1.5后均无法解决该问题

Posted by GitBox <gi...@apache.org>.
936645 commented on issue #2275:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2275#issuecomment-792412068


   该问题已经修复,一是升级到serviceComb 3.1.5,升级之后发现swagger文件里面定义的属性都是小写,解决了属性大小写的问题。但是还是会注册失败,对比两个swagger文件发现属性顺序不一致。于是加上@JsonPropertyOrder(alphabetic=true)注解后,解决问题。
   
   伙伴反馈:第二个实例副本注册失败的情况下,重启注册失败的实例,是有概率注册成功的。这里咨询下生成swagger文件的规则?每次是随机的吗?
   
   实际上,伙伴在使用过程中并不能严格的按照咱们定义的规则去写代码,看这块规则是不是能优化一下,校验的时候规则宽松一点。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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