[
https://issues.apache.org/jira/browse/FLINK-33791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17795236#comment-17795236
]
Sergey Nuyanzin edited comment on FLINK-33791 at 12/11/23 8:26 AM:
-------------------------------------------------------------------
[~lijingwei.5018] can you be more precise about test case?
We have testcase at
{{org.apache.flink.connector.jdbc.databases.postgres.catalog.PostgresCatalogITCase#testArrayTypes}}
when array is null and it doesn't fail.
Do you have a test case confirming failure you've mentioned, or even better
ready to run JUnit test?
was (Author: sergey nuyanzin):
[~lijingwei.5018] can you be more precise about test case?
We have testcase at
{{org.apache.flink.connector.jdbc.databases.postgres.catalog.PostgresCatalogITCase#testArrayTypes}}
when array is null and it doesn't fail.
Do you have a test case confirming failure you've mentioned?
> Fix NPE when array is null in PostgresArrayConverter in flink-connector-jdbc
> ----------------------------------------------------------------------------
>
> Key: FLINK-33791
> URL: https://issues.apache.org/jira/browse/FLINK-33791
> Project: Flink
> Issue Type: Bug
> Components: Connectors / JDBC
> Reporter: JingWei Li
> Priority: Major
>
> {code:java}
> // private JdbcDeserializationConverter
> createPostgresArrayConverter(ArrayType arrayType) {
> // Since PGJDBC 42.2.15 (https://github.com/pgjdbc/pgjdbc/pull/1194)
> bytea[] is wrapped in
> // primitive byte arrays
> final Class<?> elementClass =
>
> LogicalTypeUtils.toInternalConversionClass(arrayType.getElementType());
> final JdbcDeserializationConverter elementConverter =
> createNullableInternalConverter(arrayType.getElementType());
> return val -> {
> @SuppressWarnings("unchecked")
> T pgArray = (T) val;
> Object[] in = (Object[]) pgArray.getArray();
> final Object[] array = (Object[]) Array.newInstance(elementClass,
> in.length);
> for (int i = 0; i < in.length; i++) {
> array[i] = elementConverter.deserialize(in[i]);
> }
> return new GenericArrayData(array);
> };
> } {code}
> When use this method, array is null pgArray.getArray() will throw NPE。
--
This message was sent by Atlassian Jira
(v8.20.10#820010)