Skip to content

Commit

Permalink
Merge pull request #381 from groldan/qa
Browse files Browse the repository at this point in the history
Fix non false positive bugs identified by SonarLint
  • Loading branch information
groldan authored Dec 2, 2023
2 parents 9df37bf + c43d983 commit e3ec42c
Show file tree
Hide file tree
Showing 40 changed files with 113 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UncheckedSqlException extends RuntimeException {
super(cause);
}

public @Override SQLException getCause() {
public @Override synchronized SQLException getCause() {
return (SQLException) super.getCause();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,11 +29,11 @@ public class UpdateSequenceEvent<SELF> extends GeoServerEvent<SELF> {
* 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class CatalogInfoAdded extends InfoAdded<CatalogInfoAdded, CatalogInfo> {

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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public class CatalogInfoModified extends InfoModified<CatalogInfoModified, Catal
protected CatalogInfoModified() {}

protected CatalogInfoModified(
@NonNull Long updateSequence,
long updateSequence,
@NonNull String objectId,
@NonNull ConfigInfoType objectType,
@NonNull Patch patch) {
super(updateSequence, objectId, objectType, patch);
}

public static CatalogInfoModified createLocal(
@NonNull Long updateSequence, @NonNull CatalogInfo info, @NonNull Patch patch) {
long updateSequence, @NonNull CatalogInfo info, @NonNull Patch patch) {

if (info instanceof Catalog) {
if (patch.get("defaultWorkspace").isPresent()) {
Expand All @@ -63,7 +63,7 @@ public static CatalogInfoModified createLocal(
}

public static CatalogInfoModified createLocal(
@NonNull Long updateSequence, @NonNull CatalogPostModifyEvent event) {
long updateSequence, @NonNull CatalogPostModifyEvent event) {

final CatalogInfo info = event.getSource();
final Patch patch =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ public class CatalogInfoRemoved extends InfoRemoved<CatalogInfoRemoved, CatalogI

protected CatalogInfoRemoved() {}

CatalogInfoRemoved(
@NonNull Long updateSequence, @NonNull String id, @NonNull ConfigInfoType type) {
CatalogInfoRemoved(long updateSequence, @NonNull String id, @NonNull ConfigInfoType type) {
super(updateSequence, id, type);
}

public static CatalogInfoRemoved createLocal(
@NonNull Long updateSequence, @NonNull CatalogInfo info) {
public static CatalogInfoRemoved createLocal(long updateSequence, @NonNull CatalogInfo info) {
String id = resolveId(info);
ConfigInfoType type = ConfigInfoType.valueOf(info);
return new CatalogInfoRemoved(updateSequence, id, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
@EqualsAndHashCode(callSuper = true)
public class DefaultDataStoreSet extends CatalogInfoModified {

private @NonNull @Getter String workspaceId;
private @Getter String workspaceId;
private @Getter String defaultDataStoreId;

protected DefaultDataStoreSet() {}

DefaultDataStoreSet(
@NonNull Long updateSequence,
long updateSequence,
@NonNull String workspaceId,
String defaultDataStoreId,
@NonNull Patch patch) {
Expand All @@ -54,7 +54,7 @@ protected DefaultDataStoreSet() {}
}

public static DefaultDataStoreSet createLocal(
@NonNull Long updateSequence, @NonNull CatalogPostModifyEvent event) {
long updateSequence, @NonNull CatalogPostModifyEvent event) {

PropertyDiff diff =
PropertyDiff.valueOf(
Expand All @@ -78,9 +78,7 @@ public static DefaultDataStoreSet createLocal(
}

public static DefaultDataStoreSet createLocal(
@NonNull Long updateSequence,
@NonNull WorkspaceInfo workspace,
DataStoreInfo newStore) {
long updateSequence, @NonNull WorkspaceInfo workspace, DataStoreInfo newStore) {

Patch patch = new Patch();
patch.add("defaultDataStore", newStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DefaultNamespaceSet extends CatalogInfoModified {

protected DefaultNamespaceSet() {}

DefaultNamespaceSet(@NonNull Long updateSequence, String newNamespaceId, @NonNull Patch patch) {
DefaultNamespaceSet(long updateSequence, String newNamespaceId, @NonNull Patch patch) {
super(updateSequence, InfoEvent.CATALOG_ID, ConfigInfoType.Catalog, patch);
this.newNamespaceId = newNamespaceId;
}
Expand All @@ -34,7 +34,7 @@ protected DefaultNamespaceSet() {}
}

public static DefaultNamespaceSet createLocal(
@NonNull Long updateSequence, NamespaceInfo defaultNamespace) {
long updateSequence, NamespaceInfo defaultNamespace) {

String namespaceId = resolveId(defaultNamespace);
Patch patch = new Patch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected DefaultWorkspaceSet() {
//
}

DefaultWorkspaceSet(@NonNull Long updateSequence, String newWorkspaceId, @NonNull Patch patch) {
DefaultWorkspaceSet(long updateSequence, String newWorkspaceId, @NonNull Patch patch) {
super(updateSequence, InfoEvent.CATALOG_ID, ConfigInfoType.Catalog, patch);
this.newWorkspaceId = newWorkspaceId;
}
Expand All @@ -38,7 +38,7 @@ protected DefaultWorkspaceSet() {
}

public static DefaultWorkspaceSet createLocal(
@NonNull Long updateSequence, WorkspaceInfo defaultWorkspace) {
long updateSequence, WorkspaceInfo defaultWorkspace) {

String workspaceId = resolveId(defaultWorkspace);
Patch patch = new Patch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ protected ConfigInfoAdded() {
// default constructor, needed for deserialization
}

public ConfigInfoAdded(@NonNull Long updateSequence, INFO object) {
public ConfigInfoAdded(long updateSequence, INFO object) {
super(updateSequence, object);
}

@SuppressWarnings("unchecked")
public static @NonNull <I extends Info> ConfigInfoAdded<?, I> createLocal(
@NonNull Long updateSequence, @NonNull I info) {
long updateSequence, @NonNull I info) {

final ConfigInfoType type = ConfigInfoType.valueOf(info);
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected ConfigInfoModified() {
}

protected ConfigInfoModified(
@NonNull Long updateSequence,
long updateSequence,
@NonNull String objectId,
@NonNull ConfigInfoType objectType,
@NonNull Patch patch) {
Expand All @@ -42,7 +42,7 @@ protected ConfigInfoModified(

@SuppressWarnings("unchecked")
public static @NonNull <I extends Info> ConfigInfoModified<?, I> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <I extends Info> ConfigInfoRemoved<?, I> createLocal(
@NonNull Long updateSequence, @NonNull I info) {
long updateSequence, @NonNull I info) {

final ConfigInfoType type = ConfigInfoType.valueOf(info);
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Loading

0 comments on commit e3ec42c

Please sign in to comment.