Skip to content

Commit

Permalink
Merge pull request #37 from georchestra/reduce_log_bloating_from_cust…
Browse files Browse the repository at this point in the history
…om_pg_dialect

Reduce log bloating from SchemaUnawarePostGISDialect
  • Loading branch information
groldan authored Jun 19, 2024
2 parents 09ea686 + 3247086 commit 40f4a1c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Level;

import javax.sql.DataSource;

import org.geotools.api.data.DataStore;
import org.geotools.data.postgis.PostGISDialect;
import org.geotools.data.postgis.PostGISPSDialect;
import org.geotools.data.postgis.PostgisNGDataStoreFactory;
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.SQLDialect;
Expand Down Expand Up @@ -50,7 +50,7 @@ CollectionRepository postgisDataStoreCollectionRepository(DataStoreProvider dsPr
@DependsOn("databaseStartupValidator")
DataStoreProvider postgisDataStore(DataSource dataSource, @Value("${postgres.schema:#{null}}") String schema)
throws IOException {
Map<String, Object> params = new HashMap<String, Object>(Map.of(//
Map<String, Object> params = new HashMap<>(Map.of(//
PostgisNGDataStoreFactory.DBTYPE.key, "post gis", //
PostgisNGDataStoreFactory.DATASOURCE.key, dataSource, //
PostgisNGDataStoreFactory.PREPARED_STATEMENTS.key, true, //
Expand Down Expand Up @@ -134,8 +134,12 @@ public Integer getGeometrySRID(String schemaName, String tableName, String colum
srid = result.getInt(1);
}
} catch (SQLException e) {
LOGGER.log(Level.WARNING, "Failed to retrieve information about " + tableName + "." + columnName
+ " from the geometry_columns table, checking the first geometry instead", e);
String origMessage = Optional.ofNullable(e.getMessage()).orElse("").replaceAll("\\R", " ");
LOGGER.log(Level.WARNING, ()->
"""
Failed to retrieve information about %s.%s (%s) \
from the geometry_columns table, checking the first geometry instead
""".formatted(tableName, columnName, origMessage));
}
}
return srid;
Expand Down

0 comments on commit 40f4a1c

Please sign in to comment.