Folks,
I'm seeing a problem with a thread pool blocking shutdown of Tomcat. The
pool seems to be created by the AlarmClock class in Jena which I think is
being instantiated from QueryExecutionBase. The problem only seems to occur
if I execute a SPARQL query with a timeout set like so:
QueryExecution queryExec = QueryExecutionFactory.create(query, model);
queryExec.setTimeout(queryTimeout);
I have a work around for the behaviour by manually releasing the clock
using a hack that causes grown developers to cry. In a class invoked at
application shutdown I do this:
private final AlarmClock defaultAlarmClock = AlarmClock.get();
public void shutdown()
{
defaultAlarmClock.release();
}
I'm assuming that this is not actually required and that I'm doing
something wrong executing the SPARQL or terminating the query. Any hints
are most welcome. Here's the full version of the SPARQL execution code in
case it is of use in helping locate the issue:
public Set<Triple> findBySparql( Query query)
{
Set<Triple> results = new HashSet<Triple>();
try {
model.enterCriticalSection(Lock.READ);
QueryExecution queryExec = QueryExecutionFactory.create(query, model);
queryExec.setTimeout(queryTimeout);
try {
Model resultModel = queryExec.execConstruct();
StmtIterator statements = resultModel.listStatements();
try {
while ( statements.hasNext()) {
Statement statement = statements.next();
results.add(new AttachedTripleImpl(statement));
}
}
finally {
statements.close();
}
}
finally {
queryExec.close();
}
}
finally {
model.leaveCriticalSection();
}
return results;
}
--
Regards,
*Stephen Owens*
CTO, ThoughtWire
t 647.351.9473 ext.104 I m 416.697.3466