Skip to content

Commit

Permalink
deserialize UUID support input empty string, for issue alibaba#1763
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Aug 18, 2023
1 parent 89f8437 commit 0dfe008
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/com/alibaba/fastjson2/JSONReaderUTF16.java
Original file line number Diff line number Diff line change
Expand Up @@ -5378,6 +5378,9 @@ public final UUID readUUID() {
}

String str = readString();
if (str.isEmpty()) {
return null;
}
return UUID.fromString(str);
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/com/alibaba/fastjson2/JSONReaderUTF8.java
Original file line number Diff line number Diff line change
Expand Up @@ -7993,6 +7993,9 @@ public final UUID readUUID() {
}

String str = readString();
if (str.isEmpty()) {
return null;
}
return UUID.fromString(str);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.alibaba.fastjson2.issues_1700;

import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertNull;

public class Issue1763 {
@Test
public void test() {
String str = "\"\"";
assertNull(JSON.parseObject(str, UUID.class));
assertNull(JSON.parseObject(str.toCharArray(), UUID.class));
assertNull(JSON.parseObject(str.getBytes(), UUID.class));
}
}

0 comments on commit 0dfe008

Please sign in to comment.