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

In ServiceController's "create" method a optional param is actually required #4424

Closed
Xezeloh opened this issue Dec 8, 2020 · 6 comments
Closed
Assignees
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Milestone

Comments

@Xezeloh
Copy link

Xezeloh commented Dec 8, 2020

Describe the bug
In the naming module, ServiceController's "create" method has an optional parameter protectThreshold. However, since it is a basic type and has no default value, if this parameter is not provided in actual use, an error will be reported.
naming模块中,ServiceController的create方法有一个可选参数protectThreshold,但由于其是基本类型且无默认值,在实际使用中如果不提供这个参数会导致报错。

Expected behavior
A request sent to the api create with out the param protectThreshold get an ok returned.

Acutally behavior
nacos return this:
caused: Optional float parameter 'protectThreshold' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.;

How to Reproduce
curl -X POST "127.0.0.1:8848/nacos/v1/ns/service?serviceName=12e"

Desktop (please complete the following information):

  • OS: Windows 10
  • Version nacos-server 1.3.2
  • Module naming

Additional context
No

@KomachiSion KomachiSion added kind/bug Category issues or prs related to bug. good first issue Good for newcomers labels Dec 8, 2020
@KomachiSion KomachiSion added this to the 1.4.1 milestone Dec 8, 2020
@neighbor-uncleWang
Copy link
Contributor

@i will solve it@

@neighbor-uncleWang
Copy link
Contributor

To archive this goal,here is my plan:
Modify the parameter to the packaging type, and then convert the null to 0.0L in the method.

我的计划是:
将参数修改为包装类型,然后在方法里面将null转换为0.0L。

@Xezeloh
Copy link
Author

Xezeloh commented Dec 10, 2020

To archive this goal,here is my plan:
Modify the parameter to the packaging type, and then convert the null to 0.0L in the method.

我的计划是:
将参数修改为包装类型,然后在方法里面将null转换为0.0L。

那为啥不直接在形参那儿赋个默认值0.0

@neighbor-uncleWang
Copy link
Contributor

对耶,默认值直接defaultValue

@liuweizhenhaoa
Copy link

对耶,默认值直接defaultValue

i want to know did you submit this issue

@neighbor-uncleWang
Copy link
Contributor

周末再提交,最近工作日比较忙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Projects
None yet
Development

No branches or pull requests

4 participants