You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "rickiehsu (via GitHub)" <gi...@apache.org> on 2023/06/26 02:50:50 UTC

[GitHub] [dubbo] rickiehsu opened a new issue, #12591: FastJson2Serialization : Wrong deserialization value

rickiehsu opened a new issue, #12591:
URL: https://github.com/apache/dubbo/issues/12591

   ### Environment
   
   * Dubbo version: 3.2.2
   * Operating System version: win 10
   * Java version: 1.8
   * Fastjson2: both 2.0.31,2.0.34
   
   ### Steps to reproduce this issue
   This code reproduce the problem
   
   ```
   public void testWriteReadString() throws Exception {
           QueryVo model = new QueryVo();
           model.addOrderClause(new OrderClause("task_no", false));
   
           FrameworkModel frameworkModel = new FrameworkModel();
           Serialization serialization = frameworkModel.getExtensionLoader(Serialization.class).getExtension("fastjson2");
           URL url = URL.valueOf("").setScopeModel(frameworkModel);
           // write pojo, read failed
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           ObjectOutput objectOutput = serialization.serialize(url, outputStream);
           objectOutput.writeObject(model);
           objectOutput.flushBuffer();
   
           byte[] bytes = outputStream.toByteArray();
           ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
           ObjectInput objectInput = serialization.deserialize(url, inputStream);
           Object obj = objectInput.readObject();
           Assertions.assertEquals(obj, objectInput.readObject());
           
           frameworkModel.destroy();
       }
   
   **QueryVo.java**
   public class QueryVo implements Serializable {
       private int limit;
       private int offset;
       private Map<String, Object> queryObj;
       private List<OrderClause> orderClauses;
   
       public int getLimit() {
           return limit;
       }
   
       public void setLimit(int limit) {
           this.limit = limit;
       }
   
       public int getOffset() {
           return offset;
       }
   
       public void setOffset(int offset) {
           this.offset = offset;
       }
   
       public Map<String, Object> getQueryObj() {
           return queryObj;
       }
   
       public void setQueryObj(Map<String, Object> queryObj) {
           this.queryObj = queryObj;
       }
   
       public List<OrderClause> getOrderClauses() {
           return orderClauses;
       }
   
       public void addOrderClause(OrderClause orderClause) {
           if (this.orderClauses == null) {
               this.orderClauses = new ArrayList<>();
           }
           this.orderClauses.add(orderClause);
       }
   }
   
   **OrderClause.java**
   public class OrderClause implements Serializable {
       private String fieldName;
       private boolean ascending = true;
   
       public OrderClause(){
   
       }
   
       public OrderClause(String fieldName){
           this.fieldName = fieldName;
       }
   
       public OrderClause(String fieldName, boolean ascending){
           this.fieldName = fieldName;
           this.ascending = ascending;
       }
   
       public String getFieldName() {
           return fieldName;
       }
   
       public void setFieldName(String fieldName) {
           this.fieldName = fieldName;
       }
   
       public boolean isAscending() {
           return ascending;
       }
   
       public void setAscending(boolean ascending) {
           this.ascending = ascending;
       }
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #12591: FastJson2Serialization : Wrong deserialization value

Posted by "EarthChen (via GitHub)" <gi...@apache.org>.
EarthChen commented on issue #12591:
URL: https://github.com/apache/dubbo/issues/12591#issuecomment-1608712898

   这个问题应该提给 fastjson 那边


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] rickiehsu commented on issue #12591: FastJson2Serialization : Wrong deserialization value

Posted by "rickiehsu (via GitHub)" <gi...@apache.org>.
rickiehsu commented on issue #12591:
URL: https://github.com/apache/dubbo/issues/12591#issuecomment-1606514671

   ### Expected Behavior
   
   {"limit":0,"offset":0,"orderClauses":[{"ascending":false,"fieldName":"task_no"}]}
   
   ### Actual Behavior
   
   {"limit":0,"offset":0,"orderClauses":[{"ascending":true,"fieldName":"task_no"}]}
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] rickiehsu closed issue #12591: FastJson2Serialization : Wrong deserialization value

Posted by "rickiehsu (via GitHub)" <gi...@apache.org>.
rickiehsu closed issue #12591: FastJson2Serialization : Wrong deserialization value
URL: https://github.com/apache/dubbo/issues/12591


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org