jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/386467 )
Change subject: fix spotbug warnings
......................................................................
fix spotbug warnings
New spotbug version finds a few more minor issues with checking return
values from guava's checkNotNull. This is a good occasion to move to the
more standard java.util.Objects.requireNonNull().
Change-Id: I0788fb112602d70b386cd934171181ade0aef6aa
---
M
blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ApiTemplate.java
M
blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/MWApiServiceFactory.java
M
blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ServiceConfig.java
M tools/src/main/java/org/wikidata/query/rdf/tool/change/IdListChangeSource.java
M
tools/src/main/java/org/wikidata/query/rdf/tool/change/IdRangeChangeSource.java
M tools/src/main/java/org/wikidata/query/rdf/tool/rdf/Munger.java
M tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
7 files changed, 25 insertions(+), 16 deletions(-)
Approvals:
Smalyshev: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ApiTemplate.java
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ApiTemplate.java
index e10baae..0acfb8f 100644
---
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ApiTemplate.java
+++
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ApiTemplate.java
@@ -1,5 +1,8 @@
package org.wikidata.query.rdf.blazegraph.mwapi;
+import static java.util.Objects.requireNonNull;
+import static
org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceFactory.paramNameToURI;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -23,11 +26,8 @@
import com.bigdata.rdf.sparql.ast.eval.ServiceParams;
import com.bigdata.rdf.sparql.ast.service.ServiceNode;
import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-
-import static
org.wikidata.query.rdf.blazegraph.mwapi.MWApiServiceFactory.paramNameToURI;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -85,7 +85,7 @@
Map<String, String> outputVars = new HashMap<>();
// Parse input params
final JsonNode params = json.get("params");
- Preconditions.checkNotNull(params, "Missing params node");
+ requireNonNull(params, "Missing params node");
params.fieldNames().forEachRemaining(paramName -> {
if (fixedParams.containsKey(paramName)
|| inputVars.contains(paramName)) {
@@ -109,10 +109,10 @@
// Parse output params
final JsonNode output = json.get("output");
- Preconditions.checkNotNull(params, "Missing output node");
+ requireNonNull(params, "Missing output node");
String items = output.get("items").asText();
final JsonNode vars = output.get("vars");
- Preconditions.checkNotNull(vars, "Missing vars node");
+ requireNonNull(vars, "Missing vars node");
vars.fieldNames().forEachRemaining(paramName -> {
if (inputVars.contains(paramName)
|| fixedParams.containsKey(paramName)) {
@@ -227,7 +227,7 @@
List<OutputVariable> vars = new ArrayList<>(outputVars.size());
final GraphPatternGroup<IGroupMemberNode> group =
serviceNode.getGraphPattern();
- Preconditions.checkNotNull(serviceNode, "Group node is null?");
+ requireNonNull(serviceNode, "Group node is null?");
String prefix = paramNameToURI("").stringValue();
group.iterator().forEachRemaining(node -> {
diff --git
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/MWApiServiceFactory.java
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/MWApiServiceFactory.java
index 921e7a9..2a7a0e0 100644
---
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/MWApiServiceFactory.java
+++
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/MWApiServiceFactory.java
@@ -1,5 +1,7 @@
package org.wikidata.query.rdf.blazegraph.mwapi;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -35,7 +37,6 @@
import com.bigdata.rdf.sparql.ast.service.ServiceNode;
import com.bigdata.rdf.sparql.ast.service.ServiceRegistry;
import com.bigdata.rdf.store.BD;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
/**
@@ -127,7 +128,7 @@
public BigdataServiceCall create(ServiceCallCreateParams params, final
ServiceParams serviceParams) {
ServiceNode serviceNode = params.getServiceNode();
- Preconditions.checkNotNull(serviceNode, "Missing service node?");
+ requireNonNull(serviceNode, "Missing service node?");
try {
ApiTemplate template = getServiceTemplate(serviceParams);
@@ -154,7 +155,7 @@
*/
private ApiTemplate getServiceTemplate(final ServiceParams serviceParams) {
final String templateName = serviceParams.getAsString(API_KEY);
- Preconditions.checkNotNull(templateName, "Service name (wikibase:api)
should be supplied");
+ requireNonNull(templateName, "Service name (wikibase:api) should be
supplied");
serviceParams.clear(API_KEY);
return config.getService(templateName);
}
@@ -167,9 +168,9 @@
*/
private String getServiceHost(final ServiceParams serviceParams) throws
MalformedURLException {
TermNode hostNode = serviceParams.get(ENDPOINT_KEY, null);
- Preconditions.checkNotNull(hostNode, "Service name (wikibase:endpoint)
should be supplied");
+ requireNonNull(hostNode, "Service name (wikibase:endpoint) should be
supplied");
// TODO: allow variable endpoints
- Preconditions.checkArgument(hostNode.isConstant(), "Endpoint name
should be a constant");
+ requireNonNull(hostNode.isConstant(), "Endpoint name should be a
constant");
serviceParams.clear(ENDPOINT_KEY);
Value v = hostNode.getValue();
@@ -206,10 +207,10 @@
* @return
*/
public ServiceParams serviceParamsFromNode(final ServiceNode serviceNode) {
- Preconditions.checkNotNull(serviceNode, "Service node is null?");
+ requireNonNull(serviceNode, "Service node is null?");
final GraphPatternGroup<IGroupMemberNode> group =
serviceNode.getGraphPattern();
- Preconditions.checkNotNull(serviceNode, "Group node is null?");
+ requireNonNull(serviceNode, "Group node is null?");
final ServiceParams serviceParams = new ServiceParams();
final Iterator<IGroupMemberNode> it = group.iterator();
diff --git
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ServiceConfig.java
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ServiceConfig.java
index 9a845de..77d971d 100644
---
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ServiceConfig.java
+++
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/mwapi/ServiceConfig.java
@@ -1,5 +1,7 @@
package org.wikidata.query.rdf.blazegraph.mwapi;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.Reader;
import java.util.List;
@@ -39,7 +41,7 @@
* @return Map of API templates per name.
*/
private static Map<String, ApiTemplate> loadJSONConfig(JsonNode node) {
- Preconditions.checkNotNull(node, "Must have services node");
+ requireNonNull(node, "Must have services node");
return Streams.stream(node.fieldNames())
.collect(ImmutableMap.toImmutableMap(
@@ -53,7 +55,7 @@
* @return
*/
private static List<String> loadEndpoints(JsonNode node) {
- Preconditions.checkNotNull(node, "Must have endpoints node");
+ requireNonNull(node, "Must have endpoints node");
Preconditions.checkArgument(node.isArray(), "Endpoints config should
be an array");
// Get immutable list of elements' text representations
diff --git
a/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdListChangeSource.java
b/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdListChangeSource.java
index 0a417e9..5f2ffbf 100644
---
a/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdListChangeSource.java
+++
b/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdListChangeSource.java
@@ -13,6 +13,7 @@
/**
* Creates a change source out of the list of IDs.
*/
+@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED", justification =
"spotbug limitation: https://github.com/spotbugs/spotbugs/issues/463")
public class IdListChangeSource implements
Change.Source<IdListChangeSource.Batch> {
/**
* Build and IdChangeSource for items as opposed to properties.
diff --git
a/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdRangeChangeSource.java
b/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdRangeChangeSource.java
index 5de4aa3..bdab147 100644
---
a/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdRangeChangeSource.java
+++
b/tools/src/main/java/org/wikidata/query/rdf/tool/change/IdRangeChangeSource.java
@@ -9,10 +9,13 @@
import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
/**
* Blindly iterates an id range and returns those as "changes". Can be used to
* load known ids.
*/
+@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED", justification =
"spotbug limitation: https://github.com/spotbugs/spotbugs/issues/463")
public class IdRangeChangeSource implements
Change.Source<IdRangeChangeSource.Batch> {
/**
* Build and IdChangeSource for items as opposed to properties.
diff --git a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/Munger.java
b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/Munger.java
index 180b533..04fd6a6 100644
--- a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/Munger.java
+++ b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/Munger.java
@@ -59,6 +59,7 @@
*/
// TODO fan out complexity
@SuppressWarnings("checkstyle:classfanoutcomplexity")
+@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED", justification =
"spotbug limitation: https://github.com/spotbugs/spotbugs/issues/463")
public class Munger {
private static final Logger log = LoggerFactory.getLogger(Munger.class);
diff --git
a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
index 05e6994..e6e891e 100644
--- a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
+++ b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
@@ -78,6 +78,7 @@
*/
// TODO fan out complexity
@SuppressWarnings("checkstyle:classfanoutcomplexity")
+@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED", justification =
"spotbug limitation: https://github.com/spotbugs/spotbugs/issues/463")
public class RdfRepository implements AutoCloseable {
private static final Logger log =
LoggerFactory.getLogger(RdfRepository.class);
/**
--
To view, visit https://gerrit.wikimedia.org/r/386467
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0788fb112602d70b386cd934171181ade0aef6aa
Gerrit-PatchSet: 3
Gerrit-Project: wikidata/query/rdf
Gerrit-Branch: master
Gerrit-Owner: Gehel <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits