Skip to content

Commit

Permalink
Merge pull request #432 from groldan/qa/sonar
Browse files Browse the repository at this point in the history
resolve SonarCloud reported issues
  • Loading branch information
groldan authored Mar 5, 2024
2 parents b1cfff8 + ad10a43 commit 061170e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,8 +58,7 @@ public class RemoteGeoServerEventBridge implements DisposableBean {
public RemoteGeoServerEventBridge( //
@NonNull Consumer<GeoServerEvent> localRemoteEventPublisher, //
@NonNull Consumer<RemoteGeoServerEvent> remoteEventPublisher, //
@NonNull RemoteGeoServerEventMapper mapper,
@NonNull UpdateSequence updateSequence) {
@NonNull RemoteGeoServerEventMapper mapper) {

this.mapper = mapper;
this.outboundEventPublisher = remoteEventPublisher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<GeoServerEvent> localEventPublisher = eventPublisher::publishEvent;
Consumer<RemoteGeoServerEvent> remoteEventPublisher = eventPublisher::publishEvent;
return new RemoteGeoServerEventBridge(
localEventPublisher, remoteEventPublisher, eventMapper, updateSequence);
localEventPublisher, remoteEventPublisher, eventMapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public Locale stringToLocale(String s) {
public Map<String, String> internationalStringToDto(InternationalString s) {
if (s instanceof GrowableInternationalString gs) {
Set<Locale> locales = gs.getLocales();
Map<String, String> dto = new HashMap<>(locales.size());
Map<String, String> dto = HashMap.newHashMap(locales.size());
locales.forEach(locale -> dto.put(localeToString(locale), gs.toString(locale)));
return dto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public <T extends CatalogInfo, R extends CatalogInfoRepository<T>> R repositoryF
return (R) repos.forObject(info);
}

public List<CatalogInfoRepository<? extends CatalogInfo>> all() {
public List<CatalogInfoRepository<?>> all() {
return repos.getAll();
}

Expand Down

0 comments on commit 061170e

Please sign in to comment.