Jena query / update with response timeout

public ResultSet query(String sparql) {
int retry = 0;
while (retry++ < MAX_RETRY) { try { try ( QueryExecution qExec = open().newQuery() .query(sparql) .timeout( MAX_RESPONSE_TIMEOUT_SEC, TimeUnit.SECONDS) .build() ) { ResultSet rs = qExec.execSelect(); return ResultSetFactory.copyResults(rs); } } catch (Exception e) { log.warn("SparQL query failed, retry {} {}", retry, e.getMessage()); } } throw new DatabaseException("SparQL query failed"); }

public void update(String sparql) {
int retry = 0;
while (retry++ < MAX_RETRY) { try { UpdateExecution uExec = open().newUpdate() .update(sparql) .timeout( MAX_RESPONSE_TIMEOUT_SEC, TimeUnit.SECONDS) .build(); uExec.execute(); return; } catch (Exception e) { log.warn("SparQL update failed, retry {} {}", retry, e.getMessage()); } } throw new DatabaseException("SparQL update failed"); }