From af66832b9e3a666e327e54f68861fc521dd45efc Mon Sep 17 00:00:00 2001 From: radovanradic Date: Tue, 10 Dec 2024 19:06:24 +0100 Subject: [PATCH] Try to make Sonar happier --- .../ColumnNameExistenceAwareResultSetReader.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/data-jdbc/src/main/java/io/micronaut/data/jdbc/mapper/ColumnNameExistenceAwareResultSetReader.java b/data-jdbc/src/main/java/io/micronaut/data/jdbc/mapper/ColumnNameExistenceAwareResultSetReader.java index e8b77e904c..6ee76d45e0 100644 --- a/data-jdbc/src/main/java/io/micronaut/data/jdbc/mapper/ColumnNameExistenceAwareResultSetReader.java +++ b/data-jdbc/src/main/java/io/micronaut/data/jdbc/mapper/ColumnNameExistenceAwareResultSetReader.java @@ -49,21 +49,22 @@ public Object readDynamic(ResultSet resultSet, String index, DataType dataType) } private boolean containsColumnName(ResultSet resultSet, String name) { - if (name == null) { - return false; - } if (knownColumns == null) { try { ResultSetMetaData rsmd = resultSet.getMetaData(); int columnsCount = rsmd.getColumnCount(); knownColumns = CollectionUtils.newHashSet(columnsCount); for (int x = 1; x <= columnsCount; x++) { - knownColumns.add(rsmd.getColumnLabel(x).toLowerCase()); + knownColumns.add(toLowerCase(rsmd.getColumnLabel(x))); } } catch (SQLException e) { throw new RuntimeException(e); } } - return knownColumns.contains(name.toLowerCase()); + return knownColumns.contains(toLowerCase(name)); + } + + private static String toLowerCase(String str) { + return str == null ? null : str.toLowerCase(); } }