Gehel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/386467 )
Change subject: fix spotbug warnings
......................................................................
fix spotbug warnings
New spotbug versio nfinds 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
3 files changed, 19 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/rdf
refs/changes/67/386467/1
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
--
To view, visit https://gerrit.wikimedia.org/r/386467
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0788fb112602d70b386cd934171181ade0aef6aa
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/rdf
Gerrit-Branch: master
Gerrit-Owner: Gehel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits