From 40ed55fbdc83be2c21df42dd06056ed351c07356 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 9 Sep 2024 12:39:14 +0200 Subject: [PATCH] [jOOQ/jOOQ#17203] NPE while reading timestamp data type value for SAP SQL Anywhere 17 with jconn4 --- .../org/jooq/impl/MetaDataFieldProvider.java | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/MetaDataFieldProvider.java b/jOOQ/src/main/java/org/jooq/impl/MetaDataFieldProvider.java index c9e1e517e4..899fa4978a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/MetaDataFieldProvider.java +++ b/jOOQ/src/main/java/org/jooq/impl/MetaDataFieldProvider.java @@ -130,30 +130,38 @@ final class MetaDataFieldProvider implements Serializable { DataType dataType = SQLDataType.OTHER; String type = meta.getColumnTypeName(i); - try { - dataType = DefaultDataType.getDataType( - configuration.family(), - type, - precision, - scale, - !FALSE.equals(configuration.settings().isForceIntegerTypesOnZeroScaleDecimals()) - ); + // [#17203] jconn4 has a bug here where for some data types (e.g. timestamp), it doesn't return anything + if (type != null) { + try { + dataType = DefaultDataType.getDataType( + configuration.family(), + type, + precision, + scale, + !FALSE.equals(configuration.settings().isForceIntegerTypesOnZeroScaleDecimals()) + ); - if (dataType.hasPrecision()) - dataType = dataType.precision(precision); - if (dataType.hasScale()) - dataType = dataType.scale(scale); + if (dataType.hasPrecision()) + dataType = dataType.precision(precision); + if (dataType.hasScale()) + dataType = dataType.scale(scale); - // JDBC doesn't distinguish between precision and length - if (dataType.hasLength()) - dataType = dataType.length(precision); + // JDBC doesn't distinguish between precision and length + if (dataType.hasLength()) + dataType = dataType.length(precision); + } + + // [#650, #667] All types should be known at this point, but in plain + // SQL environments, it is possible that user-defined types, or vendor-specific + // types (e.g. such as PostgreSQL's json type) will cause this exception. + catch (SQLDialectNotSupportedException e) { + if (log.isDebugEnabled()) + log.debug("Not supported by dialect", e.getMessage()); + } } - - // [#650, #667] All types should be known at this point, but in plain - // SQL environments, it is possible that user-defined types, or vendor-specific - // types (e.g. such as PostgreSQL's json type) will cause this exception. - catch (SQLDialectNotSupportedException e) { - log.debug("Not supported by dialect", e.getMessage()); + else { + if (log.isDebugEnabled()) + log.debug("No type name is available at column index: " + i); } fields[i - 1] = field(name, dataType);