Skip to content

Commit 9ac3a01

Browse files
test(client-v2): assert enum-null error names column and type; clarify changelog
Address review feedback on #2932: - Strengthen testNullIntoNonNullableEnumThrowsIllegalArgument to assert the error message names the offending column and includes the enum type string, not just the generic prefix, so a future refactor that drops either detail fails the test. Use a distinctive `bs_flag` column name (matching the issue repro) so the column-name assertion is unambiguous. - Reword CHANGELOG: serializeEnumData had no null guard (there was no prior null check), avoiding the implication of a pre-existing check.
1 parent 507be2b commit 9ac3a01

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
### Bug Fixes
66

77
- **[client-v2]** Fixed a `NullPointerException` when serializing a `null` value into a non-nullable
8-
`Enum8`/`Enum16` column. `SerializerUtils.serializeEnumData` dereferenced the value before the `null`
9-
check, so a `null` in a non-nullable enum column failed the RowBinary insert path with a confusing NPE
10-
instead of a clear error. It now throws `IllegalArgumentException` naming the column, consistent with the
11-
existing `IllegalArgumentException` for other unsupported enum values. Nullable enum columns are unaffected.
12-
(https://github.com/ClickHouse/clickhouse-java/issues/2931)
8+
`Enum8`/`Enum16` column. `SerializerUtils.serializeEnumData` had no `null` guard, so a `null` in a
9+
non-nullable enum column reached `value.getClass()` and failed the RowBinary insert path with a confusing
10+
NPE instead of a clear error. It now throws `IllegalArgumentException` naming the column, consistent with
11+
the existing `IllegalArgumentException` for other unsupported enum values. Nullable enum columns are
12+
unaffected. (https://github.com/ClickHouse/clickhouse-java/issues/2931)
1313
- **[client-v2]** Fixed POJO insert error classification so transport write failures such as java.net.SocketException:
1414
Broken pipe (Write failed) are now surfaced as transfer/network errors instead of being wrapped as
1515
DataSerializationException. This only changes the exception type reported for request-body transport failures during

client-v2/src/test/java/com/clickhouse/client/api/data_formats/internal/SerializerUtilsTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,17 @@ public void testGeometrySerializationRejectsMalformedList() {
145145

146146
@Test(dataProvider = "nonNullableEnumTypes")
147147
public void testNullIntoNonNullableEnumThrowsIllegalArgument(String typeName) {
148-
ClickHouseColumn column = ClickHouseColumn.of("v", typeName);
148+
ClickHouseColumn column = ClickHouseColumn.of("bs_flag", typeName);
149149

150150
IllegalArgumentException ex = Assert.expectThrows(IllegalArgumentException.class,
151151
() -> SerializerUtils.serializeData(new ByteArrayOutputStream(), null, column));
152-
Assert.assertTrue(ex.getMessage().contains("Cannot insert null into non-nullable column"),
153-
"Unexpected message: " + ex.getMessage());
152+
String message = ex.getMessage();
153+
Assert.assertTrue(message.contains("Cannot insert null into non-nullable column"),
154+
"Unexpected message: " + message);
155+
Assert.assertTrue(message.contains("bs_flag"),
156+
"Message should name the offending column: " + message);
157+
Assert.assertTrue(message.contains(typeName),
158+
"Message should include the enum type: " + message);
154159
}
155160

156161
@DataProvider(name = "nonNullableEnumTypes")

0 commit comments

Comments
 (0)