Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock字段注入异常 #5239

Closed
ksyzz opened this issue Oct 25, 2019 · 3 comments
Closed

Mock字段注入异常 #5239

ksyzz opened this issue Oct 25, 2019 · 3 comments
Assignees
Milestone

Comments

@ksyzz
Copy link

ksyzz commented Oct 25, 2019

环境

  • Dubbo version: 2.7.3
  • Operating System version: win10
  • Java version: 1.8.0_101
  • Dubbo-spring-boot-starter version: 2.7.3
  • Spring-boot-starter version: 2.1.3.RELEASE

问题描述

  1. 在application.properties中添加mock配置:dubbo.consumer.mock=return {"code":300,"message":"fail"}
  2. 项目启动失败,报错:
Failed to bind properties under 'dubbo.consumer.mock' to java.lang.Boolean:
    Property: dubbo.consumer.mock
    Value: return {"code":300,"message":"fail"}
    Origin: class path resource [application.properties]:30:21
    Reason: failed to convert java.lang.String to java.lang.Boolean
  1. 调试发现在将dubbo.consumer.mock赋值给AbstractMethodConfing时,调用的是setMock(Boolean) 而不是setMock(String)。
  2. spring在获取字段的set方法时,用到了Class.getDeclaredMethods(),这个方法返回结果是无序的,这样导致了如果先加载了setMock(String),那么项目会成功启动,反之,则会出现上面说的错误。
@wangkezun
Copy link

可以给出完整的exception栈信息吗?

@ksyzz
Copy link
Author

ksyzz commented Oct 27, 2019

可以给出完整的exception栈信息吗?

控制台只输出了这些信息

@ksyzz
Copy link
Author

ksyzz commented Oct 30, 2019

请问为啥要写两个setMock方法,有什么特殊的地方吗

@chickenlj chickenlj added this to the 2.7.6 milestone Dec 30, 2019
mercyblitz added a commit to mercyblitz/dubbo that referenced this issue Feb 19, 2020
mercyblitz added a commit to mercyblitz/dubbo that referenced this issue Feb 20, 2020
mercyblitz added a commit that referenced this issue Feb 20, 2020
* Polish /#5745 : Increasing the stack size in the start.sh

* Polish /#5297 : Only one of the multiple registration centers using nacos can register

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费

* Polish /#5442 : Merge upstream/master

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /apache/dubbo##5239 : Mock字段注入异常
seedeed pushed a commit to seedeed/dubbo that referenced this issue Feb 20, 2020
* Polish /apache#5745 : Increasing the stack size in the start.sh

* Polish /apache#5297 : Only one of the multiple registration centers using nacos can register

* Polish /apache#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费

* Polish /apache#5442 : Merge upstream/master

* Polish /apache/dubbo#apache#5239 : Mock字段注入异常

* Polish /apache/dubbo#apache#5239 : Mock字段注入异常
mercyblitz added a commit that referenced this issue Feb 21, 2020
* Polish /#5745 : Increasing the stack size in the start.sh

* Polish /#5297 : Only one of the multiple registration centers using nacos can register

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费

* Polish /#5442 : Merge upstream/master

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /#5770 : Removing the interinal JDK API from FileSystemDynamicConfiguration

* Polish /#5771 : [Enhancement] Refactor the APT test-cases implementation of dubbo-metadata-processor in Java 9+

* Bugfix for the test-cases
mercyblitz added a commit that referenced this issue Feb 28, 2020
…erface (#5801)

* Polish /#5745 : Increasing the stack size in the start.sh

* Polish /#5297 : Only one of the multiple registration centers using nacos can register

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费

* Polish /#5442 : Merge upstream/master

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /#5770 : Removing the interinal JDK API from FileSystemDynamicConfiguration

* Polish /#5771 : [Enhancement] Refactor the APT test-cases implementation of dubbo-metadata-processor in Java 9+

* Bugfix for the test-cases

* Polish /#5779 : Rename the local variables

* Add FieldUtils

* Polish /#5795 : [Feature] To support the application choose the preferred network interface

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants