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

[SCB-685] Service comb chassis must support default values in query parameters #774

Merged
merged 2 commits into from Jun 25, 2018

Conversation

acsukesh
Copy link
Contributor

@acsukesh acsukesh commented Jun 22, 2018

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@acsukesh acsukesh changed the title [SCB-685] Service comb chassis must support default values [SCB-685] Service comb chassis must support default values in query parameters Jun 22, 2018
@@ -43,6 +54,12 @@ public Object getValue(HttpServletRequest request) throws Exception {
value = request.getParameterValues(paramPath);
} else {
value = request.getParameter(paramPath);
if (value == null || value.equals("")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1."" should not change to default value?
2.only process query parameter? what about header/cookie and so on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add defaultValue to base interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"" comes only when user inputs the same and is considered as valid input parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. For http://10.57.65.159:8080/codeFirstSpringmvc/reduce?a=
give default Value is better.

@@ -51,9 +51,12 @@ public static void main(String[] args) throws Exception {
// RestTemplate Consumer
String sayHiResult =
restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java Chassis", null, String.class);
String sayHiDefaultResult =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add test cases in demo projects. Sample are short examples, and demos folder are integration tests, you can add as many test cases you like.

And maybe you need to test some primitive types default value, and from the following code, they seems not properly handled.


}

protected String getAnnotationParameterDefaultValue(Object annotation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primitive and other types default value not properly handled?

protected String getAnnotationParameterDefaultValue(Object annotation) {
String defaultValue = ((RequestParam) annotation).defaultValue();
if (defaultValue.equals(ValueConstants.DEFAULT_NONE)) {
return "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe null is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might cause NullPointerException, also some message might get added with null which may not be correct , so returning empty

Copy link
Contributor

@liubao68 liubao68 Jun 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to return ValueConstants.DEFAULT_NONE. When no default value specified and users do not give the parameter value, we can throw an BadRequest exception or give default value based on parameter type, e.g. int is 0 and String is null.

@coveralls
Copy link

coveralls commented Jun 25, 2018

Coverage Status

Coverage decreased (-0.06%) to 87.124% when pulling 72289dd on acsukesh:master into 9147c70 on apache:master.

@liubao68
Copy link
Contributor

I'll merge this PR. Following work need to be done:

  1. Support JAX-RS
  2. Adding more test cases, to cover default values not specified and user do not parse any value. See review comments: " Maybe it's better to return ValueConstants.DEFAULT_NONE. When no default value specified and users do not give the parameter value, we can throw an BadRequest exception or give default value based on parameter type, e.g. int is 0 and String is null."

@liubao68 liubao68 merged commit 403af0d into apache:master Jun 25, 2018
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

Successfully merging this pull request may close these issues.

None yet

4 participants