diff --git a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java index f0b3649fd..d6977a807 100644 --- a/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java +++ b/src/catalog/backends/common/src/main/java/org/geoserver/cloud/security/CloudGeoServerSecurityManager.java @@ -146,13 +146,14 @@ public void fireRemoteChangedEvent(@NonNull String reason) { } /** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */ - public @Override void saveSecurityConfig(SecurityManagerConfig config) throws Exception { + public @Override synchronized void saveSecurityConfig(SecurityManagerConfig config) + throws Exception { super.saveSecurityConfig(config); fireRemoteChangedEvent("SecurityManagerConfig changed"); } /** Override to {@link #fireChanged fire} a remote {@link SecurityConfigChanged} */ - public @Override void saveMasterPasswordConfig( + public @Override synchronized void saveMasterPasswordConfig( MasterPasswordConfig config, char[] currPasswd, char[] newPasswd, diff --git a/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/catalog/repository/UncheckedSqlException.java b/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/catalog/repository/UncheckedSqlException.java index 4d9afa0d2..2d820ea9b 100644 --- a/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/catalog/repository/UncheckedSqlException.java +++ b/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/catalog/repository/UncheckedSqlException.java @@ -16,7 +16,7 @@ class UncheckedSqlException extends RuntimeException { super(cause); } - public @Override SQLException getCause() { + public @Override synchronized SQLException getCause() { return (SQLException) super.getCause(); } diff --git a/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/resource/PgsqlResourceStore.java b/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/resource/PgsqlResourceStore.java index 99811e3e8..34820d88a 100644 --- a/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/resource/PgsqlResourceStore.java +++ b/src/catalog/backends/pgsql/src/main/java/org/geoserver/cloud/backend/pgsql/resource/PgsqlResourceStore.java @@ -150,9 +150,13 @@ public long save(@NonNull PgsqlResource resource, byte[] contents) { } public long getLastmodified(long resourceId) { - return template.queryForObject( - "SELECT mtime FROM resourcestore WHERE id = ?", Timestamp.class, resourceId) - .getTime(); + Long mtime = + template.queryForObject( + "SELECT mtime FROM resourcestore WHERE id = ?", + Timestamp.class, + resourceId) + .getTime(); + return null == mtime ? 0L : mtime.longValue(); } @Override diff --git a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java index f21602fac..ca75d9687 100644 --- a/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java +++ b/src/catalog/event-bus/src/main/java/org/geoserver/cloud/event/bus/RemoteGeoServerEvent.java @@ -17,7 +17,7 @@ public class RemoteGeoServerEvent extends RemoteApplicationEvent { private static final long serialVersionUID = 1L; - private @Getter @NonNull GeoServerEvent event; + private @Getter GeoServerEvent event; /** Deserialization-time constructor, {@link #getSource()} will be {@code null} */ protected RemoteGeoServerEvent() { @@ -26,7 +26,10 @@ protected RemoteGeoServerEvent() { /** Publish-time constructor, {@link #getSource()} won't be {@code null} */ public RemoteGeoServerEvent( - Object source, GeoServerEvent event, String originService, Destination destination) { + Object source, + @NonNull GeoServerEvent event, + @NonNull String originService, + @NonNull Destination destination) { super(source, originService, destination); this.event = event; } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventPublisher.java b/src/catalog/events/src/main/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventPublisher.java index 0dc3ae6cd..f6a6bfd6f 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventPublisher.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/config/catalog/events/CatalogApplicationEventPublisher.java @@ -43,6 +43,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; import java.util.function.Consumer; import java.util.function.Supplier; @@ -191,8 +192,8 @@ private void preparePreModify( push(id, patch); } - private void publishPostModify(@NonNull String id, Info info) { - Patch patch = pop(id); + private void publishPostModify(@NonNull String id, @NonNull Info info) { + Patch patch = Objects.requireNonNull(pop(id)); publish(ConfigInfoModified.createLocal(incrementSequence(), info, patch)); } 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 7c78a49d7..4c0961f45 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 @@ -9,7 +9,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import lombok.Getter; -import lombok.NonNull; import org.geoserver.cloud.event.info.InfoEvent; import org.geoserver.cloud.event.security.SecurityConfigChanged; @@ -30,11 +29,11 @@ public class UpdateSequenceEvent extends GeoServerEvent { * sequence}. Being the most frequently updated property, it's readily available for remote * listeners even when the {@link #getPatch() patch} is not sent over the wire. */ - private @Getter @NonNull Long updateSequence; + private @Getter long updateSequence; protected UpdateSequenceEvent() {} - protected UpdateSequenceEvent(@NonNull Long updateSequence) { + protected UpdateSequenceEvent(long updateSequence) { super(System.currentTimeMillis(), resolveAuthor()); this.updateSequence = updateSequence; } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoAdded.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoAdded.java index e5c40c8ac..26ae8d6a6 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoAdded.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoAdded.java @@ -19,12 +19,12 @@ public class CatalogInfoAdded extends InfoAdded { protected CatalogInfoAdded() {} - CatalogInfoAdded(@NonNull Long updateSequence, @NonNull CatalogInfo object) { + CatalogInfoAdded(long updateSequence, @NonNull CatalogInfo object) { super(updateSequence, object); } public static CatalogInfoAdded createLocal( - @NonNull Long updateSequence, @NonNull CatalogAddEvent event) { + long updateSequence, @NonNull CatalogAddEvent event) { return new CatalogInfoAdded(updateSequence, event.getSource()); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoModified.java index 8be902692..ae73f3aac 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/catalog/CatalogInfoModified.java @@ -35,7 +35,7 @@ public class CatalogInfoModified extends InfoModified ConfigInfoAdded createLocal( - @NonNull Long updateSequence, @NonNull I info) { + long updateSequence, @NonNull I info) { final ConfigInfoType type = ConfigInfoType.valueOf(info); switch (type) { diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoModified.java index 1e73cef63..da9ba9c60 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoModified.java @@ -33,7 +33,7 @@ protected ConfigInfoModified() { } protected ConfigInfoModified( - @NonNull Long updateSequence, + long updateSequence, @NonNull String objectId, @NonNull ConfigInfoType objectType, @NonNull Patch patch) { @@ -42,7 +42,7 @@ protected ConfigInfoModified( @SuppressWarnings("unchecked") public static @NonNull ConfigInfoModified createLocal( - @NonNull Long updateSequence, @NonNull Info info, @NonNull Patch patch) { + long updateSequence, @NonNull Info info, @NonNull Patch patch) { final ConfigInfoType type = ConfigInfoType.valueOf(info); switch (type) { diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoRemoved.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoRemoved.java index f3b6713af..9930c2bd3 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoRemoved.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ConfigInfoRemoved.java @@ -28,13 +28,13 @@ protected ConfigInfoRemoved() { } public ConfigInfoRemoved( - @NonNull Long updateSequence, @NonNull String objectId, @NonNull ConfigInfoType type) { + long updateSequence, @NonNull String objectId, @NonNull ConfigInfoType type) { super(updateSequence, objectId, type); } @SuppressWarnings("unchecked") public static @NonNull ConfigInfoRemoved createLocal( - @NonNull Long updateSequence, @NonNull I info) { + long updateSequence, @NonNull I info) { final ConfigInfoType type = ConfigInfoType.valueOf(info); switch (type) { diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoModified.java index 958409199..7daac73cc 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoModified.java @@ -24,13 +24,12 @@ protected GeoServerInfoModified() { // default constructor, needed for deserialization } - protected GeoServerInfoModified( - @NonNull Long updateSequence, @NonNull String id, @NonNull Patch patch) { + protected GeoServerInfoModified(long updateSequence, @NonNull String id, @NonNull Patch patch) { super(updateSequence, id, ConfigInfoType.GeoServerInfo, patch); } public static GeoServerInfoModified createLocal( - @NonNull Long updateSequence, GeoServerInfo info, @NonNull Patch patch) { + long updateSequence, GeoServerInfo info, @NonNull Patch patch) { final String id = resolveId(info); return new GeoServerInfoModified(updateSequence, id, patch); diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoSet.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoSet.java index 2e7b60c6d..b83dc3927 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoSet.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/GeoServerInfoSet.java @@ -7,8 +7,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import lombok.NonNull; - import org.geoserver.config.GeoServer; import org.geoserver.config.GeoServerInfo; @@ -22,11 +20,11 @@ protected GeoServerInfoSet() { // default constructor, needed for deserialization } - protected GeoServerInfoSet(@NonNull Long updateSequence, GeoServerInfo object) { + protected GeoServerInfoSet(long updateSequence, GeoServerInfo object) { super(updateSequence, object); } - public static GeoServerInfoSet createLocal(@NonNull Long updateSequence, GeoServerInfo value) { + public static GeoServerInfoSet createLocal(long updateSequence, GeoServerInfo value) { return new GeoServerInfoSet(updateSequence, value); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoModified.java index 4c6c4a01f..20ffc547a 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoModified.java @@ -24,14 +24,13 @@ protected LoggingInfoModified() { // default constructor, needed for deserialization } - protected LoggingInfoModified( - @NonNull Long updateSequence, @NonNull String id, @NonNull Patch patch) { + protected LoggingInfoModified(long updateSequence, @NonNull String id, @NonNull Patch patch) { super(updateSequence, id, ConfigInfoType.LoggingInfo, patch); } public static LoggingInfoModified createLocal( - @NonNull Long updateSequence, LoggingInfo info, @NonNull Patch patch) { + long updateSequence, LoggingInfo info, @NonNull Patch patch) { String id = resolveId(info); return new LoggingInfoModified(updateSequence, id, patch); } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoSet.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoSet.java index 8cd5bdecb..a020e9bc9 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoSet.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/LoggingInfoSet.java @@ -7,8 +7,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import lombok.NonNull; - import org.geoserver.config.GeoServer; import org.geoserver.config.LoggingInfo; @@ -22,11 +20,11 @@ protected LoggingInfoSet() { // default constructor, needed for deserialization } - protected LoggingInfoSet(@NonNull Long updateSequence, LoggingInfo object) { + protected LoggingInfoSet(long updateSequence, LoggingInfo object) { super(updateSequence, object); } - public static LoggingInfoSet createLocal(@NonNull Long updateSequence, LoggingInfo value) { + public static LoggingInfoSet createLocal(long updateSequence, LoggingInfo value) { return new LoggingInfoSet(updateSequence, value); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceAdded.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceAdded.java index 9b23b0e42..f812e53a2 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceAdded.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceAdded.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import lombok.EqualsAndHashCode; -import lombok.NonNull; import org.geoserver.config.GeoServer; import org.geoserver.config.ServiceInfo; @@ -24,11 +23,11 @@ protected ServiceAdded() { // default constructor, needed for deserialization } - protected ServiceAdded(@NonNull Long updateSequence, ServiceInfo object) { + protected ServiceAdded(long updateSequence, ServiceInfo object) { super(updateSequence, object); } - public static ServiceAdded createLocal(@NonNull Long updateSequence, ServiceInfo value) { + public static ServiceAdded createLocal(long updateSequence, ServiceInfo value) { return new ServiceAdded(updateSequence, value); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceModified.java index b9acf322f..b74e49c80 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceModified.java @@ -31,7 +31,7 @@ protected ServiceModified() { } protected ServiceModified( - @NonNull Long updateSequence, + long updateSequence, @NonNull String objectId, @NonNull Patch patch, String workspaceId) { @@ -45,7 +45,7 @@ protected ServiceModified( } public static ServiceModified createLocal( - @NonNull Long updateSequence, @NonNull ServiceInfo object, @NonNull Patch patch) { + long updateSequence, @NonNull ServiceInfo object, @NonNull Patch patch) { final @NonNull String serviceId = InfoEvent.resolveId(object); final String workspaceId = InfoEvent.resolveId(object.getWorkspace()); diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceRemoved.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceRemoved.java index 98c4fe97b..749414144 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceRemoved.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/ServiceRemoved.java @@ -25,15 +25,13 @@ protected ServiceRemoved() { // default constructor, needed for deserialization } - protected ServiceRemoved( - @NonNull Long updateSequence, @NonNull String objectId, String workspaceId) { + protected ServiceRemoved(long updateSequence, @NonNull String objectId, String workspaceId) { super(updateSequence, objectId, ConfigInfoType.ServiceInfo); this.workspaceId = workspaceId; } - public static ServiceRemoved createLocal( - @NonNull Long updateSequence, @NonNull ServiceInfo info) { + public static ServiceRemoved createLocal(long updateSequence, @NonNull ServiceInfo info) { final @NonNull String serviceId = info.getId(); final String workspaceId = resolveId(info.getWorkspace()); diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsAdded.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsAdded.java index ecb6b7693..8b51dd3bb 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsAdded.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsAdded.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import lombok.EqualsAndHashCode; -import lombok.NonNull; import org.geoserver.config.GeoServer; import org.geoserver.config.SettingsInfo; @@ -27,11 +26,11 @@ protected SettingsAdded() { // default constructor, needed for deserialization } - protected SettingsAdded(@NonNull Long updateSequence, SettingsInfo object) { + protected SettingsAdded(long updateSequence, SettingsInfo object) { super(updateSequence, object); } - public static SettingsAdded createLocal(@NonNull Long updateSequence, SettingsInfo value) { + public static SettingsAdded createLocal(long updateSequence, SettingsInfo value) { return new SettingsAdded(updateSequence, value); } } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsModified.java index f26d3e26b..39cdb44df 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsModified.java @@ -23,14 +23,14 @@ public class SettingsModified extends ConfigInfoModified implements ConfigInfoEvent { - private @Getter @NonNull String workspaceId; + private @Getter String workspaceId; protected SettingsModified() { // default constructor, needed for deserialization } public SettingsModified( - @NonNull Long updateSequence, + long updateSequence, @NonNull String objectId, @NonNull Patch patch, @NonNull String workspaceId) { @@ -44,7 +44,7 @@ public SettingsModified( } public static SettingsModified createLocal( - @NonNull Long updateSequence, @NonNull SettingsInfo object, @NonNull Patch patch) { + long updateSequence, @NonNull SettingsInfo object, @NonNull Patch patch) { final String settingsId = object.getId(); final String workspaceId = InfoEvent.resolveId(object.getWorkspace()); diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsRemoved.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsRemoved.java index 155d47382..4d58f9ec6 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsRemoved.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/config/SettingsRemoved.java @@ -17,21 +17,20 @@ @JsonTypeName("SettingsInfoRemoved") public class SettingsRemoved extends ConfigInfoRemoved { - private @Getter @NonNull String workspaceId; + private @Getter String workspaceId; protected SettingsRemoved() { // default constructor, needed for deserialization } protected SettingsRemoved( - @NonNull Long updateSequence, @NonNull String objectId, @NonNull String workspaceId) { + long updateSequence, @NonNull String objectId, @NonNull String workspaceId) { super(updateSequence, objectId, ConfigInfoType.SettingsInfo); this.workspaceId = workspaceId; } - public static SettingsRemoved createLocal( - @NonNull Long updateSequence, @NonNull SettingsInfo settings) { + public static SettingsRemoved createLocal(long updateSequence, @NonNull SettingsInfo settings) { final @NonNull String settingsId = settings.getId(); final @NonNull String workspaceId = settings.getWorkspace().getId(); diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoAdded.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoAdded.java index bebbb0b4d..0217f8a7f 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoAdded.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoAdded.java @@ -22,11 +22,11 @@ }) public abstract class InfoAdded extends InfoEvent { - private @Getter @Setter @NonNull I object; + private @Getter @Setter I object; protected InfoAdded() {} - protected InfoAdded(@NonNull Long updateSequence, @NonNull I object) { + protected InfoAdded(long updateSequence, @NonNull I object) { super(updateSequence, resolveId(object), typeOf(object)); this.object = object; } diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoEvent.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoEvent.java index 657eb2481..da0851fa6 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoEvent.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoEvent.java @@ -32,9 +32,7 @@ public abstract class InfoEvent extends UpdateSequenceE protected InfoEvent() {} protected InfoEvent( - @NonNull Long updateSequence, - @NonNull String objectId, - @NonNull ConfigInfoType objectType) { + long updateSequence, @NonNull String objectId, @NonNull ConfigInfoType objectType) { super(updateSequence); // this.source = source; this.objectId = objectId; diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoModified.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoModified.java index 7dedf610e..5b573d641 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoModified.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoModified.java @@ -26,12 +26,12 @@ }) public abstract class InfoModified extends InfoEvent { - private @Getter @Setter @NonNull Patch patch; + private @Getter @Setter Patch patch; protected InfoModified() {} protected InfoModified( - @NonNull Long updateSequence, + long updateSequence, @NonNull String objectId, @NonNull ConfigInfoType objectType, @NonNull Patch patch) { diff --git a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoRemoved.java b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoRemoved.java index 7c16b17b6..f8e922316 100644 --- a/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoRemoved.java +++ b/src/catalog/events/src/main/java/org/geoserver/cloud/event/info/InfoRemoved.java @@ -23,7 +23,7 @@ public abstract class InfoRemoved extends InfoEvent { - private @NonNull @Getter String reason; + private @Getter String reason; protected SecurityConfigChanged() {} - protected SecurityConfigChanged(@NonNull Long updateSequence, @NonNull String reason) { + protected SecurityConfigChanged(long updateSequence, @NonNull String reason) { super(updateSequence); this.reason = reason; } @@ -35,8 +35,7 @@ protected SecurityConfigChanged(@NonNull Long updateSequence, @NonNull String re return super.toStringBuilder().append("reason", reason); } - public static SecurityConfigChanged createLocal( - @NonNull Long updateSequence, @NonNull String reason) { + public static SecurityConfigChanged createLocal(long updateSequence, @NonNull String reason) { return new SecurityConfigChanged(updateSequence, reason); } } diff --git a/src/catalog/jackson-bindings/geoserver/src/main/java/org/geoserver/jackson/databind/mapper/SharedMappers.java b/src/catalog/jackson-bindings/geoserver/src/main/java/org/geoserver/jackson/databind/mapper/SharedMappers.java index 0d1ab0ec9..cb1ccfef2 100644 --- a/src/catalog/jackson-bindings/geoserver/src/main/java/org/geoserver/jackson/databind/mapper/SharedMappers.java +++ b/src/catalog/jackson-bindings/geoserver/src/main/java/org/geoserver/jackson/databind/mapper/SharedMappers.java @@ -30,6 +30,7 @@ import org.mapstruct.ObjectFactory; import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; +import org.springframework.lang.Nullable; import java.util.Optional; @@ -85,7 +86,7 @@ public Class canonicalNameToClass(String value) { } /** Added due to {@link GMLInfo#getMimeTypeToForce()} */ - public String optToString(Optional value) { + public String optToString(@Nullable Optional value) { return value == null ? null : value.orElse(null); } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java index fea671e5f..c1ba6ca9a 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogInfoLookup.java @@ -409,7 +409,9 @@ public Optional findById(String id) { return findFirst(clazz, i -> name.equals(nameMapper.apply(i).getLocalPart())); } - protected Optional findByName(Name name, @Nullable Class clazz) { + protected Optional findByName(Name name, Class clazz) { + requireNonNull(name); + requireNonNull(clazz); for (Class key : nameMultiMap.keySet()) { if (clazz.isAssignableFrom(key)) { Map valueMap = getMapForType(nameMultiMap, key); @@ -477,7 +479,7 @@ public NamespaceInfoLookup() { } public @Override Optional findFirstByName( - String name, @Nullable Class clazz) { + String name, Class clazz) { requireNonNull(name); requireNonNull(clazz); return findByName(new NameImpl(name), clazz); diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogPlugin.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogPlugin.java index 0370292e5..7db3c2c31 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogPlugin.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/CatalogPlugin.java @@ -366,7 +366,7 @@ public ValidationResult validate(MapInfo map, boolean isNew) { } public @Override T detach(T store) { - return detached(store, facade.detach(store)); + return detach(store, facade.detach(store)); } public @Override T getStore(String id, Class clazz) { @@ -564,7 +564,7 @@ public ValidationResult validate(MapInfo map, boolean isNew) { } public @Override T detach(T resource) { - return detached(resource, facade.detach(resource)); + return detach(resource, facade.detach(resource)); } public @Override T getResource(String id, Class clazz) { @@ -759,7 +759,7 @@ public ValidationResult validate(MapInfo map, boolean isNew) { } public @Override LayerInfo detach(LayerInfo layer) { - return detached(layer, facade.detach(layer)); + return detach(layer, facade.detach(layer)); } public @Override LayerInfo getLayer(String id) { @@ -856,7 +856,7 @@ public static LayerInfo getLayerByName(Catalog catalog, String workspace, String } public @Override LayerGroupInfo detach(LayerGroupInfo layerGroup) { - return detached(layerGroup, facade.detach(layerGroup)); + return detach(layerGroup, facade.detach(layerGroup)); } public @Override List getLayerGroups() { @@ -944,7 +944,7 @@ public static LayerInfo getLayerByName(Catalog catalog, String workspace, String } public @Override MapInfo detach(MapInfo map) { - return detached(map, facade.detach(map)); + return detach(map, facade.detach(map)); } // Namespace methods @@ -988,7 +988,7 @@ public static LayerInfo getLayerByName(Catalog catalog, String workspace, String } public @Override NamespaceInfo detach(NamespaceInfo namespace) { - return detached(namespace, facade.detach(namespace)); + return detach(namespace, facade.detach(namespace)); } public @Override NamespaceInfo getDefaultNamespace() { @@ -1034,7 +1034,7 @@ public static LayerInfo getLayerByName(Catalog catalog, String workspace, String } public @Override WorkspaceInfo detach(WorkspaceInfo workspace) { - return detached(workspace, facade.detach(workspace)); + return detach(workspace, facade.detach(workspace)); } public @Override WorkspaceInfo getDefaultWorkspace() { @@ -1164,7 +1164,7 @@ public static LayerInfo getLayerByName(Catalog catalog, String workspace, String } public @Override StyleInfo detach(StyleInfo style) { - return detached(style, facade.detach(style)); + return detach(style, facade.detach(style)); } // Event methods @@ -1517,7 +1517,7 @@ protected void doRemove(T object, Consumer remover) { } } - private T detached(T original, T detached) { + private T detach(T original, T detached) { return detached != null ? detached : original; } diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java index 8d78a8b54..537e9a13f 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/RepositoryCatalogFacadeImpl.java @@ -179,7 +179,7 @@ protected I add( public @Override T getResourceByStore( StoreInfo store, String name, Class clazz) { - Optional resource = null; + Optional resource; NamespaceInfo ns = null; if (store.getWorkspace() != null && store.getWorkspace().getName() != null diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/forwarding/ResolvingCatalogFacadeDecorator.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/forwarding/ResolvingCatalogFacadeDecorator.java index cc6e38559..55440b406 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/forwarding/ResolvingCatalogFacadeDecorator.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/forwarding/ResolvingCatalogFacadeDecorator.java @@ -127,7 +127,7 @@ public ResolvingCatalogFacadeDecorator(ExtendedCatalogFacade facade) { * add traits to the current resolver */ public @Override Function getInboundResolver() { - return this.outboundResolver; + return this.inboundResolver; } @SuppressWarnings("unchecked") diff --git a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultPropertyValuesResolver.java b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultPropertyValuesResolver.java index 9ead56353..2a22bcfb1 100644 --- a/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultPropertyValuesResolver.java +++ b/src/catalog/plugin/src/main/java/org/geoserver/catalog/plugin/validation/DefaultPropertyValuesResolver.java @@ -98,15 +98,17 @@ private void resolve(ResourceInfo resource) { } private CoverageInfo resolve(CoverageInfo r) { - CoverageInfoImpl c = (CoverageInfoImpl) r; - if (c.getDimensions() != null) { - for (CoverageDimensionInfo dim : c.getDimensions()) { - if (dim.getNullValues() == null) { - ((CoverageDimensionImpl) dim).setNullValues(new ArrayList()); + if (r instanceof CoverageInfoImpl) { + CoverageInfoImpl c = (CoverageInfoImpl) r; + if (c.getDimensions() != null) { + for (CoverageDimensionInfo dim : c.getDimensions()) { + if (dim.getNullValues() == null) { + ((CoverageDimensionImpl) dim).setNullValues(new ArrayList()); + } } } + resolveCollections(r); } - resolveCollections(r); return r; } @@ -120,14 +122,18 @@ private void resolve(FeatureTypeInfo featureType) { } private WMSLayerInfo resolve(WMSLayerInfo wmsLayer) { - WMSLayerInfoImpl impl = (WMSLayerInfoImpl) wmsLayer; - resolveCollections(impl); + if (wmsLayer instanceof WMSLayerInfoImpl) { + WMSLayerInfoImpl impl = (WMSLayerInfoImpl) wmsLayer; + resolveCollections(impl); + } return wmsLayer; } private WMTSLayerInfo resolve(WMTSLayerInfo wmtsLayer) { - WMTSLayerInfoImpl impl = (WMTSLayerInfoImpl) wmtsLayer; - resolveCollections(impl); + if (wmtsLayer instanceof WMTSLayerInfoImpl) { + WMTSLayerInfoImpl impl = (WMTSLayerInfoImpl) wmtsLayer; + resolveCollections(impl); + } return wmtsLayer; } diff --git a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/PropertyDiffTest.java b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/PropertyDiffTest.java index e3d9c764a..e4735549d 100644 --- a/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/PropertyDiffTest.java +++ b/src/catalog/plugin/src/test/java/org/geoserver/catalog/plugin/PropertyDiffTest.java @@ -196,7 +196,7 @@ public class PropertyDiffTest { assertEquals(metadata, copy.getMetadata()); assertNotEquals(ws.getName(), copy.getName()); - assertNotEquals(ws.isIsolated(), copy.getName()); + assertNotEquals(ws.isIsolated(), copy.isIsolated()); assertNotEquals(ws.getDateCreated(), copy.getDateCreated()); assertNotEquals(ws.getDateModified(), copy.getDateModified()); assertNotEquals(ws.getMetadata(), copy.getMetadata()); diff --git a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudCatalogConfiguration.java b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudCatalogConfiguration.java index 16b7afc24..d0dce3a55 100644 --- a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudCatalogConfiguration.java +++ b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudCatalogConfiguration.java @@ -63,7 +63,7 @@ public void onTileLayerEvent(TileLayerEvent event) { } @Override - public void addLayer(final TileLayer tl) { + public synchronized void addLayer(final TileLayer tl) { checkNotNull(tl); checkArgument(canSave(tl), "Can't save TileLayer of type ", tl.getClass()); diff --git a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudDefaultStorageFinder.java b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudDefaultStorageFinder.java index 8d8cae0d4..d8c65e98d 100644 --- a/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudDefaultStorageFinder.java +++ b/src/gwc/core/src/main/java/org/geoserver/cloud/gwc/repository/CloudDefaultStorageFinder.java @@ -34,7 +34,7 @@ public CloudDefaultStorageFinder(Path defaultCacheDirectory, Environment environ this.environment = environment; } - public @Override String getDefaultPath() throws ConfigurationException { + public @Override String getDefaultPath() throws ConfigurationException { // NOSONAR return defaultCacheDirectory.toString(); } diff --git a/src/library/spring-boot-simplejndi/src/main/java/org/geoserver/cloud/jndi/NameClassPair.java b/src/library/spring-boot-simplejndi/src/main/java/org/geoserver/cloud/jndi/NameClassPair.java index 6d30bcd8f..1b53eb31e 100644 --- a/src/library/spring-boot-simplejndi/src/main/java/org/geoserver/cloud/jndi/NameClassPair.java +++ b/src/library/spring-boot-simplejndi/src/main/java/org/geoserver/cloud/jndi/NameClassPair.java @@ -24,6 +24,10 @@ public NameClassPair(String name, String className) { && Objects.equals(getClassName(), p.getClassName()); } + public @Override int hashCode() { + return Objects.hash(getName(), getClassName()); + } + public @Override String toString() { return super.toString(); }