From e328129d6e8e20fb9a80c4e8d18c2d0f4635aa62 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Thu, 5 Feb 2026 20:48:44 +0000 Subject: [PATCH 1/3] fix: avoid String.format in log calls --- .../bigquery/jdbc/BigQueryArrowResultSet.java | 2 +- .../bigquery/jdbc/BigQueryBaseResultSet.java | 3 +- .../jdbc/BigQueryCallableStatement.java | 17 +- .../bigquery/jdbc/BigQueryConnection.java | 8 +- .../jdbc/BigQueryDatabaseMetaData.java | 280 +++++++++--------- .../cloud/bigquery/jdbc/BigQueryDriver.java | 8 +- .../jdbc/BigQueryJdbcCustomLogger.java | 28 ++ .../jdbc/BigQueryJdbcOAuthUtility.java | 6 +- .../bigquery/jdbc/BigQueryJdbcUrlUtility.java | 17 +- .../bigquery/jdbc/BigQueryJsonResultSet.java | 2 +- .../jdbc/BigQueryParameterHandler.java | 15 +- .../jdbc/BigQueryPooledConnection.java | 3 +- .../jdbc/BigQueryPreparedStatement.java | 6 +- .../bigquery/jdbc/BigQueryStatement.java | 24 +- .../bigquery/jdbc/BigQueryThreadFactory.java | 2 +- .../bigquery/jdbc/BigQueryTypeCoercer.java | 2 +- .../jdbc/PooledConnectionListener.java | 4 +- 17 files changed, 210 insertions(+), 217 deletions(-) diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java index 004dfb02b..aeea6783d 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java @@ -441,7 +441,7 @@ private String formatRangeElement(Object element, StandardSQLTypeName elementTyp @Override public void close() { - LOG.fine(String.format("Closing BigqueryArrowResultSet %s.", this)); + LOG.fine("Closing BigqueryArrowResultSet %s.", this); this.isClosed = true; if (ownedThread != null && !ownedThread.isInterrupted()) { // interrupt the producer thread when result set is closed diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java index 7367a8153..4ff4acad6 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java @@ -103,8 +103,7 @@ public void close() { statement.close(); } } catch (SQLException ex) { - LOG.warning( - String.format("Exception during ResultState.close() operation: %s", ex.getMessage())); + LOG.warning("Exception during ResultState.close() operation: %s", ex.getMessage()); } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java index 041505c62..78ae6dd9c 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java @@ -930,8 +930,7 @@ public URL getURL(String arg0) throws SQLException { @Override public void registerOutParameter(int paramIndex, int sqlType) throws SQLException { LOG.finest("++enter++"); - LOG.finest( - String.format("registerOutParameter: paramIndex %s, sqlType %s", paramIndex, sqlType)); + LOG.finest("registerOutParameter: paramIndex %s, sqlType %s", paramIndex, sqlType); checkClosed(); try { this.parameterHandler.setParameter( @@ -948,7 +947,7 @@ public void registerOutParameter(int paramIndex, int sqlType) throws SQLExceptio @Override public void registerOutParameter(String paramName, int sqlType) throws SQLException { LOG.finest("++enter++"); - LOG.finest(String.format("registerOutParameter: paramName %s, sqlType %s", paramName, sqlType)); + LOG.finest("registerOutParameter: paramName %s, sqlType %s", paramName, sqlType); checkClosed(); try { this.parameterHandler.setParameter( @@ -966,9 +965,8 @@ public void registerOutParameter(String paramName, int sqlType) throws SQLExcept public void registerOutParameter(int paramIndex, int sqlType, int scale) throws SQLException { LOG.finest("++enter++"); LOG.finest( - String.format( "registerOutParameter: paramIndex %s, sqlType %s, scale %s", - paramIndex, sqlType, scale)); + paramIndex, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { throw new IllegalArgumentException( @@ -991,9 +989,8 @@ public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException { LOG.finest("++enter++"); LOG.finest( - String.format( "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", - paramIndex, sqlType, typeName)); + paramIndex, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. registerOutParameter(paramIndex, sqlType); } @@ -1002,9 +999,8 @@ public void registerOutParameter(int paramIndex, int sqlType, String typeName) public void registerOutParameter(String paramName, int sqlType, int scale) throws SQLException { LOG.finest("++enter++"); LOG.finest( - String.format( "registerOutParameter: paramIndex %s, sqlType %s, scale %s", - paramName, sqlType, scale)); + paramName, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { throw new IllegalArgumentException( @@ -1027,9 +1023,8 @@ public void registerOutParameter(String paramName, int sqlType, String typeName) throws SQLException { LOG.finest("++enter++"); LOG.finest( - String.format( "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", - paramName, sqlType, typeName)); + paramName, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. registerOutParameter(paramName, sqlType); } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java index e93938f25..5bb4d874f 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java @@ -386,7 +386,7 @@ HeaderProvider createHeaderProvider() { } protected void addOpenStatements(Statement statement) { - LOG.finest(String.format("Statement %s added to Connection %s.", statement, this)); + LOG.finest("Statement %s added to Connection %s.", statement, this); this.openStatements.add(statement); } @@ -430,7 +430,7 @@ String getConnectionUrl() { public Statement createStatement() throws SQLException { checkClosed(); BigQueryStatement currentStatement = new BigQueryStatement(this); - LOG.fine(String.format("Statement %s created.", currentStatement)); + LOG.fine("Statement %s created.", currentStatement); addOpenStatements(currentStatement); return currentStatement; } @@ -489,7 +489,7 @@ public Statement createStatement( public PreparedStatement prepareStatement(String sql) throws SQLException { checkClosed(); PreparedStatement currentStatement = new BigQueryPreparedStatement(this, sql); - LOG.fine(String.format("Prepared Statement %s created.", currentStatement)); + LOG.fine("Prepared Statement %s created.", currentStatement); addOpenStatements(currentStatement); return currentStatement; } @@ -1125,7 +1125,7 @@ private void commitTransaction() { public CallableStatement prepareCall(String sql) throws SQLException { checkClosed(); CallableStatement currentStatement = new BigQueryCallableStatement(this, sql); - LOG.fine(String.format("Callable Statement %s created.", currentStatement)); + LOG.fine("Callable Statement %s created.", currentStatement); addOpenStatements(currentStatement); return currentStatement; } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java index 66917ea88..e8f206072 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java @@ -783,19 +783,11 @@ public boolean dataDefinitionIgnoredInTransactions() { @Override public ResultSet getProcedures( String catalog, String schemaPattern, String procedureNamePattern) { - if ((catalog == null || catalog.isEmpty()) - || (schemaPattern != null && schemaPattern.isEmpty()) - || (procedureNamePattern != null && procedureNamePattern.isEmpty())) { - LOG.warning("Returning empty ResultSet as catalog is null/empty or a pattern is empty."); - return new BigQueryJsonResultSet(); - } - LOG.info( - String.format( - "getProcedures called for catalog: %s, schemaPattern: %s, procedureNamePattern: %s", - catalog, schemaPattern, procedureNamePattern)); - - final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); + "getProcedures called for catalog: %s, schemaPattern: %s, procedureNamePattern: %s", + catalog, + schemaPattern, + procedureNamePattern); final Pattern procedureNameRegex = compileSqlLikePattern(procedureNamePattern); final Schema resultSchema = defineGetProceduresSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -1036,9 +1028,8 @@ void processProcedureInfo( } catch (Exception e) { LOG.warning( - String.format( "Error processing procedure info for %s: %s. Skipping this procedure.", - routineId, e.getMessage())); + routineId, e.getMessage()); } } @@ -1077,10 +1068,12 @@ public ResultSet getProcedureColumns( } LOG.info( - String.format( - "getProcedureColumns called for catalog: %s, schemaPattern: %s, procedureNamePattern:" - + " %s, columnNamePattern: %s", - catalog, schemaPattern, procedureNamePattern, columnNamePattern)); + "getProcedureColumns called for catalog: %s, schemaPattern: %s, procedureNamePattern:" + + " %s, columnNamePattern: %s", + catalog, + schemaPattern, + procedureNamePattern, + columnNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern procedureNameRegex = compileSqlLikePattern(procedureNamePattern); @@ -1221,9 +1214,8 @@ public ResultSet getProcedureColumns( private List fetchMatchingDatasetsForProcedureColumns( String catalogParam, String schemaPattern, Pattern schemaRegex) throws InterruptedException { LOG.fine( - String.format( "Fetching matching datasets for catalog '%s', schemaPattern '%s'", - catalogParam, schemaPattern)); + catalogParam, schemaPattern); List datasetsToScan = findMatchingBigQueryObjects( "Dataset", @@ -1235,9 +1227,8 @@ private List fetchMatchingDatasetsForProcedureColumns( schemaRegex, LOG); LOG.info( - String.format( "Found %d datasets to scan for procedures in catalog '%s'.", - datasetsToScan.size(), catalogParam)); + datasetsToScan.size(), catalogParam); return datasetsToScan; } @@ -1495,10 +1486,9 @@ void processProcedureArguments( arguments = routine.getArguments(); } catch (Exception e) { LOG.warning( - String.format( "Could not retrieve arguments list for procedure %s: %s. No arguments will be" + " processed.", - routineId, e.getMessage())); + routineId, e.getMessage()); return; } @@ -1527,10 +1517,9 @@ void processProcedureArguments( argName = arg.getName(); } catch (Exception listAccessException) { LOG.warning( - String.format( "Exception during arguments.get(%d) for Proc: %s. Ordinal: %d. Message: %s." + " Generating fallback row.", - i, routineId, ordinalPosition, listAccessException.getMessage())); + i, routineId, ordinalPosition, listAccessException.getMessage()); argName = "arg_retrieval_err_" + ordinalPosition; arg = null; } @@ -1568,20 +1557,18 @@ List createProcedureColumnRow( if (argument == null) { LOG.warning( - String.format( "Proc: %s, Arg: %s (Pos %d) - RoutineArgument object is null. Defaulting type to" + " VARCHAR.", - procedureName, columnName, ordinalPosition)); + procedureName, columnName, ordinalPosition); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } else { try { StandardSQLDataType argumentDataType = argument.getDataType(); if (argumentDataType == null) { LOG.warning( - String.format( "Proc: %s, Arg: %s (Pos %d) - argument.getDataType() returned null. Defaulting" + " type to VARCHAR.", - procedureName, columnName, ordinalPosition)); + procedureName, columnName, ordinalPosition); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } else { typeInfo = @@ -1590,10 +1577,9 @@ List createProcedureColumnRow( } } catch (Exception e) { LOG.warning( - String.format( "Proc: %s, Arg: %s (Pos %d) - Unexpected Exception during type processing." + " Defaulting type to VARCHAR. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage())); + procedureName, columnName, ordinalPosition, e.getMessage()); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } } @@ -1604,9 +1590,8 @@ List createProcedureColumnRow( argumentModeStr = argument.getMode(); } catch (Exception e) { LOG.warning( - String.format( "Proc: %s, Arg: %s (Pos %d) - Could not get argument mode. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage())); + procedureName, columnName, ordinalPosition, e.getMessage()); } } @@ -1672,10 +1657,9 @@ ColumnTypeInfo determineTypeInfoFromDataType( } } catch (Exception e) { LOG.warning( - String.format( "Proc: %s, Arg: %s (Pos %d) - Caught an unexpected Exception during type" + " determination. Defaulting type to VARCHAR. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage())); + procedureName, columnName, ordinalPosition, e.getMessage()); } return defaultVarcharTypeInfo; } @@ -1733,9 +1717,11 @@ public ResultSet getTables( } LOG.info( - String.format( - "getTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s, types: %s", - effectiveCatalog, effectiveSchemaPattern, tableNamePattern, Arrays.toString(types))); + "getTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s, types: %s", + effectiveCatalog, + effectiveSchemaPattern, + tableNamePattern, + Arrays.toString(types)); final Pattern schemaRegex = compileSqlLikePattern(effectiveSchemaPattern); final Pattern tableNameRegex = compileSqlLikePattern(tableNamePattern); @@ -1959,9 +1945,8 @@ void processTableInfo( if (requestedTypes != null && !requestedTypes.contains(bqTableType)) { LOG.finer( - String.format( "Skipping table %s as its type '%s' is not in the requested types %s", - tableId, bqTableType, requestedTypes)); + tableId, bqTableType, requestedTypes); return; } @@ -1983,9 +1968,8 @@ void processTableInfo( LOG.fine("Processed and added table info row for: " + tableId); } catch (Exception e) { LOG.warning( - String.format( "Error processing table info for %s: %s. Skipping this table.", - tableId, e.getMessage())); + tableId, e.getMessage()); } } @@ -2105,10 +2089,12 @@ public ResultSet getColumns( } LOG.info( - String.format( - "getColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," - + " columnNamePattern: %s", - effectiveCatalog, effectiveSchemaPattern, tableNamePattern, columnNamePattern)); + "getColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," + + " columnNamePattern: %s", + effectiveCatalog, + effectiveSchemaPattern, + tableNamePattern, + columnNamePattern); Pattern schemaRegex = compileSqlLikePattern(effectiveSchemaPattern); Pattern tableNameRegex = compileSqlLikePattern(tableNamePattern); @@ -2257,9 +2243,8 @@ private void processTableColumns( || tableSchema.getFields() == null || tableSchema.getFields().isEmpty()) { LOG.warning( - String.format( "Schema not found or fields are null for table %s (Type: %s). Skipping columns.", - tableId, definition.getType())); + tableId, definition.getType()); return; } @@ -2284,12 +2269,10 @@ private void processTableColumns( LOG.fine("Finished processing columns for table: " + tableId); } catch (BigQueryException e) { LOG.warning( - String.format( "BigQueryException processing table %s: %s (Code: %d)", - tableId, e.getMessage(), e.getCode())); + tableId, e.getMessage(), e.getCode()); } catch (Exception e) { - LOG.severe( - String.format("Unexpected error processing table %s: %s", tableId, e.getMessage())); + LOG.severe("Unexpected error processing table %s: %s", tableId, e.getMessage()); } } @@ -2511,10 +2494,12 @@ private Comparator defineGetColumnsComparator(FieldList resultSc public ResultSet getColumnPrivileges( String catalog, String schema, String table, String columnNamePattern) { LOG.info( - String.format( - "getColumnPrivileges called for catalog: %s, schema: %s, table: %s, columnNamePattern:" - + " %s. BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", - catalog, schema, table, columnNamePattern)); + "getColumnPrivileges called for catalog: %s, schema: %s, table: %s, columnNamePattern:" + + " %s. BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", + catalog, + schema, + table, + columnNamePattern); final Schema resultSchema = defineGetColumnPrivilegesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2540,10 +2525,11 @@ Schema defineGetColumnPrivilegesSchema() { public ResultSet getTablePrivileges( String catalog, String schemaPattern, String tableNamePattern) { LOG.info( - String.format( - "getTablePrivileges called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " - + "BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", - catalog, schemaPattern, tableNamePattern)); + "getTablePrivileges called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " + + "BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", + catalog, + schemaPattern, + tableNamePattern); final Schema resultSchema = defineGetTablePrivilegesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2562,11 +2548,14 @@ Schema defineGetTablePrivilegesSchema() { public ResultSet getBestRowIdentifier( String catalog, String schema, String table, int scope, boolean nullable) { LOG.info( - String.format( - "getBestRowIdentifier called for catalog: %s, schema: %s, table: %s, scope: %d," - + " nullable: %s. BigQuery does not support best row identifiers; returning empty" - + " ResultSet.", - catalog, schema, table, scope, nullable)); + "getBestRowIdentifier called for catalog: %s, schema: %s, table: %s, scope: %d," + + " nullable: %s. BigQuery does not support best row identifiers; returning empty" + + " ResultSet.", + catalog, + schema, + table, + scope, + nullable); final Schema resultSchema = defineGetBestRowIdentifierSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2614,10 +2603,11 @@ Schema defineGetBestRowIdentifierSchema() { @Override public ResultSet getVersionColumns(String catalog, String schema, String table) { LOG.info( - String.format( - "getVersionColumns called for catalog: %s, schema: %s, table: %s. " - + "Automatic version columns not supported by BigQuery; returning empty ResultSet.", - catalog, schema, table)); + "getVersionColumns called for catalog: %s, schema: %s, table: %s. " + + "Automatic version columns not supported by BigQuery; returning empty ResultSet.", + catalog, + schema, + table); final Schema resultSchema = defineGetVersionColumnsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3324,13 +3314,12 @@ public boolean supportsBatchUpdates() { public ResultSet getUDTs( String catalog, String schemaPattern, String typeNamePattern, int[] types) { LOG.info( - String.format( - "getUDTs called for catalog: %s, schemaPattern: %s, typeNamePattern: %s, types: %s. " - + "Feature not supported by BigQuery; returning empty ResultSet.", - catalog, - schemaPattern, - typeNamePattern, - (types == null ? "null" : Arrays.toString(types)))); + "getUDTs called for catalog: %s, schemaPattern: %s, typeNamePattern: %s, types: %s. " + + "Feature not supported by BigQuery; returning empty ResultSet.", + catalog, + schemaPattern, + typeNamePattern, + (types == null ? "null" : Arrays.toString(types))); final Schema resultSchema = defineGetUDTsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3401,10 +3390,11 @@ public boolean supportsGetGeneratedKeys() { @Override public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) { LOG.info( - String.format( - "getSuperTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " - + "BigQuery does not support super tables; returning empty ResultSet.", - catalog, schemaPattern, tableNamePattern)); + "getSuperTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " + + "BigQuery does not support super tables; returning empty ResultSet.", + catalog, + schemaPattern, + tableNamePattern); final Schema resultSchema = defineGetSuperTablesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3439,10 +3429,11 @@ Schema defineGetSuperTablesSchema() { @Override public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) { LOG.info( - String.format( - "getSuperTypes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s. BigQuery" - + " does not support user-defined type hierarchies; returning empty ResultSet.", - catalog, schemaPattern, typeNamePattern)); + "getSuperTypes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s. BigQuery" + + " does not support user-defined type hierarchies; returning empty ResultSet.", + catalog, + schemaPattern, + typeNamePattern); final Schema resultSchema = defineGetSuperTypesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3486,11 +3477,13 @@ Schema defineGetSuperTypesSchema() { public ResultSet getAttributes( String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) { LOG.info( - String.format( - "getAttributes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s," - + " attributeNamePattern: %s. Feature not supported by BigQuery; returning empty" - + " ResultSet.", - catalog, schemaPattern, typeNamePattern, attributeNamePattern)); + "getAttributes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s," + + " attributeNamePattern: %s. Feature not supported by BigQuery; returning empty" + + " ResultSet.", + catalog, + schemaPattern, + typeNamePattern, + attributeNamePattern); final Schema resultSchema = defineGetAttributesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3652,9 +3645,7 @@ public ResultSet getSchemas(String catalog, String schemaPattern) { return new BigQueryJsonResultSet(); } - LOG.info( - String.format( - "getSchemas called for catalog: %s, schemaPattern: %s", catalog, schemaPattern)); + LOG.info("getSchemas called for catalog: %s, schemaPattern: %s", catalog, schemaPattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Schema resultSchema = defineGetSchemasSchema(); @@ -3780,9 +3771,8 @@ void processSchemaInfo( LOG.finer("Processed and added schema info row for: " + datasetId); } catch (Exception e) { LOG.warning( - String.format( "Error processing schema info for dataset %s: %s. Skipping this schema.", - datasetId, e.getMessage())); + datasetId, e.getMessage()); } } @@ -3901,9 +3891,10 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct } LOG.info( - String.format( - "getFunctions called for catalog: %s, schemaPattern: %s, functionNamePattern: %s", - catalog, schemaPattern, functionNamePattern)); + "getFunctions called for catalog: %s, schemaPattern: %s, functionNamePattern: %s", + catalog, + schemaPattern, + functionNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern functionNameRegex = compileSqlLikePattern(functionNamePattern); @@ -3954,9 +3945,8 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct Callable> apiCallable = () -> { LOG.fine( - String.format( "Fetching all routines for dataset: %s, pattern: %s", - currentDatasetId.getDataset(), functionNamePattern)); + currentDatasetId.getDataset(), functionNamePattern); return findMatchingBigQueryObjects( "Routine", () -> @@ -4113,9 +4103,8 @@ void processFunctionInfo( } catch (Exception e) { LOG.warning( - String.format( "Error processing function info for %s: %s. Skipping this function.", - routineId, e.getMessage())); + routineId, e.getMessage()); } } @@ -4154,10 +4143,12 @@ public ResultSet getFunctionColumns( } LOG.info( - String.format( - "getFunctionColumns called for catalog: %s, schemaPattern: %s, functionNamePattern: %s," - + " columnNamePattern: %s", - catalog, schemaPattern, functionNamePattern, columnNamePattern)); + "getFunctionColumns called for catalog: %s, schemaPattern: %s, functionNamePattern: %s," + + " columnNamePattern: %s", + catalog, + schemaPattern, + functionNamePattern, + columnNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern functionNameRegex = compileSqlLikePattern(functionNamePattern); @@ -4701,11 +4692,13 @@ Comparator defineGetFunctionColumnsComparator(FieldList resultSc public ResultSet getPseudoColumns( String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) { LOG.info( - String.format( - "getPseudoColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," - + " columnNamePattern: %s. Pseudo columns not supported by BigQuery; returning" - + " empty ResultSet.", - catalog, schemaPattern, tableNamePattern, columnNamePattern)); + "getPseudoColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," + + " columnNamePattern: %s. Pseudo columns not supported by BigQuery; returning" + + " empty ResultSet.", + catalog, + schemaPattern, + tableNamePattern, + columnNamePattern); final Schema resultSchema = defineGetPseudoColumnsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -4824,34 +4817,30 @@ private Tuple determineEffectiveCatalogAndSchema( effectiveCatalog = defaultProjectFromConnection; effectiveSchemaPattern = defaultSchemaFromConnection; LOG.info( - String.format( - logPrefix + "Using default catalog '%s' and default dataset '%s'.", - effectiveCatalog, - effectiveSchemaPattern)); + logPrefix + "Using default catalog '%s' and default dataset '%s'.", + effectiveCatalog, + effectiveSchemaPattern); } else if (catalogIsNullOrEmptyOrWildcard) { effectiveCatalog = defaultProjectFromConnection; LOG.info( - String.format( - logPrefix - + "Using default catalog '%s' with user dataset '%s'. Default dataset '%s' ignored.", - effectiveCatalog, - effectiveSchemaPattern, - defaultSchemaFromConnection)); + logPrefix + + "Using default catalog '%s' with user dataset '%s'. Default dataset '%s' ignored.", + effectiveCatalog, + effectiveSchemaPattern, + defaultSchemaFromConnection); } else if (schemaPatternIsNullOrEmptyOrWildcard) { effectiveSchemaPattern = defaultSchemaFromConnection; LOG.info( - String.format( - logPrefix + "Using user catalog '%s' and default dataset '%s'.", - effectiveCatalog, - effectiveSchemaPattern)); + logPrefix + "Using user catalog '%s' and default dataset '%s'.", + effectiveCatalog, + effectiveSchemaPattern); } else { LOG.info( - String.format( - logPrefix - + "Using user catalog '%s' and schema '%s'. Default dataset '%s' ignored.", - effectiveCatalog, - effectiveSchemaPattern, - defaultSchemaFromConnection)); + logPrefix + + "Using user catalog '%s' and schema '%s'. Default dataset '%s' ignored.", + effectiveCatalog, + effectiveSchemaPattern, + defaultSchemaFromConnection); } } return Tuple.of(effectiveCatalog, effectiveSchemaPattern); @@ -4914,9 +4903,9 @@ List findMatchingBigQueryObjects( Iterable objects; if (needsList) { logger.info( - String.format( - "Listing all %ss (pattern: %s)...", - objectTypeName, pattern == null ? "" : pattern)); + "Listing all %ss (pattern: %s)...", + objectTypeName, + pattern == null ? "" : pattern); Page firstPage = listAllOperation.get(); objects = firstPage.iterateAll(); logger.fine( @@ -4924,14 +4913,14 @@ List findMatchingBigQueryObjects( "Retrieved initial %s list, iterating & filtering if needed...", objectTypeName)); } else { - logger.info(String.format("Getting specific %s: '%s'", objectTypeName, pattern)); + logger.info("Getting specific %s: '%s'", objectTypeName, pattern); T specificObject = getSpecificOperation.apply(pattern); objects = (specificObject == null) ? Collections.emptyList() : Collections.singletonList(specificObject); if (specificObject == null) { - logger.info(String.format("Specific %s not found: '%s'", objectTypeName, pattern)); + logger.info("Specific %s not found: '%s'", objectTypeName, pattern); } } @@ -4956,7 +4945,7 @@ List findMatchingBigQueryObjects( } catch (BigQueryException e) { if (!needsList && e.getCode() == 404) { - logger.info(String.format("%s '%s' not found (API error 404).", objectTypeName, pattern)); + logger.info("%s '%s' not found (API error 404).", objectTypeName, pattern); } else { logger.warning( String.format( @@ -5036,20 +5025,18 @@ void sortResults( BigQueryJdbcCustomLogger logger) { if (collectedResults == null || collectedResults.isEmpty()) { - logger.info(String.format("No results collected for %s, skipping sort.", operationName)); + logger.info("No results collected for %s, skipping sort.", operationName); return; } if (comparator == null) { - logger.info(String.format("No comparator provided for %s, skipping sort.", operationName)); + logger.info("No comparator provided for %s, skipping sort.", operationName); return; } - logger.info( - String.format( - "Sorting %d collected %s results...", collectedResults.size(), operationName)); + logger.info("Sorting %d collected %s results...", collectedResults.size(), operationName); try { collectedResults.sort(comparator); - logger.info(String.format("%s result sorting completed.", operationName)); + logger.info("%s result sorting completed.", operationName); } catch (Exception e) { logger.severe( String.format("Error during sorting %s results: %s", operationName, e.getMessage())); @@ -5174,7 +5161,7 @@ private Long getLongValueOrNull(FieldValueList fvl, int index) { } private void waitForTasksCompletion(List> taskFutures) { - LOG.info(String.format("Waiting for %d submitted tasks to complete...", taskFutures.size())); + LOG.info("Waiting for %d submitted tasks to complete...", taskFutures.size()); for (Future future : taskFutures) { try { if (!future.isCancelled()) { @@ -5184,9 +5171,8 @@ private void waitForTasksCompletion(List> taskFutures) { LOG.warning("A table processing task was cancelled."); } catch (ExecutionException e) { LOG.severe( - String.format( "Error executing table processing task: %s", - (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()))); + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage())); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warning( @@ -5203,7 +5189,7 @@ private void populateQueue( List collectedResults, BlockingQueue queue, FieldList resultSchemaFields) { - LOG.info(String.format("Populating queue with %d results...", collectedResults.size())); + LOG.info("Populating queue with %d results...", collectedResults.size()); try { for (FieldValueList sortedRow : collectedResults) { if (Thread.currentThread().isInterrupted()) { diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java index 8d1dfb138..ab92d56d0 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java @@ -144,11 +144,13 @@ public Connection connect(String url, Properties info) throws SQLException { logPath = BigQueryJdbcUrlUtility.DEFAULT_LOG_PATH; } - BigQueryJdbcRootLogger.setLevel(logLevel, logPath); + BigQueryJdbcRootLogger.setLevel(logLevel); + BigQueryJdbcRootLogger.enableFileLogger(logPath + + ); // Logging starts from here. BigQueryConnection connection = new BigQueryConnection(connectionUri); LOG.info( - String.format( "Driver info : { {Database Product Name : %s}, " + "{Database Product Version : %s}, " + "{Driver Name : %s}, " @@ -162,7 +164,7 @@ public Connection connect(String url, Properties info) throws SQLException { connection.getMetaData().getDriverVersion(), logLevel, logPath, - this.toString())); + this.toString()); return connection; } else { return null; diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java index 611b200ff..019e7e4ca 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java @@ -29,4 +29,32 @@ protected BigQueryJdbcCustomLogger(String name, String resourceBundleName) { this(name, null); this.setParent(BigQueryJdbcRootLogger.getRootLogger()); } + + void finest(String format, Object... args){ + this.finest(() -> String.format(format, args)); + } + + void finer(String format, Object... args){ + this.finer(() -> String.format(format, args)); + } + + void fine(String format, Object... args){ + this.fine(() -> String.format(format, args)); + } + + void config(String format, Object... args){ + this.config(() -> String.format(format, args)); + } + + void info(String format, Object... args){ + this.info(() -> String.format(format, args)); + } + + void warning(String format, Object... args){ + this.warning(() -> String.format(format, args)); + } + + void severe(String format, Object... args){ + this.severe(() -> String.format(format, args)); + } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java index 5f486f1e5..f0215a118 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java @@ -507,9 +507,8 @@ private static GoogleCredentials getGoogleUserAccountCredentials( return getCredentialsFromCode(userAuthorizer, code, callerClassName); } catch (IOException | URISyntaxException ex) { LOG.severe( - String.format( "Failed to establish connection using User Account authentication: %s", - ex.getMessage())); + ex.getMessage()); throw new BigQueryJdbcRuntimeException(ex); } } @@ -594,9 +593,8 @@ private static GoogleCredentials getApplicationDefaultCredentials(String callerC principal = "external account"; } LOG.info( - String.format( "Connection established. Auth Method: Application Default Credentials, Principal: %s.", - principal)); + principal); return credentials; } catch (IOException exception) { // TODO throw exception diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java index 3b26f7be5..43044b190 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java @@ -601,8 +601,7 @@ static String appendPropertiesToURL(String url, String callerClassName, Properti StringBuilder urlBuilder = new StringBuilder(url); for (Entry entry : properties.entrySet()) { if (entry.getValue() != null && !"".equals(entry.getValue())) { - LOG.info( - String.format("Appending %s with value %s to URL", entry.getKey(), entry.getValue())); + LOG.info("Appending %s with value %s to URL", entry.getKey(), entry.getValue()); urlBuilder.append(";").append(entry.getKey()).append("=").append(entry.getValue()); } } @@ -707,9 +706,8 @@ static Integer parseIntProperty( return Integer.parseInt(parsedValue); } catch (NumberFormatException e) { LOG.severe( - String.format( "Invalid integer value '%s' for property '%s'. Please provide a valid integer.", - parsedValue, propertyName)); + parsedValue, propertyName); throw new IllegalArgumentException( String.format("Invalid integer value for property '%s': %s", propertyName, parsedValue), e); @@ -760,8 +758,7 @@ public static Level parseLogLevel(String logLevelString) { case 0: default: LOG.info( - String.format( - "%s value not provided, defaulting to %s.", LOG_LEVEL_PROPERTY_NAME, Level.OFF)); + "%s value not provided, defaulting to %s.", LOG_LEVEL_PROPERTY_NAME, Level.OFF); return Level.OFF; } } @@ -799,9 +796,8 @@ public static boolean parseJobCreationMode(String url, String callerClassName) { if (jobCreationMode == null) { LOG.fine( - String.format( "%s value not provided, defaulting to %s. Caller: %s", - JOB_CREATION_MODE_PROPERTY_NAME, DEFAULT_JOB_CREATION_MODE, callerClassName)); + JOB_CREATION_MODE_PROPERTY_NAME, DEFAULT_JOB_CREATION_MODE, callerClassName); // Default Job creation mode is JOB_CREATION_OPTIONAL(2) // which translates to options.setQueryPreviewEnabled(true) return true; @@ -898,7 +894,7 @@ private static Map parsePropertiesMap( LOG.finest("++enter++\t" + callerClassName); String propertiesString = BigQueryJdbcUrlUtility.parseUriProperty(url, propertyName); if (propertiesString == null || propertiesString.isEmpty()) { - LOG.fine(String.format("Unable to parse property name: %s from url: %s", propertyName, url)); + LOG.fine("Unable to parse property name: %s from url: %s", propertyName, url); return null; } Map propertiesMap = new HashMap<>(); @@ -910,9 +906,8 @@ private static Map parsePropertiesMap( propertiesMap.put(parts[0], parts[1]); } else { LOG.warning( - String.format( "Invalid KeyValue pair: %s found in url: %s for property name: %s", - keyValuePair, url, propertyName)); + keyValuePair, url, propertyName); } } return propertiesMap; diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java index f9d7b1153..3773b99aa 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java @@ -263,7 +263,7 @@ private FieldValue getObjectInternal(int columnIndex) throws SQLException { @Override public void close() { - LOG.fine(String.format("Closing BigqueryJsonResultSet %s.", this)); + LOG.fine("Closing BigqueryJsonResultSet %s.", this); this.isClosed = true; if (ownedThreads != null) { for (Thread ownedThread : ownedThreads) { diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java index 9644dd581..63bf6ffff 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java @@ -60,9 +60,8 @@ QueryJobConfiguration.Builder configureParameters( Object parameterValue = getParameter(i); StandardSQLTypeName sqlType = getSqlType(i); LOG.info( - String.format( "Parameter %s of type %s at index %s added to QueryJobConfiguration", - parameterValue, sqlType, i)); + parameterValue, sqlType, i); jobConfigurationBuilder.addPositionalParameter( QueryParameterValue.of(parameterValue, sqlType)); } @@ -77,7 +76,7 @@ QueryJobConfiguration.Builder configureParameters( void setParameter(int parameterIndex, Object value, Class type) throws BigQueryJdbcSqlFeatureNotSupportedException { LOG.finest("++enter++"); - LOG.finest(String.format("setParameter called by : %s", type.getName())); + LOG.finest("setParameter called by : %s", type.getName()); checkValidIndex(parameterIndex); int arrayIndex = parameterIndex - 1; @@ -99,7 +98,7 @@ void setParameter(int parameterIndex, Object value, Class type) parameter.setParamType(BigQueryStatementParameterType.UNSPECIFIED); parameter.setScale(-1); - LOG.finest(String.format("Parameter set { %s }", parameter.toString())); + LOG.finest("Parameter set { %s }", parameter.toString()); } private void checkValidIndex(int parameterIndex) { @@ -150,7 +149,7 @@ void setParameter( int scale) throws BigQueryJdbcSqlFeatureNotSupportedException { LOG.finest("++enter++"); - LOG.finest(String.format("setParameter called by : %s", type.getName())); + LOG.finest("setParameter called by : %s", type.getName()); if (paramName == null || paramName.isEmpty()) { throw new IllegalArgumentException("paramName cannot be null or empty"); } @@ -175,7 +174,7 @@ void setParameter( if (parameter.getIndex() == -1) { parametersList.add(parameter); } - LOG.finest(String.format("Parameter set { %s }", parameter.toString())); + LOG.finest("Parameter set { %s }", parameter.toString()); } // set parameter by index and type @@ -187,7 +186,7 @@ void setParameter( int scale) throws BigQueryJdbcSqlFeatureNotSupportedException { LOG.finest("++enter++"); - LOG.finest(String.format("setParameter called by : %s", type.getName())); + LOG.finest("setParameter called by : %s", type.getName()); checkValidIndex(parameterIndex); int arrayIndex = parameterIndex - 1; if (parameterIndex >= this.highestIndex || this.parametersList.get(arrayIndex) == null) { @@ -208,7 +207,7 @@ void setParameter( parameter.setParamType(paramType); parameter.setScale(scale); - LOG.finest(String.format("Parameter set { %s }", parameter.toString())); + LOG.finest("Parameter set { %s }", parameter.toString()); } // Get Parameter by name diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java index ebb07dc11..0bc012954 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java @@ -134,8 +134,7 @@ public synchronized void fireConnectionError(SQLException e) { for (ConnectionEventListener listener : listeners) { listener.connectionErrorOccurred(event); } - LOG.finest( - String.format("Connection handle removed from the pool due to error: %s", e.getMessage())); + LOG.finest("Connection handle removed from the pool due to error: %s", e.getMessage()); // Listners no longer need to listen for this connection since it has been removed from the // pool. for (ConnectionEventListener listener : listeners) { diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java index 2410f6a58..a311abc48 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java @@ -404,9 +404,8 @@ private void setInsertMetadata(QueryStatistics statistics) throws SQLException { this.insertTableName = TableName.of(tableID.getProject(), tableID.getDataset(), tableID.getTable()); LOG.finest( - String.format( "this.insertTableName : %s, this.insertSchema : %s", - this.insertTableName, this.insertSchema.toString())); + this.insertTableName, this.insertSchema.toString()); } QueryJobConfiguration getWriteBatchJobConfiguration( @@ -433,9 +432,8 @@ QueryJobConfiguration getStandardBatchJobConfiguration(String query) throws SQLE Object parameterValue = parameter.getValue(); StandardSQLTypeName sqlType = parameter.getSqlType(); LOG.finest( - String.format( "Parameter %s of type %s at index %s added to QueryJobConfiguration", - parameterValue, sqlType, index++)); + parameterValue, sqlType, index++); jobConfiguration.addPositionalParameter(QueryParameterValue.of(parameterValue, sqlType)); } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index 0da086888..655a6f3c5 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -325,9 +325,8 @@ SqlType getQueryType(QueryJobConfiguration jobConfiguration, StatementType state SqlType sqlType = BigQuerySqlTypeConverter.getSqlTypeFromStatementType(statementType); LOG.fine( - String.format( "Query: %s, Statement Type: %s, SQL Type: %s", - jobConfiguration.getQuery(), statementType, sqlType)); + jobConfiguration.getQuery(), statementType, sqlType); return sqlType; } @@ -359,7 +358,7 @@ QueryStatistics getQueryStatistics(QueryJobConfiguration queryJobConfiguration) */ @Override public void close() throws SQLException { - LOG.fine(String.format("Closing Statement %s.", this)); + LOG.fine("Closing Statement %s.", this); if (isClosed()) { return; } @@ -369,7 +368,7 @@ public void close() throws SQLException { cancel(); // This attempts to cancel jobs and calls closeStatementResources() cancelSucceeded = true; } catch (SQLException e) { - LOG.warning(String.format("Failed to cancel statement during close().", e)); + LOG.warning("Failed to cancel statement during close().", e); } finally { if (!cancelSucceeded) { closeStatementResources(); @@ -425,7 +424,7 @@ public void setQueryTimeout(int seconds) { */ @Override public void cancel() throws SQLException { - LOG.finest(String.format("Statement %s cancelled", this)); + LOG.finest("Statement %s cancelled", this); synchronized (cancelLock) { this.isCanceled = true; for (JobId jobId : this.jobIds) { @@ -855,9 +854,8 @@ Thread populateArrowBufferedQueue( /** Executes SQL query using either fast query path or read API */ void processQueryResponse(String query, TableResult results) throws SQLException { LOG.finest( - String.format( "API call completed{Query=%s, Parent Job ID=%s, Total rows=%s} ", - query, results.getJobId(), results.getTotalRows())); + query, results.getJobId(), results.getTotalRows()); JobId currentJobId = results.getJobId(); if (currentJobId == null) { LOG.fine("Standard API with Stateless query used."); @@ -905,7 +903,7 @@ private boolean meetsReadRatio(TableResult results) { BigQueryJsonResultSet processJsonResultSet(TableResult results) { String jobIdOrQueryId = results.getJobId() == null ? results.getQueryId() : results.getJobId().getJob(); - LOG.info(String.format("BigQuery Job %s completed. Fetching results.", jobIdOrQueryId)); + LOG.info("BigQuery Job %s completed. Fetching results.", jobIdOrQueryId); List threadList = new ArrayList(); Schema schema = results.getSchema(); @@ -1024,10 +1022,9 @@ Thread runNextPageTaskAsync( // thread rpcResponseQueue.put(Tuple.of(results, true)); LOG.fine( - String.format( "Fetched %d results from the server in %d ms.", querySettings.getMaxResultPerPage(), - (int) ((System.nanoTime() - startTime) / 1000000))); + (int) ((System.nanoTime() - startTime) / 1000000)); } // this will stop the parseDataTask as well when the pagination // completes @@ -1100,9 +1097,8 @@ Thread parseAndPopulateRpcDataAsync( } } LOG.fine( - String.format( "Processed %d results in %d ms.", - results, (int) ((System.nanoTime() - startTime) / 1000000))); + results, (int) ((System.nanoTime() - startTime) / 1000000)); } try { // All the pages has been processed, put this marker @@ -1177,7 +1173,7 @@ private int getBufferSize() { /** Returns the destinationTable from jobId by calling `jobs.get` API */ TableId getDestinationTable(JobId jobId) { Job job = this.bigQuery.getJob(jobId); - LOG.finest(String.format("Destination Table retrieved from %s", job.getJobId())); + LOG.finest("Destination Table retrieved from %s", job.getJobId()); return ((QueryJobConfiguration) job.getConfiguration()).getDestinationTable(); } @@ -1230,7 +1226,7 @@ QueryJobConfiguration.Builder getJobConfig(String query) { private void checkIfDatasetExistElseCreate(String datasetName) { Dataset dataset = bigQuery.getDataset(DatasetId.of(datasetName)); if (dataset == null) { - LOG.info(String.format("Creating a hidden dataset: %s ", datasetName)); + LOG.info("Creating a hidden dataset: %s ", datasetName); DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName) .setDefaultTableLifetime(this.querySettings.getDestinationDatasetExpirationTime()) diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java index a5aa7a73a..bba57d731 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java @@ -38,7 +38,7 @@ public BigQueryThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r, threadPrefix + (++threadSerialNum)); // non thread safe increment t.setDaemon(true); - LOG.finest(String.format("New thread %s created.", t.getName())); + LOG.finest("New thread %s created.", t.getName()); return t; } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercer.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercer.java index d156c2d66..42640ddf2 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercer.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercer.java @@ -104,7 +104,7 @@ T coerceTo(Class targetClass, Object value) { return targetClass.cast(value); } BigQueryCoercion coercion = findCoercion(sourceClass, targetClass); - LOG.finest(() -> String.format("%s coercion for %s", coercion, value)); + LOG.finest("%s coercion for %s", coercion, value); // Value is null case & no explicit coercion if (sourceClass == Void.class && coercion == null) { return null; diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java index c0f082043..524a82bc9 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java @@ -118,9 +118,7 @@ public void connectionErrorOccurred(ConnectionEvent event) { (event.getSQLException() != null) ? event.getSQLException().getMessage() : "Connection error occured"; - LOG.finest( - String.format( - "Removed pooled connection from connection pool due to error: %s", errorMessage)); + LOG.finest("Removed pooled connection from connection pool dor: %s", errorMessage); } @Override From cb6949b837f87d69cb59bd4dd9d09a1c0ea1a085 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Thu, 5 Feb 2026 20:52:28 +0000 Subject: [PATCH 2/3] lint --- .../jdbc/BigQueryCallableStatement.java | 14 +- .../jdbc/BigQueryDatabaseMetaData.java | 168 +++++++----------- .../cloud/bigquery/jdbc/BigQueryDriver.java | 34 ++-- .../jdbc/BigQueryJdbcCustomLogger.java | 14 +- .../jdbc/BigQueryJdbcOAuthUtility.java | 7 +- .../bigquery/jdbc/BigQueryJdbcUrlUtility.java | 17 +- .../jdbc/BigQueryParameterHandler.java | 6 +- .../jdbc/BigQueryPreparedStatement.java | 8 +- .../bigquery/jdbc/BigQueryStatement.java | 18 +- .../jdbc/PooledConnectionListener.java | 2 +- 10 files changed, 124 insertions(+), 164 deletions(-) diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java index 78ae6dd9c..4de22e64e 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java @@ -965,8 +965,7 @@ public void registerOutParameter(String paramName, int sqlType) throws SQLExcept public void registerOutParameter(int paramIndex, int sqlType, int scale) throws SQLException { LOG.finest("++enter++"); LOG.finest( - "registerOutParameter: paramIndex %s, sqlType %s, scale %s", - paramIndex, sqlType, scale); + "registerOutParameter: paramIndex %s, sqlType %s, scale %s", paramIndex, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { throw new IllegalArgumentException( @@ -989,8 +988,8 @@ public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException { LOG.finest("++enter++"); LOG.finest( - "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", - paramIndex, sqlType, typeName); + "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", + paramIndex, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. registerOutParameter(paramIndex, sqlType); } @@ -999,8 +998,7 @@ public void registerOutParameter(int paramIndex, int sqlType, String typeName) public void registerOutParameter(String paramName, int sqlType, int scale) throws SQLException { LOG.finest("++enter++"); LOG.finest( - "registerOutParameter: paramIndex %s, sqlType %s, scale %s", - paramName, sqlType, scale); + "registerOutParameter: paramIndex %s, sqlType %s, scale %s", paramName, sqlType, scale); checkClosed(); if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) { throw new IllegalArgumentException( @@ -1023,8 +1021,8 @@ public void registerOutParameter(String paramName, int sqlType, String typeName) throws SQLException { LOG.finest("++enter++"); LOG.finest( - "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", - paramName, sqlType, typeName); + "registerOutParameter: paramIndex %s, sqlType %s, typeName %s", + paramName, sqlType, typeName); // fully qualified sql typeName is not supported by the driver and hence ignored. registerOutParameter(paramName, sqlType); } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java index e8f206072..1ef88a29d 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java @@ -783,11 +783,18 @@ public boolean dataDefinitionIgnoredInTransactions() { @Override public ResultSet getProcedures( String catalog, String schemaPattern, String procedureNamePattern) { + if ((catalog == null || catalog.isEmpty()) + || (schemaPattern != null && schemaPattern.isEmpty()) + || (procedureNamePattern != null && procedureNamePattern.isEmpty())) { + LOG.warning("Returning empty ResultSet as catalog is null/empty or a pattern is empty."); + return new BigQueryJsonResultSet(); + } + LOG.info( "getProcedures called for catalog: %s, schemaPattern: %s, procedureNamePattern: %s", - catalog, - schemaPattern, - procedureNamePattern); + catalog, schemaPattern, procedureNamePattern); + + final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern procedureNameRegex = compileSqlLikePattern(procedureNamePattern); final Schema resultSchema = defineGetProceduresSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -1028,8 +1035,8 @@ void processProcedureInfo( } catch (Exception e) { LOG.warning( - "Error processing procedure info for %s: %s. Skipping this procedure.", - routineId, e.getMessage()); + "Error processing procedure info for %s: %s. Skipping this procedure.", + routineId, e.getMessage()); } } @@ -1070,10 +1077,7 @@ public ResultSet getProcedureColumns( LOG.info( "getProcedureColumns called for catalog: %s, schemaPattern: %s, procedureNamePattern:" + " %s, columnNamePattern: %s", - catalog, - schemaPattern, - procedureNamePattern, - columnNamePattern); + catalog, schemaPattern, procedureNamePattern, columnNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern procedureNameRegex = compileSqlLikePattern(procedureNamePattern); @@ -1214,8 +1218,8 @@ public ResultSet getProcedureColumns( private List fetchMatchingDatasetsForProcedureColumns( String catalogParam, String schemaPattern, Pattern schemaRegex) throws InterruptedException { LOG.fine( - "Fetching matching datasets for catalog '%s', schemaPattern '%s'", - catalogParam, schemaPattern); + "Fetching matching datasets for catalog '%s', schemaPattern '%s'", + catalogParam, schemaPattern); List datasetsToScan = findMatchingBigQueryObjects( "Dataset", @@ -1227,8 +1231,8 @@ private List fetchMatchingDatasetsForProcedureColumns( schemaRegex, LOG); LOG.info( - "Found %d datasets to scan for procedures in catalog '%s'.", - datasetsToScan.size(), catalogParam); + "Found %d datasets to scan for procedures in catalog '%s'.", + datasetsToScan.size(), catalogParam); return datasetsToScan; } @@ -1486,9 +1490,9 @@ void processProcedureArguments( arguments = routine.getArguments(); } catch (Exception e) { LOG.warning( - "Could not retrieve arguments list for procedure %s: %s. No arguments will be" - + " processed.", - routineId, e.getMessage()); + "Could not retrieve arguments list for procedure %s: %s. No arguments will be" + + " processed.", + routineId, e.getMessage()); return; } @@ -1517,9 +1521,9 @@ void processProcedureArguments( argName = arg.getName(); } catch (Exception listAccessException) { LOG.warning( - "Exception during arguments.get(%d) for Proc: %s. Ordinal: %d. Message: %s." - + " Generating fallback row.", - i, routineId, ordinalPosition, listAccessException.getMessage()); + "Exception during arguments.get(%d) for Proc: %s. Ordinal: %d. Message: %s." + + " Generating fallback row.", + i, routineId, ordinalPosition, listAccessException.getMessage()); argName = "arg_retrieval_err_" + ordinalPosition; arg = null; } @@ -1557,18 +1561,18 @@ List createProcedureColumnRow( if (argument == null) { LOG.warning( - "Proc: %s, Arg: %s (Pos %d) - RoutineArgument object is null. Defaulting type to" - + " VARCHAR.", - procedureName, columnName, ordinalPosition); + "Proc: %s, Arg: %s (Pos %d) - RoutineArgument object is null. Defaulting type to" + + " VARCHAR.", + procedureName, columnName, ordinalPosition); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } else { try { StandardSQLDataType argumentDataType = argument.getDataType(); if (argumentDataType == null) { LOG.warning( - "Proc: %s, Arg: %s (Pos %d) - argument.getDataType() returned null. Defaulting" - + " type to VARCHAR.", - procedureName, columnName, ordinalPosition); + "Proc: %s, Arg: %s (Pos %d) - argument.getDataType() returned null. Defaulting" + + " type to VARCHAR.", + procedureName, columnName, ordinalPosition); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } else { typeInfo = @@ -1577,9 +1581,9 @@ List createProcedureColumnRow( } } catch (Exception e) { LOG.warning( - "Proc: %s, Arg: %s (Pos %d) - Unexpected Exception during type processing." - + " Defaulting type to VARCHAR. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage()); + "Proc: %s, Arg: %s (Pos %d) - Unexpected Exception during type processing." + + " Defaulting type to VARCHAR. Error: %s", + procedureName, columnName, ordinalPosition, e.getMessage()); typeInfo = new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null); } } @@ -1590,8 +1594,8 @@ List createProcedureColumnRow( argumentModeStr = argument.getMode(); } catch (Exception e) { LOG.warning( - "Proc: %s, Arg: %s (Pos %d) - Could not get argument mode. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage()); + "Proc: %s, Arg: %s (Pos %d) - Could not get argument mode. Error: %s", + procedureName, columnName, ordinalPosition, e.getMessage()); } } @@ -1657,9 +1661,9 @@ ColumnTypeInfo determineTypeInfoFromDataType( } } catch (Exception e) { LOG.warning( - "Proc: %s, Arg: %s (Pos %d) - Caught an unexpected Exception during type" - + " determination. Defaulting type to VARCHAR. Error: %s", - procedureName, columnName, ordinalPosition, e.getMessage()); + "Proc: %s, Arg: %s (Pos %d) - Caught an unexpected Exception during type" + + " determination. Defaulting type to VARCHAR. Error: %s", + procedureName, columnName, ordinalPosition, e.getMessage()); } return defaultVarcharTypeInfo; } @@ -1718,10 +1722,7 @@ public ResultSet getTables( LOG.info( "getTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s, types: %s", - effectiveCatalog, - effectiveSchemaPattern, - tableNamePattern, - Arrays.toString(types)); + effectiveCatalog, effectiveSchemaPattern, tableNamePattern, Arrays.toString(types)); final Pattern schemaRegex = compileSqlLikePattern(effectiveSchemaPattern); final Pattern tableNameRegex = compileSqlLikePattern(tableNamePattern); @@ -1945,8 +1946,8 @@ void processTableInfo( if (requestedTypes != null && !requestedTypes.contains(bqTableType)) { LOG.finer( - "Skipping table %s as its type '%s' is not in the requested types %s", - tableId, bqTableType, requestedTypes); + "Skipping table %s as its type '%s' is not in the requested types %s", + tableId, bqTableType, requestedTypes); return; } @@ -1968,8 +1969,7 @@ void processTableInfo( LOG.fine("Processed and added table info row for: " + tableId); } catch (Exception e) { LOG.warning( - "Error processing table info for %s: %s. Skipping this table.", - tableId, e.getMessage()); + "Error processing table info for %s: %s. Skipping this table.", tableId, e.getMessage()); } } @@ -2091,10 +2091,7 @@ public ResultSet getColumns( LOG.info( "getColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," + " columnNamePattern: %s", - effectiveCatalog, - effectiveSchemaPattern, - tableNamePattern, - columnNamePattern); + effectiveCatalog, effectiveSchemaPattern, tableNamePattern, columnNamePattern); Pattern schemaRegex = compileSqlLikePattern(effectiveSchemaPattern); Pattern tableNameRegex = compileSqlLikePattern(tableNamePattern); @@ -2243,8 +2240,8 @@ private void processTableColumns( || tableSchema.getFields() == null || tableSchema.getFields().isEmpty()) { LOG.warning( - "Schema not found or fields are null for table %s (Type: %s). Skipping columns.", - tableId, definition.getType()); + "Schema not found or fields are null for table %s (Type: %s). Skipping columns.", + tableId, definition.getType()); return; } @@ -2269,8 +2266,8 @@ private void processTableColumns( LOG.fine("Finished processing columns for table: " + tableId); } catch (BigQueryException e) { LOG.warning( - "BigQueryException processing table %s: %s (Code: %d)", - tableId, e.getMessage(), e.getCode()); + "BigQueryException processing table %s: %s (Code: %d)", + tableId, e.getMessage(), e.getCode()); } catch (Exception e) { LOG.severe("Unexpected error processing table %s: %s", tableId, e.getMessage()); } @@ -2496,10 +2493,7 @@ public ResultSet getColumnPrivileges( LOG.info( "getColumnPrivileges called for catalog: %s, schema: %s, table: %s, columnNamePattern:" + " %s. BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", - catalog, - schema, - table, - columnNamePattern); + catalog, schema, table, columnNamePattern); final Schema resultSchema = defineGetColumnPrivilegesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2527,9 +2521,7 @@ public ResultSet getTablePrivileges( LOG.info( "getTablePrivileges called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " + "BigQuery IAM model differs from SQL privileges; returning empty ResultSet.", - catalog, - schemaPattern, - tableNamePattern); + catalog, schemaPattern, tableNamePattern); final Schema resultSchema = defineGetTablePrivilegesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2551,11 +2543,7 @@ public ResultSet getBestRowIdentifier( "getBestRowIdentifier called for catalog: %s, schema: %s, table: %s, scope: %d," + " nullable: %s. BigQuery does not support best row identifiers; returning empty" + " ResultSet.", - catalog, - schema, - table, - scope, - nullable); + catalog, schema, table, scope, nullable); final Schema resultSchema = defineGetBestRowIdentifierSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -2605,9 +2593,7 @@ public ResultSet getVersionColumns(String catalog, String schema, String table) LOG.info( "getVersionColumns called for catalog: %s, schema: %s, table: %s. " + "Automatic version columns not supported by BigQuery; returning empty ResultSet.", - catalog, - schema, - table); + catalog, schema, table); final Schema resultSchema = defineGetVersionColumnsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3316,10 +3302,7 @@ public ResultSet getUDTs( LOG.info( "getUDTs called for catalog: %s, schemaPattern: %s, typeNamePattern: %s, types: %s. " + "Feature not supported by BigQuery; returning empty ResultSet.", - catalog, - schemaPattern, - typeNamePattern, - (types == null ? "null" : Arrays.toString(types))); + catalog, schemaPattern, typeNamePattern, (types == null ? "null" : Arrays.toString(types))); final Schema resultSchema = defineGetUDTsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3392,9 +3375,7 @@ public ResultSet getSuperTables(String catalog, String schemaPattern, String tab LOG.info( "getSuperTables called for catalog: %s, schemaPattern: %s, tableNamePattern: %s. " + "BigQuery does not support super tables; returning empty ResultSet.", - catalog, - schemaPattern, - tableNamePattern); + catalog, schemaPattern, tableNamePattern); final Schema resultSchema = defineGetSuperTablesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3431,9 +3412,7 @@ public ResultSet getSuperTypes(String catalog, String schemaPattern, String type LOG.info( "getSuperTypes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s. BigQuery" + " does not support user-defined type hierarchies; returning empty ResultSet.", - catalog, - schemaPattern, - typeNamePattern); + catalog, schemaPattern, typeNamePattern); final Schema resultSchema = defineGetSuperTypesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3480,10 +3459,7 @@ public ResultSet getAttributes( "getAttributes called for catalog: %s, schemaPattern: %s, typeNamePattern: %s," + " attributeNamePattern: %s. Feature not supported by BigQuery; returning empty" + " ResultSet.", - catalog, - schemaPattern, - typeNamePattern, - attributeNamePattern); + catalog, schemaPattern, typeNamePattern, attributeNamePattern); final Schema resultSchema = defineGetAttributesSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -3771,8 +3747,8 @@ void processSchemaInfo( LOG.finer("Processed and added schema info row for: " + datasetId); } catch (Exception e) { LOG.warning( - "Error processing schema info for dataset %s: %s. Skipping this schema.", - datasetId, e.getMessage()); + "Error processing schema info for dataset %s: %s. Skipping this schema.", + datasetId, e.getMessage()); } } @@ -3892,9 +3868,7 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct LOG.info( "getFunctions called for catalog: %s, schemaPattern: %s, functionNamePattern: %s", - catalog, - schemaPattern, - functionNamePattern); + catalog, schemaPattern, functionNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern functionNameRegex = compileSqlLikePattern(functionNamePattern); @@ -3945,8 +3919,8 @@ public ResultSet getFunctions(String catalog, String schemaPattern, String funct Callable> apiCallable = () -> { LOG.fine( - "Fetching all routines for dataset: %s, pattern: %s", - currentDatasetId.getDataset(), functionNamePattern); + "Fetching all routines for dataset: %s, pattern: %s", + currentDatasetId.getDataset(), functionNamePattern); return findMatchingBigQueryObjects( "Routine", () -> @@ -4103,8 +4077,8 @@ void processFunctionInfo( } catch (Exception e) { LOG.warning( - "Error processing function info for %s: %s. Skipping this function.", - routineId, e.getMessage()); + "Error processing function info for %s: %s. Skipping this function.", + routineId, e.getMessage()); } } @@ -4145,10 +4119,7 @@ public ResultSet getFunctionColumns( LOG.info( "getFunctionColumns called for catalog: %s, schemaPattern: %s, functionNamePattern: %s," + " columnNamePattern: %s", - catalog, - schemaPattern, - functionNamePattern, - columnNamePattern); + catalog, schemaPattern, functionNamePattern, columnNamePattern); final Pattern schemaRegex = compileSqlLikePattern(schemaPattern); final Pattern functionNameRegex = compileSqlLikePattern(functionNamePattern); @@ -4695,10 +4666,7 @@ public ResultSet getPseudoColumns( "getPseudoColumns called for catalog: %s, schemaPattern: %s, tableNamePattern: %s," + " columnNamePattern: %s. Pseudo columns not supported by BigQuery; returning" + " empty ResultSet.", - catalog, - schemaPattern, - tableNamePattern, - columnNamePattern); + catalog, schemaPattern, tableNamePattern, columnNamePattern); final Schema resultSchema = defineGetPseudoColumnsSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -4836,8 +4804,7 @@ private Tuple determineEffectiveCatalogAndSchema( effectiveSchemaPattern); } else { LOG.info( - logPrefix - + "Using user catalog '%s' and schema '%s'. Default dataset '%s' ignored.", + logPrefix + "Using user catalog '%s' and schema '%s'. Default dataset '%s' ignored.", effectiveCatalog, effectiveSchemaPattern, defaultSchemaFromConnection); @@ -4904,8 +4871,7 @@ List findMatchingBigQueryObjects( if (needsList) { logger.info( "Listing all %ss (pattern: %s)...", - objectTypeName, - pattern == null ? "" : pattern); + objectTypeName, pattern == null ? "" : pattern); Page firstPage = listAllOperation.get(); objects = firstPage.iterateAll(); logger.fine( @@ -5171,8 +5137,8 @@ private void waitForTasksCompletion(List> taskFutures) { LOG.warning("A table processing task was cancelled."); } catch (ExecutionException e) { LOG.severe( - "Error executing table processing task: %s", - (e.getCause() != null ? e.getCause().getMessage() : e.getMessage())); + "Error executing table processing task: %s", + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage())); } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOG.warning( diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java index ab92d56d0..11199c372 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java @@ -144,27 +144,25 @@ public Connection connect(String url, Properties info) throws SQLException { logPath = BigQueryJdbcUrlUtility.DEFAULT_LOG_PATH; } - BigQueryJdbcRootLogger.setLevel(logLevel); - BigQueryJdbcRootLogger.enableFileLogger(logPath - - ); + BigQueryJdbcRootLogger.setLevel(logLevel, logPath); + // Logging starts from here. BigQueryConnection connection = new BigQueryConnection(connectionUri); LOG.info( - "Driver info : { {Database Product Name : %s}, " - + "{Database Product Version : %s}, " - + "{Driver Name : %s}, " - + "{Driver Version : %s}, " - + "{LogLevel : %s}, " - + "{LogPath : %s}, " - + "{Driver Instance : %s} }", - connection.getMetaData().getDatabaseProductName(), - connection.getMetaData().getDatabaseProductVersion(), - connection.getMetaData().getDriverName(), - connection.getMetaData().getDriverVersion(), - logLevel, - logPath, - this.toString()); + "Driver info : { {Database Product Name : %s}, " + + "{Database Product Version : %s}, " + + "{Driver Name : %s}, " + + "{Driver Version : %s}, " + + "{LogLevel : %s}, " + + "{LogPath : %s}, " + + "{Driver Instance : %s} }", + connection.getMetaData().getDatabaseProductName(), + connection.getMetaData().getDatabaseProductVersion(), + connection.getMetaData().getDriverName(), + connection.getMetaData().getDriverVersion(), + logLevel, + logPath, + this.toString()); return connection; } else { return null; diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java index 019e7e4ca..9412b2fd7 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java @@ -30,31 +30,31 @@ protected BigQueryJdbcCustomLogger(String name, String resourceBundleName) { this.setParent(BigQueryJdbcRootLogger.getRootLogger()); } - void finest(String format, Object... args){ + void finest(String format, Object... args) { this.finest(() -> String.format(format, args)); } - void finer(String format, Object... args){ + void finer(String format, Object... args) { this.finer(() -> String.format(format, args)); } - void fine(String format, Object... args){ + void fine(String format, Object... args) { this.fine(() -> String.format(format, args)); } - void config(String format, Object... args){ + void config(String format, Object... args) { this.config(() -> String.format(format, args)); } - void info(String format, Object... args){ + void info(String format, Object... args) { this.info(() -> String.format(format, args)); } - void warning(String format, Object... args){ + void warning(String format, Object... args) { this.warning(() -> String.format(format, args)); } - void severe(String format, Object... args){ + void severe(String format, Object... args) { this.severe(() -> String.format(format, args)); } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java index f0215a118..dcf31a7ff 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java @@ -507,8 +507,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials( return getCredentialsFromCode(userAuthorizer, code, callerClassName); } catch (IOException | URISyntaxException ex) { LOG.severe( - "Failed to establish connection using User Account authentication: %s", - ex.getMessage()); + "Failed to establish connection using User Account authentication: %s", ex.getMessage()); throw new BigQueryJdbcRuntimeException(ex); } } @@ -593,8 +592,8 @@ private static GoogleCredentials getApplicationDefaultCredentials(String callerC principal = "external account"; } LOG.info( - "Connection established. Auth Method: Application Default Credentials, Principal: %s.", - principal); + "Connection established. Auth Method: Application Default Credentials, Principal: %s.", + principal); return credentials; } catch (IOException exception) { // TODO throw exception diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java index 43044b190..5b90e42c3 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java @@ -601,7 +601,7 @@ static String appendPropertiesToURL(String url, String callerClassName, Properti StringBuilder urlBuilder = new StringBuilder(url); for (Entry entry : properties.entrySet()) { if (entry.getValue() != null && !"".equals(entry.getValue())) { - LOG.info("Appending %s with value %s to URL", entry.getKey(), entry.getValue()); + LOG.finest("Appending %s with value %s to URL", entry.getKey(), entry.getValue()); urlBuilder.append(";").append(entry.getKey()).append("=").append(entry.getValue()); } } @@ -706,8 +706,8 @@ static Integer parseIntProperty( return Integer.parseInt(parsedValue); } catch (NumberFormatException e) { LOG.severe( - "Invalid integer value '%s' for property '%s'. Please provide a valid integer.", - parsedValue, propertyName); + "Invalid integer value '%s' for property '%s'. Please provide a valid integer.", + parsedValue, propertyName); throw new IllegalArgumentException( String.format("Invalid integer value for property '%s': %s", propertyName, parsedValue), e); @@ -757,8 +757,7 @@ public static Level parseLogLevel(String logLevelString) { return Level.SEVERE; case 0: default: - LOG.info( - "%s value not provided, defaulting to %s.", LOG_LEVEL_PROPERTY_NAME, Level.OFF); + LOG.info("%s value not provided, defaulting to %s.", LOG_LEVEL_PROPERTY_NAME, Level.OFF); return Level.OFF; } } @@ -796,8 +795,8 @@ public static boolean parseJobCreationMode(String url, String callerClassName) { if (jobCreationMode == null) { LOG.fine( - "%s value not provided, defaulting to %s. Caller: %s", - JOB_CREATION_MODE_PROPERTY_NAME, DEFAULT_JOB_CREATION_MODE, callerClassName); + "%s value not provided, defaulting to %s. Caller: %s", + JOB_CREATION_MODE_PROPERTY_NAME, DEFAULT_JOB_CREATION_MODE, callerClassName); // Default Job creation mode is JOB_CREATION_OPTIONAL(2) // which translates to options.setQueryPreviewEnabled(true) return true; @@ -906,8 +905,8 @@ private static Map parsePropertiesMap( propertiesMap.put(parts[0], parts[1]); } else { LOG.warning( - "Invalid KeyValue pair: %s found in url: %s for property name: %s", - keyValuePair, url, propertyName); + "Invalid KeyValue pair: %s found in url: %s for property name: %s", + keyValuePair, url, propertyName); } } return propertiesMap; diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java index 63bf6ffff..5dbf731a0 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java @@ -59,9 +59,9 @@ QueryJobConfiguration.Builder configureParameters( Object parameterValue = getParameter(i); StandardSQLTypeName sqlType = getSqlType(i); - LOG.info( - "Parameter %s of type %s at index %s added to QueryJobConfiguration", - parameterValue, sqlType, i); + LOG.finest( + "Parameter %s of type %s at index %s added to QueryJobConfiguration", + parameterValue, sqlType, i); jobConfigurationBuilder.addPositionalParameter( QueryParameterValue.of(parameterValue, sqlType)); } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java index a311abc48..abead84b7 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java @@ -404,8 +404,8 @@ private void setInsertMetadata(QueryStatistics statistics) throws SQLException { this.insertTableName = TableName.of(tableID.getProject(), tableID.getDataset(), tableID.getTable()); LOG.finest( - "this.insertTableName : %s, this.insertSchema : %s", - this.insertTableName, this.insertSchema.toString()); + "this.insertTableName : %s, this.insertSchema : %s", + this.insertTableName, this.insertSchema.toString()); } QueryJobConfiguration getWriteBatchJobConfiguration( @@ -432,8 +432,8 @@ QueryJobConfiguration getStandardBatchJobConfiguration(String query) throws SQLE Object parameterValue = parameter.getValue(); StandardSQLTypeName sqlType = parameter.getSqlType(); LOG.finest( - "Parameter %s of type %s at index %s added to QueryJobConfiguration", - parameterValue, sqlType, index++); + "Parameter %s of type %s at index %s added to QueryJobConfiguration", + parameterValue, sqlType, index++); jobConfiguration.addPositionalParameter(QueryParameterValue.of(parameterValue, sqlType)); } } diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java index 655a6f3c5..3fb2c2d58 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java @@ -325,8 +325,8 @@ SqlType getQueryType(QueryJobConfiguration jobConfiguration, StatementType state SqlType sqlType = BigQuerySqlTypeConverter.getSqlTypeFromStatementType(statementType); LOG.fine( - "Query: %s, Statement Type: %s, SQL Type: %s", - jobConfiguration.getQuery(), statementType, sqlType); + "Query: %s, Statement Type: %s, SQL Type: %s", + jobConfiguration.getQuery(), statementType, sqlType); return sqlType; } @@ -854,8 +854,8 @@ Thread populateArrowBufferedQueue( /** Executes SQL query using either fast query path or read API */ void processQueryResponse(String query, TableResult results) throws SQLException { LOG.finest( - "API call completed{Query=%s, Parent Job ID=%s, Total rows=%s} ", - query, results.getJobId(), results.getTotalRows()); + "API call completed{Query=%s, Parent Job ID=%s, Total rows=%s} ", + query, results.getJobId(), results.getTotalRows()); JobId currentJobId = results.getJobId(); if (currentJobId == null) { LOG.fine("Standard API with Stateless query used."); @@ -1022,9 +1022,9 @@ Thread runNextPageTaskAsync( // thread rpcResponseQueue.put(Tuple.of(results, true)); LOG.fine( - "Fetched %d results from the server in %d ms.", - querySettings.getMaxResultPerPage(), - (int) ((System.nanoTime() - startTime) / 1000000)); + "Fetched %d results from the server in %d ms.", + querySettings.getMaxResultPerPage(), + (int) ((System.nanoTime() - startTime) / 1000000)); } // this will stop the parseDataTask as well when the pagination // completes @@ -1097,8 +1097,8 @@ Thread parseAndPopulateRpcDataAsync( } } LOG.fine( - "Processed %d results in %d ms.", - results, (int) ((System.nanoTime() - startTime) / 1000000)); + "Processed %d results in %d ms.", + results, (int) ((System.nanoTime() - startTime) / 1000000)); } try { // All the pages has been processed, put this marker diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java index 524a82bc9..9f3b21044 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java @@ -118,7 +118,7 @@ public void connectionErrorOccurred(ConnectionEvent event) { (event.getSQLException() != null) ? event.getSQLException().getMessage() : "Connection error occured"; - LOG.finest("Removed pooled connection from connection pool dor: %s", errorMessage); + LOG.finest("Removed pooled connection from connection pool. Error: %s", errorMessage); } @Override From 819fe08e5c2399a5f4683b5acbecd530d3baa088 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Fri, 6 Feb 2026 05:58:52 +0000 Subject: [PATCH 3/3] Add missing logger entries --- .../jdbc/BigQueryDatabaseMetaData.java | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java index 1ef88a29d..75c455907 100644 --- a/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java +++ b/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java @@ -1246,9 +1246,8 @@ List listMatchingProcedureIdsFromDatasets( throws InterruptedException { logger.fine( - String.format( - "Listing matching procedure IDs from %d datasets for catalog '%s'.", - datasetsToScan.size(), catalogParam)); + "Listing matching procedure IDs from %d datasets for catalog '%s'.", + datasetsToScan.size(), catalogParam); final List>> listRoutineFutures = new ArrayList<>(); final List procedureIdsToGet = Collections.synchronizedList(new ArrayList<>()); @@ -1314,9 +1313,8 @@ List listMatchingProcedureIdsFromDatasets( } } logger.info( - String.format( - "Found %d procedure IDs to fetch details for in catalog '%s'.", - procedureIdsToGet.size(), catalogParam)); + "Found %d procedure IDs to fetch details for in catalog '%s'.", + procedureIdsToGet.size(), catalogParam); return procedureIdsToGet; } @@ -1325,8 +1323,7 @@ List fetchFullRoutineDetailsForIds( ExecutorService getRoutineDetailsExecutor, BigQueryJdbcCustomLogger logger) throws InterruptedException { - logger.fine( - String.format("Fetching full details for %d procedure IDs.", procedureIdsToGet.size())); + logger.fine("Fetching full details for %d procedure IDs.", procedureIdsToGet.size()); final List> getRoutineFutures = new ArrayList<>(); final List fullRoutines = Collections.synchronizedList(new ArrayList<>()); @@ -1370,8 +1367,7 @@ List fetchFullRoutineDetailsForIds( logger.warning("getRoutine detail task cancelled."); } } - logger.info( - String.format("Successfully fetched full details for %d routines.", fullRoutines.size())); + logger.info("Successfully fetched full details for %d routines.", fullRoutines.size()); return fullRoutines; } @@ -1384,8 +1380,7 @@ void submitProcedureArgumentProcessingJobs( List> outArgumentProcessingFutures, BigQueryJdbcCustomLogger logger) throws InterruptedException { - logger.fine( - String.format("Submitting argument processing jobs for %d routines.", fullRoutines.size())); + logger.fine("Submitting argument processing jobs for %d routines.", fullRoutines.size()); for (Routine fullRoutine : fullRoutines) { if (Thread.currentThread().isInterrupted()) { @@ -3168,10 +3163,9 @@ Comparator defineGetTypeInfoComparator(FieldList schemaFields) { public ResultSet getIndexInfo( String catalog, String schema, String table, boolean unique, boolean approximate) { LOG.info( - String.format( - "getIndexInfo called for catalog: %s, schema: %s, table: %s, unique: %s, approximate:" - + " %s. Traditional indexes not supported by BigQuery; returning empty ResultSet.", - catalog, schema, table, unique, approximate)); + "getIndexInfo called for catalog: %s, schema: %s, table: %s, unique: %s, approximate:" + + " %s. Traditional indexes not supported by BigQuery; returning empty ResultSet.", + catalog, schema, table, unique, approximate); final Schema resultSchema = defineGetIndexInfoSchema(); final FieldList resultSchemaFields = resultSchema.getFields(); @@ -4346,9 +4340,8 @@ List listMatchingFunctionIdsFromDatasets( throws InterruptedException { logger.fine( - String.format( - "Listing matching function IDs from %d datasets for catalog '%s'.", - datasetsToScan.size(), catalogParam)); + "Listing matching function IDs from %d datasets for catalog '%s'.", + datasetsToScan.size(), catalogParam); final List>> listRoutineFutures = new ArrayList<>(); final List functionIdsToGet = Collections.synchronizedList(new ArrayList<>()); @@ -4420,9 +4413,8 @@ List listMatchingFunctionIdsFromDatasets( } } logger.info( - String.format( - "Found %d function IDs to fetch details for in catalog '%s'.", - functionIdsToGet.size(), catalogParam)); + "Found %d function IDs to fetch details for in catalog '%s'.", + functionIdsToGet.size(), catalogParam); return functionIdsToGet; } @@ -4435,9 +4427,7 @@ void submitFunctionParameterProcessingJobs( List> outParameterProcessingFutures, BigQueryJdbcCustomLogger logger) throws InterruptedException { - logger.fine( - String.format( - "Submitting parameter processing jobs for %d functions.", fullFunctions.size())); + logger.fine("Submitting parameter processing jobs for %d functions.", fullFunctions.size()); for (Routine fullFunction : fullFunctions) { if (Thread.currentThread().isInterrupted()) { @@ -4875,8 +4865,7 @@ List findMatchingBigQueryObjects( Page firstPage = listAllOperation.get(); objects = firstPage.iterateAll(); logger.fine( - String.format( - "Retrieved initial %s list, iterating & filtering if needed...", objectTypeName)); + "Retrieved initial %s list, iterating & filtering if needed...", objectTypeName); } else { logger.info("Getting specific %s: '%s'", objectTypeName, pattern); @@ -4914,18 +4903,16 @@ List findMatchingBigQueryObjects( logger.info("%s '%s' not found (API error 404).", objectTypeName, pattern); } else { logger.warning( - String.format( - "BigQueryException finding %ss for pattern '%s': %s (Code: %d)", - objectTypeName, pattern, e.getMessage(), e.getCode())); + "BigQueryException finding %ss for pattern '%s': %s (Code: %d)", + objectTypeName, pattern, e.getMessage(), e.getCode()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.warning("Interrupted while finding " + objectTypeName + "s."); } catch (Exception e) { logger.severe( - String.format( - "Unexpected exception finding %ss for pattern '%s': %s", - objectTypeName, pattern, e.getMessage())); + "Unexpected exception finding %ss for pattern '%s': %s", + objectTypeName, pattern, e.getMessage()); } return resultList; } @@ -5004,8 +4991,7 @@ void sortResults( collectedResults.sort(comparator); logger.info("%s result sorting completed.", operationName); } catch (Exception e) { - logger.severe( - String.format("Error during sorting %s results: %s", operationName, e.getMessage())); + logger.severe("Error during sorting %s results: %s", operationName, e.getMessage()); } }