diff --git a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/CatalogInfoRowMapper.java b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/CatalogInfoRowMapper.java index 229bf219a..a5c33866a 100644 --- a/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/CatalogInfoRowMapper.java +++ b/src/catalog/backends/pgconfig/src/main/java/org/geoserver/cloud/backend/pgconfig/catalog/repository/CatalogInfoRowMapper.java @@ -182,7 +182,7 @@ protected StyleInfo loadStyle(ResultSet rs, String columnName) { } catch (SQLException e) { throw UncheckedSqlException.of(e); } - WorkspaceInfo workspace = style.getWorkspace(); + WorkspaceInfo workspace = null == style ? null : style.getWorkspace(); if (null != workspace) { String wsid = workspace.getId(); WorkspaceInfo ws = mapWorkspace(wsid, rs); @@ -224,9 +224,11 @@ protected StoreInfo mapStore(ResultSet rs) { } catch (SQLException e) { throw UncheckedSqlException.of(e); } - String wsid = store.getWorkspace().getId(); - WorkspaceInfo ws = mapWorkspace(wsid, rs); - store.setWorkspace(ModificationProxy.create(ws, WorkspaceInfo.class)); + if (null != store) { + String wsid = store.getWorkspace().getId(); + WorkspaceInfo ws = mapWorkspace(wsid, rs); + store.setWorkspace(ModificationProxy.create(ws, WorkspaceInfo.class)); + } return store; } @@ -261,8 +263,10 @@ public ResourceInfo mapResource(ResultSet rs) { } catch (SQLException e) { throw UncheckedSqlException.of(e); } - setStore(resource, rs); - setNamespace(rs, resource); + if (null != resource) { + setStore(resource, rs); + setNamespace(rs, resource); + } return resource; } @@ -360,9 +364,11 @@ protected LayerInfo mapLayer(ResultSet rs) { } catch (SQLException e) { throw UncheckedSqlException.of(e); } - setResource(layer, rs); - setDefaultStyle(layer, rs); - setStyles(layer); + if (null != layer) { + setResource(layer, rs); + setDefaultStyle(layer, rs); + setStyles(layer); + } return layer; } @@ -412,11 +418,13 @@ protected LayerGroupInfo mapLayerGroup(ResultSet rs) { } catch (SQLException e) { throw UncheckedSqlException.of(e); } - WorkspaceInfo workspace = layergroup.getWorkspace(); - if (null != workspace) { - String wsid = workspace.getId(); - WorkspaceInfo ws = mapWorkspace(wsid, rs); - layergroup.setWorkspace(ModificationProxy.create(ws, WorkspaceInfo.class)); + if (null != layergroup) { + WorkspaceInfo workspace = layergroup.getWorkspace(); + if (null != workspace) { + String wsid = workspace.getId(); + WorkspaceInfo ws = mapWorkspace(wsid, rs); + layergroup.setWorkspace(ModificationProxy.create(ws, WorkspaceInfo.class)); + } } return layergroup; } diff --git a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventBridge.java b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventBridge.java index a6b055b89..1a4092c03 100644 --- a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventBridge.java +++ b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventBridge.java @@ -13,7 +13,6 @@ import org.geoserver.catalog.impl.ResolvingProxy; import org.geoserver.cloud.event.GeoServerEvent; import org.geoserver.cloud.event.info.InfoEvent; -import org.geoserver.platform.config.UpdateSequence; import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.EventListener; @@ -59,8 +58,7 @@ public class RemoteGeoServerEventBridge implements DisposableBean { public RemoteGeoServerEventBridge( // @NonNull Consumer localRemoteEventPublisher, // @NonNull Consumer remoteEventPublisher, // - @NonNull RemoteGeoServerEventMapper mapper, - @NonNull UpdateSequence updateSequence) { + @NonNull RemoteGeoServerEventMapper mapper) { this.mapper = mapper; this.outboundEventPublisher = remoteEventPublisher; diff --git a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventsConfiguration.java b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventsConfiguration.java index 2f89501e8..42d7efce3 100644 --- a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventsConfiguration.java +++ b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEventsConfiguration.java @@ -14,7 +14,6 @@ import org.geoserver.config.GeoServer; import org.geoserver.jackson.databind.catalog.GeoServerCatalogModule; import org.geoserver.jackson.databind.config.GeoServerConfigModule; -import org.geoserver.platform.config.UpdateSequence; import org.geotools.api.filter.Filter; import org.geotools.api.filter.expression.Expression; import org.geotools.api.filter.expression.Literal; @@ -94,15 +93,13 @@ RemoteGeoServerEventMapper remoteGeoServerEventMapper( @Bean RemoteGeoServerEventBridge remoteEventBroadcaster( - ApplicationEventPublisher eventPublisher, - RemoteGeoServerEventMapper eventMapper, - UpdateSequence updateSequence) { + ApplicationEventPublisher eventPublisher, RemoteGeoServerEventMapper eventMapper) { log.info("Configuring GeoServer Catalog distributed events."); Consumer localEventPublisher = eventPublisher::publishEvent; Consumer remoteEventPublisher = eventPublisher::publishEvent; return new RemoteGeoServerEventBridge( - localEventPublisher, remoteEventPublisher, eventMapper, updateSequence); + localEventPublisher, remoteEventPublisher, eventMapper); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/UpdateSequenceEvent.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/UpdateSequenceEvent.java index 13a6aba97..b39d3adba 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/UpdateSequenceEvent.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/UpdateSequenceEvent.java @@ -54,6 +54,7 @@ public static UpdateSequenceEvent createLocal(long value) { return new UpdateSequenceEvent(value); } + @SuppressWarnings("java:S1210") @Override public int compareTo(UpdateSequenceEvent o) { return Long.compare(getUpdateSequence(), o.getUpdateSequence()); diff --git a/src/catalog/jackson-bindings/geotools/src/main/java/org/geotools/jackson/databind/filter/mapper/GeoToolsValueMappers.java b/src/catalog/jackson-bindings/geotools/src/main/java/org/geotools/jackson/databind/filter/mapper/GeoToolsValueMappers.java index 6ae6792cc..7eeeda744 100644 --- a/src/catalog/jackson-bindings/geotools/src/main/java/org/geotools/jackson/databind/filter/mapper/GeoToolsValueMappers.java +++ b/src/catalog/jackson-bindings/geotools/src/main/java/org/geotools/jackson/databind/filter/mapper/GeoToolsValueMappers.java @@ -222,7 +222,7 @@ public Locale stringToLocale(String s) { public Map internationalStringToDto(InternationalString s) { if (s instanceof GrowableInternationalString gs) { Set locales = gs.getLocales(); - Map dto = new HashMap<>(locales.size()); + Map dto = HashMap.newHashMap(locales.size()); locales.forEach(locale -> dto.put(localeToString(locale), gs.toString(locale))); return dto; } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoRepositoryHolderImpl.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoRepositoryHolderImpl.java index d067fba0a..cb4e38a3f 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoRepositoryHolderImpl.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoRepositoryHolderImpl.java @@ -50,7 +50,7 @@ public > R repositoryF return (R) repos.forObject(info); } - public List> all() { + public List> all() { return repos.getAll(); }