kclizhiwei opened a new issue #9562:
URL: https://github.com/apache/dubbo/issues/9562


   <!-- If you need to report a security issue please visit 
https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) 
of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 2.7.13
   * Operating System version: MacOS 12.1 
   * Java version: 11
   
   ### Steps to reproduce this issue
   consumer code :
   
   ```java
   ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
   ApplicationConfig applicationConfig = new ApplicationConfig();
   applicationConfig.setName("dubbo-provider");
   RegistryConfig registryConfig = new RegistryConfig();
   registryConfig.setAddress("zookeeper://127.0.1:2181");
   reference.setApplication(applicationConfig);
   reference.setRegistry(registryConfig);
   reference.setProtocol("dubbo");
   reference.setInterface("com.msnu.demo.provider.OrderService");
   reference.setVersion("1.0.0");
   reference.setTimeout(1000);
   reference.setGeneric("true");
   GenericService genericService = reference.get();
   Order order = new Order("20220110172900001", new BigDecimal(10000000.00));
   String orderJson = objectMapper.writeValueAsString(order);
   // The  price attribute type is Long in linkedHashMap
   LinkedHashMap linkedHashMap = objectMapper.readValue(orderJson, 
LinkedHashMap.class);
   Object result = genericService.$invoke(
           "queryOrder",
           new String[]{"com.msnu.demo.provider.OrderDto"},
           new Object[]{linkedHashMap});
   System.out.println(result);
   ```
   
   provide code :
   
   ```java
   public class OrderServiceImpl implements OrderService{
       @Override
       public OrderDto queryOrder(OrderDto orderDto) {
           System.out.println(orderDto);
           return orderDto;
       }
   }
   ```
   Pls. provide [GitHub address] to reproduce this issue.
   
   ### Expected Behavior
   <!-- What do you expect from the above steps?-->
   result is {orderId=20220110172900001, price=10000000, 
class=com.msnu.demo.provider.OrderDto}
   ### Actual Behavior
   
   <!-- What actually happens? -->
   
   If there is an exception, please attach the exception trace:
   result is {orderId=20220110172900001, price=1.0E+7, 
class=com.msnu.demo.provider.OrderDto}
   
   The analysis is as follows:
   code:
   ```java
   org.apache.dubbo.common.utils.CompatibleTypeUtils#compatibleTypeConvert
   ```
   line : 173
   ```java
   if (type == BigDecimal.class) {
        return BigDecimal.valueOf(number.doubleValue());
    }
   ```
     If I use <b>new BigDecimal(number.doubleValue())</b>, can fix this problem
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to