} finally {
connection.close();
}
} catch(RepositoryException e) {
log.error("error while getting repository connection: {}", e);
throw new MarmottaException("error while getting repository connection", e);
} catch (QueryEvaluationException e) {
log.error("error while evaluating query: {}", e);
throw new MarmottaException("error while writing query result in format ", e);
} catch (MalformedQueryException e) {
log.error("error because malformed query: {}", e);
throw new MarmottaException("error because malformed query result in format ", e);
}
log.debug("SPARQL execution took {}ms", System.currentTimeMillis()-start);
return Boolean.TRUE;
}
});
try {
Boolean result = future.get(timeoutInSeconds, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException e) {
log.info("SPARQL query execution aborted due to timeout");
future.cancel(true);
throw new TimeoutException("SPARQL query execution aborted due to timeout (" + configurationService.getIntConfiguration("sparql.timeout",60)+"s)");
} catch (ExecutionException e) {
log.info("SPARQL query execution aborted due to exception");
if(e.getCause() instanceof MarmottaException) {
throw (MarmottaException)e.getCause();
} else if(e.getCause() instanceof MalformedQueryException) {
throw (MalformedQueryException)e.getCause();
} else {
throw new MarmottaException("unknown exception while evaluating SPARQL query",e.getCause());
}
}
}