diff --git a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java index 7a510527fa394..2b31c759ca434 100644 --- a/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java +++ b/bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcMapper.java @@ -27,6 +27,7 @@ import org.knowm.yank.Yank; import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.items.Item; +import org.openhab.core.items.ItemUtil; import org.openhab.core.persistence.FilterCriteria; import org.openhab.core.persistence.HistoricItem; import org.openhab.core.persistence.PersistenceItemInfo; @@ -340,6 +341,11 @@ public void populateItemNameToTableNameMap() throws JdbcSQLException { } } else { for (ItemsVO vo : getItemIDTableNames()) { + String itemName = vo.getItemName(); + if (!ItemUtil.isValidItemName(itemName)) { + logger.warn("Skipping invalid item name {}", itemName); + continue; + } itemNameToTableNameMap.put(vo.getItemName(), namingStrategy.getTableName(vo.getItemId(), vo.getItemName())); } @@ -429,6 +435,10 @@ private void formatTableNames() throws JdbcSQLException { } oldNewTableNames = new ArrayList<>(); for (String itemName : itemTables) { + if (!ItemUtil.isValidItemName(itemName)) { + logger.warn("JDBC::formatTableNames: Skipping invalid item name {}", itemName); + continue; + } ItemsVO isvo = new ItemsVO(); isvo.setItemName(itemName); isvo.setItemsManageTable(conf.getItemsManageTable());