[jira] [Commented] (SCB-933) Revert changes to RestObjectMapper that fail on primitive types not present

2018-09-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-933:


liubao68 closed pull request #923: [SCB-933]Revert changes to RestObjectMapper 
that fail on primitive types not present
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/923
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java
 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java
index 327175b22..8f20acbfc 100644
--- 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java
+++ 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/RestObjectMapper.java
@@ -61,12 +61,12 @@ public StringBuffer format(Date date, StringBuffer 
toAppendTo, FieldPosition fie
 });
 
 getFactory().disable(Feature.AUTO_CLOSE_SOURCE);
+// Enable features that can tolerance errors and not enable those make 
more constraints for compatible reasons.
+// Developers can use validation api to do more checks.
 disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
 disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
 enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
 enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
-// If required=true, need to fail, while required=false, default values is 
given.
-enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
 
 SimpleModule module = new SimpleModule();
 // custom types
diff --git 
a/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/ControllerImpl.java
 
b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/ControllerImpl.java
index 7b22f9fa6..3c68b97b1 100644
--- 
a/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/ControllerImpl.java
+++ 
b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/ControllerImpl.java
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.validation.constraints.Min;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.demo.controller.Person;
@@ -37,7 +38,7 @@
 @RequestMapping(path = "/springmvc/controller", produces = 
MediaType.APPLICATION_JSON)
 public class ControllerImpl {
   @GetMapping(path = "/add")
-  public int add(@RequestParam("a") int a, @RequestParam("b") int b) {
+  public int add(@Min(1) @RequestParam("a") int a, @Min(1) @RequestParam("b") 
int b) {
 return a + b;
   }
 
diff --git 
a/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestBaseModel.java
 
b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestBaseModel.java
new file mode 100644
index 0..30e163142
--- /dev/null
+++ 
b/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestBaseModel.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.it.schema;
+
+public class RequestBaseModel {
+  private int type;
+
+  private Integer integerType;
+
+  private String message;
+
+  public int getType() {
+return type;
+  }
+
+  public void setType(int type) {
+this.type = type;
+  }
+
+  public Integer getIntegerType() {
+return integerType;
+  }
+
+  public void setIntegerType(Integer integerType) {
+this.integerType = integerType;
+  }
+
+  public String getMessage() {
+return message;
+  }
+
+  public void setMessage(String message) {
+this.message = message;
+  }
+}
diff --git 
a/integration-tests/it-common/src/main/java/org/apache/servicecomb/it/schema/RequestModel.java
 

[jira] [Commented] (SCB-933) Revert changes to RestObjectMapper that fail on primitive types not present

2018-09-21 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on SCB-933:


coveralls commented on issue #923: [SCB-933]Revert changes to RestObjectMapper 
that fail on primitive types not present
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/923#issuecomment-423449689
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/19119000/badge)](https://coveralls.io/builds/19119000)
   
   Coverage increased (+0.03%) to 86.233% when pulling 
**d439881b31457fd17ef284a4f80e56c42ff24b0f on liubao68:revert_primitive** into 
**20627dd0af924dcdf51fe529afe49e51864dc18c on apache:master**.
   


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


> Revert changes to RestObjectMapper that fail on primitive types not present
> ---
>
> Key: SCB-933
> URL: https://issues.apache.org/jira/browse/SCB-933
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0
>Reporter: liubao
>Assignee: liubao
>Priority: Major
>
> This modification will cause compatible issues. 



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