[ 
https://issues.apache.org/jira/browse/JENA-824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14235368#comment-14235368
 ] 

Andy Seaborne commented on JENA-824:
------------------------------------

It looks like Query.setResultVars is not called at the end of parsing in 
{{ParserSPARQL11.parse$}} and related classes, or may be {{SPARQLParser}} which 
calls {{parse$}}.

Once flag {{resultVarsSet}} is set, it should be thread safe.

I think we should avoid synchronized on any get/read operations because of 
multuithreaded use.  The contract should be "create-seal-use", where "use" is 
multithreaded on an unchanging object.

> Concurrent usage of query causes NPE
> ------------------------------------
>
>                 Key: JENA-824
>                 URL: https://issues.apache.org/jira/browse/JENA-824
>             Project: Apache Jena
>          Issue Type: Bug
>            Reporter: Kristian Rosenvold
>
> Callin gQueryFactory.parse and then handling the Query off to multiple 
> threads can/will cause the error show in the stacktrace.
> As long as setResultVars is called on the Query before handing off to 
> threads, it seems to be safe.
> Pull request is coming on this.
> java.lang.NullPointerException
>       at com.hp.hpl.jena.sparql.core.Var.varNames(Var.java:193)
>       at com.hp.hpl.jena.query.Query.getResultVars(Query.java:369)
>       at 
> com.hp.hpl.jena.sparql.engine.QueryExecutionBase.asResultSet(QueryExecutionBase.java:470)
>       at 
> com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:533)
>       at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to