GeoPackage data column constraint enums with string keys are not supported

Description

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 created EnumMapper cannot, since the key type is Integer, hence an exception is thrown, preventing the GeoPackage to be loaded.

Environment

None

Activity

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created February 6, 2025 at 10:58 AM
Updated May 12, 2025 at 8:28 AM
Resolved May 12, 2025 at 8:28 AM