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

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

liubao68 commented on a change in pull request #1004: [SCB-925] Springmvc, when 
have defaultValue, required should be false, when param not exist, should check 
isRequired
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1004#discussion_r236030465
 
 

 ##########
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/FormProcessorCreator.java
 ##########
 @@ -50,20 +52,33 @@ public Object getValue(HttpServletRequest request) {
       }
 
       if (targetType.isContainerType()) {
-        return convertValue(request.getParameterValues(paramPath), targetType);
+        Object values = request.getParameterValues(paramPath);
+        //Even if the paramPath does not exist, it won't be null at now, may 
be optimized in the future
+        if (values == null) {
+          values = checkRequiredAndDefaultValue(values);
+        }
+        return convertValue(values, targetType);
       }
 
       Object value = request.getParameter(paramPath);
       if (value == null) {
-        Object defaultValue = getDefaultValue();
-        if (defaultValue != null) {
-          value = defaultValue;
-        }
+        value = checkRequiredAndDefaultValue(value);
       }
 
       return convertValue(value, targetType);
     }
 
+    private Object checkRequiredAndDefaultValue(Object values) {
 
 Review comment:
   values is always null, no need to pass this parameter

----------------------------------------------------------------
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:
us...@infra.apache.org


> Springmvc, when have defaultValue, required should be false
> -----------------------------------------------------------
>
>                 Key: SCB-925
>                 URL: https://issues.apache.org/jira/browse/SCB-925
>             Project: Apache ServiceComb
>          Issue Type: Bug
>          Components: Java-Chassis
>            Reporter: WeiChao
>            Assignee: WeiChao
>            Priority: Major
>             Fix For: java-chassis-1.1.0
>
>




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

Reply via email to