Skip to content

Commit 1f36216

Browse files
ksobolewRandgalt
authored andcommitted
Fix GlueDeserializer to use DeserializationContext instead of ObjectMapper
Calling the parser directly corrupts the parser state in the enclosing parse. As a result, we may end up with an error if the `FAIL_ON_TRAILING_TOKENS` flag is enabled in the parser.
1 parent 5fdcda3 commit 1f36216

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

trino-aws-proxy-glue/src/main/java/io/trino/aws/proxy/glue/rest/GlueDeserializer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.fasterxml.jackson.databind.JavaType;
1919
import com.fasterxml.jackson.databind.JsonDeserializer;
2020
import com.fasterxml.jackson.databind.JsonNode;
21-
import com.fasterxml.jackson.databind.ObjectMapper;
2221
import software.amazon.awssdk.core.SdkBytes;
2322
import software.amazon.awssdk.core.SdkField;
2423

@@ -54,9 +53,7 @@ public T deserialize(JsonParser parser, DeserializationContext context)
5453
{
5554
Object builder = serializerCommon.newBuilder();
5655

57-
// recommended by claude.ai
58-
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
59-
JsonNode node = mapper.readTree(parser);
56+
JsonNode node = context.readTree(parser);
6057

6158
Iterator<String> fieldNames = node.fieldNames();
6259
while (fieldNames.hasNext()) {
@@ -75,7 +72,7 @@ public T deserialize(JsonParser parser, DeserializationContext context)
7572
}
7673
else {
7774
JavaType javaType = context.getTypeFactory().constructType(type);
78-
sdkField.set(builder, mapper.convertValue(fieldValue, javaType));
75+
sdkField.set(builder, context.readTreeAsValue(fieldValue, javaType));
7976
}
8077
}
8178
}

0 commit comments

Comments
 (0)