raminqaf commented on PR #29026:
URL: https://github.com/apache/flink/pull/29026#issuecomment-5491013170
> even worse let's play more let's try to read only the rest like
>
> ```java
> @Test
> public void nestedVariantError_siblingMustSurvive() throws Exception {
> byte[] json =
"{\"v\":{\"x\":1e400,\"y\":2},\"other\":5}".getBytes(StandardCharsets.UTF_8);
>
> RowData rowData = newSchema().deserialize(json);
>
> //assertThat(rowData.isNullAt(0)).as("bad variant should be
null").isTrue();
>
> assertThat(rowData.getInt(1)).isEqualTo(5);
> }
> ```
>
> and it fails as
>
> ```
> java.lang.NullPointerException: Cannot invoke
"java.lang.Integer.intValue()" because "this.fields[pos]" is null
>
> at
org.apache.flink.table.data.GenericRowData.getInt(GenericRowData.java:151)
>
> ```
Thanks for catching this @snuyanzin! I have found the issue. The
`convertToVariant` method was passing the `JsonParser`. This was problematic.
Now we read the whole value with `readValueAsTree`, and if there is a parse
error inside, it will not desync the shared parser. I have added your test case
too and it passes now
```diff
- return BinaryVariantInternalBuilder.parseJson(jp.traverse(), true);
+ return
BinaryVariantInternalBuilder.parseJson(jp.readValueAsTree().traverse(), true);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]