File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
astra-db-java/src/main/java/com/datastax/astra/internal/serdes/collections Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 21
21
*/
22
22
23
23
import com .fasterxml .jackson .core .JsonParser ;
24
+ import com .fasterxml .jackson .core .JsonToken ;
25
+ import com .fasterxml .jackson .core .JsonTokenId ;
24
26
import com .fasterxml .jackson .databind .DeserializationContext ;
25
27
import com .fasterxml .jackson .databind .JsonDeserializer ;
26
28
import com .fasterxml .jackson .databind .JsonNode ;
29
+ import com .fasterxml .jackson .databind .node .JsonNodeType ;
27
30
28
31
import java .io .IOException ;
29
32
import java .util .UUID ;
@@ -44,11 +47,29 @@ public UUIDDeserializer() {
44
47
@ Override
45
48
public UUID deserialize (JsonParser jp , DeserializationContext ctxt )
46
49
throws IOException {
47
- JsonNode node = jp .getCodec ().readTree (jp );
48
- if (null == node .get ("$uuid" )) {
50
+ String uuidStr = null ;
51
+ JsonNode node = ctxt .readTree (jp );
52
+
53
+ switch (node .getNodeType ()) {
54
+ case STRING :
55
+ uuidStr = node .asText ();
56
+ break ;
57
+
58
+ case OBJECT :
59
+ JsonNode uuidValue = node .get ("$uuid" );
60
+ if (null != uuidValue && uuidValue .isTextual ()) {
61
+ uuidStr = uuidValue .textValue ();
62
+ }
63
+ default :
64
+ break ;
65
+ }
66
+ if (null == uuidStr ) {
49
67
throw new IllegalArgumentException ("Cannot convert the expression as an UUID " + node );
50
68
}
51
- return UUID .fromString (node .get ("$uuid" ).asText ());
69
+ try {
70
+ return UUID .fromString (uuidStr );
71
+ } catch (IllegalArgumentException e ) {
72
+ throw new IllegalArgumentException ("Invalid UUID String: \" " + uuidStr + "\" " , e );
73
+ }
52
74
}
53
-
54
75
}
You can’t perform that action at this time.
0 commit comments