// join the results of the cache connection and the wrapped connection in a single result
return new UnionIteration<Statement, SailException>(
new ExceptionConvertingIteration<Statement, SailException>(cachingConnection.getStatements(subj,pred,obj,includeInferred, contexts)) {
@Override
protected SailException convert(Exception e) {
return new SailException("error while accessing cache connection",e);
}
@Override
protected void handleClose() throws SailException {
super.handleClose();
try {
cachingConnection.close();
} catch (RepositoryException e) {
throw new SailException("error while closing cache connection",e);
}
}
},
super.getStatements(subj, pred, obj, includeInferred, contexts)
);
} catch (RepositoryException e) {
throw new SailException("error while accessing cache connection",e);
}
} else {
return super.getStatements(subj, pred, obj, includeInferred, contexts);
}
}