This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit d058d30f2e8d4813c37cc5cde676ca5161455df1 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Thu Sep 9 16:41:03 2021 +0200 Fix a NullPointerException occurring when a table has no primary key. --- .../org/apache/sis/internal/sql/feature/FeatureAdapter.java | 10 +++++++--- .../main/java/org/apache/sis/internal/sql/feature/Table.java | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureAdapter.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureAdapter.java index eb69948..dd37af9 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureAdapter.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureAdapter.java @@ -157,9 +157,13 @@ final class FeatureAdapter { final List<Relation> following, final Relation noFollow) throws SQLException, InternalDataStoreException { - this.featureType = table.featureType; - this.attributes = table.attributes; - keyComponentClass = table.primaryKey.valueClass.getComponentType(); + this.featureType = table.featureType; + this.attributes = table.attributes; + if (table.primaryKey != null) { + keyComponentClass = table.primaryKey.valueClass.getComponentType(); + } else { + keyComponentClass = null; + } final Map<String,Integer> columnIndices = new HashMap<>(); /* * Create a SELECT clause with all columns that are ordinary attributes. diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java index 9fcc318..9ae1b69 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java @@ -213,7 +213,9 @@ final class Table extends AbstractFeatureSet { case EXPORT: referenced = this.primaryKey; break; default: throw new AssertionError(direction); } - relation.setSearchTable(analyzer, table, referenced, direction); + if (referenced != null) { + relation.setSearchTable(analyzer, table, referenced, direction); + } } } }