if (dataColumn.getConstraint() instanceof DataColumnConstraint.Enum) {
DataColumnConstraint.Enum dcc = (DataColumnConstraint.Enum) dataColumn.getConstraint();
EnumMapper mapper = new EnumMapper();
for (Map.Entry<String, String> entry : dcc.getValues().entrySet()) {
mapper.addMapping(Integer.valueOf(entry.getKey()), entry.getValue());
}
if (dataColumn.getMimeType() == null) {
att.getUserData().put(JDBCDataStore.JDBC_ENUM_MAP, mapper);
} else {
att.getUserData().put(GPKG_ARRAY_ENUM_MAP, mapper);
}
}
While the data column entrySet could have a string key for the mapping, the created EnumMapper cannot, since the key type is Integer, hence an exception is thrown, preventing the GeoPackage to be loaded.
This bug causes GeoServer to crash whenever a layer is loaded from a GeoPackage that has data column constraints enums mapped by string keys.
The problem lies in how GeoTools manages the data columns constraint values in case of a enum:
if (dataColumn.getConstraint() instanceof DataColumnConstraint.Enum) { DataColumnConstraint.Enum dcc = (DataColumnConstraint.Enum) dataColumn.getConstraint(); EnumMapper mapper = new EnumMapper(); for (Map.Entry<String, String> entry : dcc.getValues().entrySet()) { mapper.addMapping(Integer.valueOf(entry.getKey()), entry.getValue()); } if (dataColumn.getMimeType() == null) { att.getUserData().put(JDBCDataStore.JDBC_ENUM_MAP, mapper); } else { att.getUserData().put(GPKG_ARRAY_ENUM_MAP, mapper); } }
While the data column
entrySet
could have a string key for the mapping, the createdEnumMapper
cannot, since the key type isInteger
, hence an exception is thrown, preventing the GeoPackage to be loaded.