public Object execute(final SailConnection sc) throws SailException { sc.close(); return null; } }
@Override public void close() throws SailException { wrappedCon.close(); }
@Override public void close() throws SailException { wrappedCon.close(); }
protected void closeInternal() throws SailException { baseSailConnection.close(); }
protected void closeInternal() throws SailException { baseSailConnection.close(); }
public void shutDown() throws SailException { // Close any remaining open SailConnections for (SailConnection sc : idToConnectionMap.values()) { sc.close(); } // baseSail.shutDown(); }
protected void finalize() throws Throwable { super.finalize(); if (null != sailConnection) { sailConnection.close(); } sailConnection = null; }
public void endRDF() throws RDFHandlerException { try { sailConnection.commit(); } catch (SailException e) { throw new RDFHandlerException(e); } finally { if(null != sailConnection) { try { sailConnection.close(); } catch(SailException e) { log.error("Found SailException while trying to close Sail connection in SailWriter", e); } } sailConnection = null; } }
protected void closeInternal() throws SailException { if (ReplayConfiguration.LOG_TRANSACTIONS) { queryHandler.handle(new CloseConnectionCall(id)); } baseSailConnection.close(); }
@Override public void close() throws RepositoryException { try { super.close(); } catch (SailException e) { throw new RepositoryException(e); } finally { sailConnection.close(); } }
public SparqlQueryRepresentation(final String query, final Sail sail, final int limit, final MediaType mediaType) throws Exception { super(mediaType); try { data = new ByteArrayOutputStream(); SailConnection sc = sail.getConnection(); try { SparqlTools.SparqlResultFormat format = SparqlTools.SparqlResultFormat.lookup(this.getMediaType()); SparqlTools.executeQuery(query, sc, data, limit, format); } finally { sc.close(); } } catch (Throwable e) { // TODO: use logging instead e.printStackTrace(System.err); throw new Exception(e); } }
@After public void tearDown() { try { sc.close(); } catch (SailException e) { LOG.error("Error closing connection", e); } sc = null; try { cachingSail.shutDown(); } catch (SailException e) { LOG.error("Error shutting down repository", e); } cachingSail = null; baseSail = null; counter = null; }
private long countStatements(final Resource subject, final IRI predicate, final Value object, final Resource... contexts) { long count = 0; SailConnection c = sail.getConnection(); try { try (CloseableIteration<? extends Statement, SailException> iter = c.getStatements(subject, predicate, object, false, contexts)) { while (iter.hasNext()) { count++; iter.next(); } } c.rollback(); } finally { c.close(); } return count; } }
@Test public void canWriteIntoOnlySpecialContext() throws Exception { SailConnection c = sail.getConnection(); try { c.begin(); c.addStatement(THING1, RELATION1, THING2, SPECIAL_CONTEXT); c.addStatement(THING2, RELATION1, THING1, OTHER_CONTEXT); c.addStatement(THING2, RELATION1, THING2, (Resource) null); c.commit(); } finally { c.close(); } assertEquals(1, countStatements(null, null, null)); }
@Test public void testStatementsInSpecialContextAreVisible() throws Exception { SailConnection bc = baseSail.getConnection(); try { bc.begin(); bc.addStatement(THING1, RELATION1, THING2, SPECIAL_CONTEXT); bc.addStatement(THING2, RELATION1, THING2, SPECIAL_CONTEXT); bc.commit(); } finally { bc.close(); } assertEquals(2, countStatements(null, null, null, SPECIAL_CONTEXT)); assertEquals(2, countStatements(null, null, null)); assertEquals(1, countStatements(THING1, null, null, SPECIAL_CONTEXT)); assertEquals(1, countStatements(THING1, null, null)); assertEquals(0, countStatements(null, null, null, OTHER_CONTEXT)); assertEquals(0, countStatements(null, null, null, (Resource) null)); }
@Test public void testStatementsInOtherContextsAreInvisible() throws Exception { SailConnection bc = baseSail.getConnection(); try { bc.begin(); bc.addStatement(THING1, RELATION1, THING2, SPECIAL_CONTEXT); bc.addStatement(THING2, RELATION1, THING1, OTHER_CONTEXT); bc.addStatement(THING2, RELATION1, THING2, (Resource) null); bc.commit(); } finally { bc.close(); } assertEquals(1, countStatements(null, null, null, SPECIAL_CONTEXT)); assertEquals(1, countStatements(null, null, null)); assertEquals(1, countStatements(THING1, null, null, SPECIAL_CONTEXT)); assertEquals(1, countStatements(THING1, null, null)); assertEquals(0, countStatements(THING2, null, null, SPECIAL_CONTEXT)); assertEquals(0, countStatements(THING2, null, null)); assertEquals(0, countStatements(null, null, null, OTHER_CONTEXT)); assertEquals(0, countStatements(null, null, null, (Resource) null)); }