Skip to content

Commit 9f0f144

Browse files
cmgroteclaude
andcommitted
fix(serde): use resolved element type for numeric deserialization in collection setters
When deserializing a JSON array via a Lombok @Singular bulk setter (e.g. assetExternalDQTestLatestScores(Collection<? extends Double>)), JacksonUtils was re-reading the raw parameter type from the method (Collection) rather than using the already-resolved singularClass (Double). This caused an "Unhandled parameter type" IOException for any SortedSet<Double> field. The fix adds a deserializeNumber(JsonNode, Class<?>) overload and routes both number-path calls in deserializePrimitive through singularClass, which is already correctly resolved before those branches are reached. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Chris (He/Him) <cgrote@gmail.com>
1 parent b8496e9 commit 9f0f144

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

sdk/src/main/java/com/atlan/util/JacksonUtils.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public static Object deserializePrimitive(JsonNode primitive, Method method, Cla
6060
} else if (singularClass == Boolean.class) {
6161
return primitive.asBoolean();
6262
} else if (Number.class.isAssignableFrom(singularClass)) {
63-
return deserializeNumber(primitive, method);
63+
return deserializeNumber(primitive, singularClass);
6464
} else {
6565
return primitive.asText();
6666
}
6767
} else if (primitive.isBoolean()) {
6868
return primitive.asBoolean();
6969
} else if (primitive.isNumber()) {
70-
return deserializeNumber(primitive, method);
70+
return deserializeNumber(primitive, singularClass);
7171
}
7272
return null;
7373
}
@@ -82,13 +82,23 @@ public static Object deserializePrimitive(JsonNode primitive, Method method, Cla
8282
*/
8383
public static Object deserializeNumber(JsonNode primitive, Method method) throws IOException {
8484
Parameter[] parameters = method.getParameters();
85-
Class<?> parameterType;
8685
if (parameters.length == 1) {
87-
parameterType = parameters[0].getType();
86+
return deserializeNumber(primitive, parameters[0].getType());
8887
} else {
8988
throw new IOException(
9089
"Unexpected number of parameters (" + parameters.length + ") found for method: " + method);
9190
}
91+
}
92+
93+
/**
94+
* Deserialize a number direct to an object, converting to the correct type.
95+
*
96+
* @param primitive number to deserialize
97+
* @param parameterType target numeric type
98+
* @return the deserialized number
99+
* @throws IOException if the target type is an unhandled numeric type
100+
*/
101+
public static Object deserializeNumber(JsonNode primitive, Class<?> parameterType) throws IOException {
92102
if (parameterType == Integer.class) {
93103
return primitive.asInt();
94104
} else if (parameterType == Long.class) {
@@ -100,7 +110,7 @@ public static Object deserializeNumber(JsonNode primitive, Method method) throws
100110
} else if (parameterType == Short.class) {
101111
return primitive.shortValue();
102112
} else {
103-
throw new IOException("Unhandled parameter type (" + parameterType + ") found for method: " + method);
113+
throw new IOException("Unhandled parameter type (" + parameterType + ") found for method: " + primitive);
104114
}
105115
}
106116

0 commit comments

Comments
 (0)