You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a ClassCastException (in RowImpl.getArrayOfEnums) when trying to get the value of a nullable array of enums column when the cell value is null.
Do you have a reproducer?
Steps to reproduce
Setup database like this:
CREATE TYPE test_enum AS ENUM(
'VAL1', 'VAL2'
);
CREATE TABLE test_table
(
test_column test_enum[]
);
INSERT INTO test_table VALUES (NULL);
try to get the null value with the sql-client.
Extra
It looks to me like there is simply a null check missing in the following function in RowImpl (compare to getEnum). But maybe there is a reason why it was left out.
private Object[] getArrayOfEnums(Class enumType, int pos) {
Object val = getValue(pos);
if (val instanceof String[]) {
String[] array = (String[]) val;
Object[] ret = (Object[]) Array.newInstance(enumType, array.length);
for (int i = 0;i < array.length;i++) {
String string = array[i];
if (string != null) {
ret[i] = Enum.valueOf(enumType, string);
}
}
return ret;
} else if (val instanceof Number[]) {
Number[] array = (Number[]) val;
Object[] ret = (Object[]) Array.newInstance(enumType, array.length);
Object[] constants = enumType.getEnumConstants();
for (int i = 0;i < array.length;i++) {
Number number = array[i];
int ordinal = number.intValue();
if (ordinal >= 0) {
if (ordinal < constants.length) {
ret[i] = constants[ordinal];
}
}
}
return ret;
} else {
throw new ClassCastException();
}
}
The text was updated successfully, but these errors were encountered:
Version
4.5.7
Context
I get a ClassCastException (in RowImpl.getArrayOfEnums) when trying to get the value of a nullable array of enums column when the cell value is null.
Do you have a reproducer?
Steps to reproduce
Setup database like this:
Extra
It looks to me like there is simply a null check missing in the following function in RowImpl (compare to getEnum). But maybe there is a reason why it was left out.
The text was updated successfully, but these errors were encountered: