{"record":{"id":"788a2c4010962318","repo":"apache/seatunnel","slug":"resultset-cannot-be-null","errorCode":null,"errorMessage":"ResultSet cannot be null","messagePattern":"ResultSet cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java","lineNumber":125,"sourceCode":"        if (ssl != null) {\n            properties.setProperty(\"ssl\", ssl.toString());\n        }\n\n        try {\n            return DriverManager.getConnection(url, properties);\n        } catch (SQLException e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.CONNECT_FAILED,\n                    \"Failed to create connection to Databend: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    /** Convert a ResultSet row to SeaTunnelRow */\n    public static SeaTunnelRow convertToSeaTunnelRow(ResultSet resultSet, SeaTunnelRowType rowType)\n            throws SQLException {\n        if (resultSet == null) {\n            throw new IllegalArgumentException(\"ResultSet cannot be null\");\n        }\n        if (rowType == null) {\n            throw new IllegalArgumentException(\"RowType cannot be null\");\n        }\n\n        int arity = rowType.getFieldNames().length;\n        Object[] fields = new Object[arity];\n        log.info(\"Converting ResultSet to SeaTunnelRow with {} fields\", arity);\n\n        try {\n            for (int i = 0; i < arity; i++) {\n                int columnIndex = i + 1;\n                String fieldName = rowType.getFieldName(i);\n                SeaTunnelDataType<?> fieldType = rowType.getFieldType(i);\n\n                try {\n                    Object value = getFieldValue(resultSet, columnIndex, fieldType);\n                    fields[i] = value;","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java#L107-L143","documentation":"DatabendUtil.convertToSeaTunnelRow requires a non-null ResultSet; if a null is passed it throws IllegalArgumentException('ResultSet cannot be null'). This is a defensive API check because row conversion cannot proceed without an open result set to read fields from.","triggerScenarios":"Calling convertToSeaTunnelRow(resultSet, rowType) with a null ResultSet - e.g. when a caller stored the result of a query that returned null, or passed an unset variable after a failed executeQuery path.","commonSituations":"Custom code (or a modified reader) invoking the util directly with the result of a statement that was never executed; test harnesses passing null; refactors where executeQuery's return value was lost before conversion.","solutions":["Ensure the ResultSet comes from a successfully executed statement.executeQuery(...) and is passed before closing","Add a null check on the query result before invoking the converter and skip/error appropriately","Check that executeQuery did not return null due to an earlier exception being swallowed upstream"],"exampleFix":"// before\nSeaTunnelRow row = DatabendUtil.convertToSeaTunnelRow(resultSet, rowType);\n// after\nif (resultSet != null) {\n    SeaTunnelRow row = DatabendUtil.convertToSeaTunnelRow(resultSet, rowType);\n}","handlingStrategy":"type-guard","validationCode":"if (resultSet == null) { throw new IllegalStateException(\"executeQuery returned no ResultSet; cannot convert rows\"); }","typeGuard":"if (resultSet == null) { return; } // skip conversion when no result set","tryCatchPattern":"try { row = DatabendUtil.convertToSeaTunnelRow(rs, rowType); } catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"ResultSet cannot be null\")) { log.error(\"Query produced no ResultSet\"); }\n    throw e;\n}","preventionTips":["Always assign the ResultSet directly from statement.executeQuery(...) rather than through intermediate nullable variables","Never call the converter with a ResultSet obtained from execute() without checking getResultSet() != null","Add null assertions in test harnesses exercising the converter"],"tags":["databend","null-check","argument-validation","jdbc"],"backgroundTag":"null-argument","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}