Commits

Anonymous committed 827cf23

Fix NPE when executing SPARQL query with no bindings on remote triple store

  • Participants
  • Parent commits 802bc3d

Comments (0)

Files changed (1)

File chempound-app/src/main/java/net/chempound/datastore/RemoteTripleStore.java

 
     protected String generateQueryString(final Query query, final QuerySolution initialBindings) {
         String queryString = query.toString();
-        for (final Iterator<String> iterator = initialBindings.varNames(); iterator.hasNext();) {
-            final String name =  iterator.next();
-            final String value = FmtUtils.stringForNode(initialBindings.get(name).asNode());
-            queryString = queryString.replaceAll("\\?" + Pattern.quote(name) + "\\b", value);
+        if (initialBindings != null) {
+            for (final Iterator<String> iterator = initialBindings.varNames(); iterator.hasNext();) {
+                final String name =  iterator.next();
+                final String value = FmtUtils.stringForNode(initialBindings.get(name).asNode());
+                queryString = queryString.replaceAll("\\?" + Pattern.quote(name) + "\\b", value);
+            }
         }
         return queryString;
     }