You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2021/02/22 05:10:04 UTC

[dubbo] branch master updated: Update CompatibleTypeUtils.java (#7028)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new e366006  Update CompatibleTypeUtils.java (#7028)
e366006 is described below

commit e366006e7b5c4172e7613fa9680c9a75593af9dc
Author: xukefu <51...@users.noreply.github.com>
AuthorDate: Mon Dec 21 12:56:21 2020 +0800

    Update CompatibleTypeUtils.java (#7028)
    
    Fix the problem that LocalDate type is forced to be converted to LocalDateTime error
---
 .../dubbo/common/utils/CompatibleTypeUtils.java    | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/CompatibleTypeUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/CompatibleTypeUtils.java
index 5d5cc5c..179f370 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/CompatibleTypeUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/CompatibleTypeUtils.java
@@ -111,17 +111,23 @@ public class CompatibleTypeUtils {
                             + DATE_FORMAT + ", cause: " + e.getMessage(), e);
                 }
             }
-            if (type == java.time.LocalDateTime.class || type == java.time.LocalDate.class
-                    || type == java.time.LocalTime.class) {
-
-                LocalDateTime localDateTime = LocalDateTime.parse(string);
-                if (type == java.time.LocalDate.class) {
-                    return localDateTime.toLocalDate();
+            if (type == java.time.LocalDateTime.class) {
+                if (StringUtils.isEmpty(string)) {
+                    return null;
+                }
+                return LocalDateTime.parse(string);
+            }
+            if (type == java.time.LocalDate.class) {
+                if (StringUtils.isEmpty(string)) {
+                    return null;
                 }
-                if (type == java.time.LocalTime.class) {
-                    return localDateTime.toLocalTime();
+                return LocalDate.parse(string);
+            }
+            if (type == java.time.LocalTime.class) {
+                if (StringUtils.isEmpty(string)) {
+                    return null;
                 }
-                return localDateTime;
+                return LocalDateTime.parse(string).toLocalTime();
             }
             if (type == Class.class) {
                 try {