History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-1055
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jeen Broekstra
Reporter: Marek Surek
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sesame

SERVICE pattern in DELETE/INSERT WHERE update causes NullPointerException

Created: 03/Jul/12 10:32 AM   Updated: 03/Jul/12 11:21 PM
Component/s: SPARQL
Affects Version/s: 2.6.7
Fix Version/s: 2.6.8


 Description   
Example update operation:

PREFIX foo: <http://example.org/foo/>
INSERT
{
GRAPH <http://www.some.com/context>
{
?thing foo:counter ?counter
}
}
WHERE
{
     SERVICE <http://localhost:8080/openrdf-sesame/repositories/repo>
     {
           SELECT ?thing (COUNT(?thing2) AS ?counter) WHERE
            {
              ?thing foo:predicate ?thing2
             } GROUP BY ?thing
      }
}

Error:

java.lang.NullPointerException
at org.openrdf.query.parser.sparql.ast.ASTServiceGraphPattern.getPatternString(ASTServiceGraphPattern.java:61)
at org.openrdf.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1083)
at org.openrdf.query.parser.sparql.ast.ASTServiceGraphPattern.jjtAccept(ASTServiceGraphPattern.java:37)
at org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:146)
at org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:563)
at org.openrdf.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1050)
at org.openrdf.query.parser.sparql.ast.ASTGraphPatternGroup.jjtAccept(ASTGraphPatternGroup.java:19)
at org.openrdf.query.parser.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:519)
at org.openrdf.query.parser.sparql.UpdateExprBuilder.visit(UpdateExprBuilder.java:70)
at org.openrdf.query.parser.sparql.ast.ASTModify.jjtAccept(ASTModify.java:18)
at org.openrdf.query.parser.sparql.SPARQLParser.parseUpdate(SPARQLParser.java:100)
at org.openrdf.query.parser.QueryParserUtil.parseOperation(QueryParserUtil.java:66)


 All   Comments   Change History      Sort Order:
Comment by Marek Surek [03/Jul/12 10:56 AM]
The complete case of SES-1000 should include also INSERT. For purposes of SES-1000 I removed INSERT part as it was not necessary for test case.
Therefore the problem of this issue is following query :


INSERT
{
GRAPH <http://www.some.com/context>
{
?thing my:counter ?counter
}
}
WHERE
{
     SERVICE <http://localhost:8080/openrdf-sesame/repositories/repo>
     {
           SELECT ?thing (COUNT(?thing2) AS ?counter) WHERE
            {
              ?thing foo:predicate ?thing2
             } GROUP BY ?thing
      }
}

Comment by Jeen Broekstra [03/Jul/12 11:04 PM]
Modified issue title and description to fit the actual problem. Issue is not really related to SES-1000.

The cause of the NPE appears to be that for update operations, the source string of the original query/update is not set. This source string is used by the SERVICE expression to build up a new remote query to send to the remote endpoint. Possible fix is a parser adaptation to make sure the source string property is set for updates as well.

Comment by Jeen Broekstra [03/Jul/12 11:18 PM]
Turns out actual cause is that source string is set on the ASTUpdateSequence, but ASTServiceGraphPattern tries to read it from ASTOperationContainer. Fixed by delegating getSourceString in ASTUpdateContainer to parent node.

Comment by Jeen Broekstra [03/Jul/12 11:21 PM]
fixed by delegating getSourceString in ASTUpdateContainer to the parent node (a ASTUpdateSequence).