RDF4JProtocolSession extends SPARQLProtocolSession { @Override public void close() { try { super.close(); } finally { transactionURL = null; if (ping != null) { ping.cancel(false); ping = null; } } } RDF4JProtocolSession(HttpClient client, ScheduledExecutorService executor); void setServerURL(String serverURL); String getServerURL(); String getRepositoryURL(); void setRepository(String repositoryURL); @Override String getUpdateURL(); @Override void close(); TupleQueryResult getRepositoryList(); void getRepositoryList(TupleQueryResultHandler handler); String getServerProtocol(); long size(Resource... contexts); void createRepository(RepositoryConfig config); void updateRepository(RepositoryConfig config); void deleteRepository(String repositoryID); void getRepositoryConfig(StatementCollector statementCollector); TupleQueryResult getNamespaces(); void getNamespaces(TupleQueryResultHandler handler); String getNamespace(String prefix); void setNamespacePrefix(String prefix, String name); void removeNamespacePrefix(String prefix); void clearNamespaces(); TupleQueryResult getContextIDs(); void getContextIDs(TupleQueryResultHandler handler); void getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler,
			Resource... contexts); synchronized void beginTransaction(IsolationLevel isolationLevel); synchronized void beginTransaction(TransactionSetting... transactionSettings); synchronized void commitTransaction(); synchronized void rollbackTransaction(); @Deprecated void sendTransaction(final Iterable<? extends TransactionOperation> txn); void addData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts); void removeData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts); void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite,
			boolean preserveNodeIds, Resource... contexts); void upload(final Reader contents, String baseURI, final RDFFormat dataFormat, boolean overwrite,
			boolean preserveNodeIds, Resource... contexts); @Override void setUsernameAndPassword(String username, String password);  }
@Test public void testClose() throws Exception { System.setProperty(Protocol.CACHE_TIMEOUT_PROPERTY, "1"); subject = new SharedHttpClientSessionManager().createRDF4JProtocolSession(serverURL); subject.setRepository(Protocol.getRepositoryLocation(serverURL, repositoryID)); String transactionStartUrl = Protocol.getTransactionsLocation(subject.getRepositoryURL()); stubFor(post(urlEqualTo("/rdf4j-server/repositories/test/transactions")) .willReturn(aResponse().withStatus(201).withHeader("Location", transactionStartUrl + "/1"))); stubFor(post("/rdf4j-server/repositories/test/transactions/1?action=PING") .willReturn(aResponse().withStatus(200).withBody("2000"))); subject.beginTransaction(IsolationLevels.SERIALIZABLE); Thread.sleep(2000); verify(moreThanOrExactly(2), postRequestedFor(urlEqualTo("/rdf4j-server/repositories/test/transactions/1?action=PING"))); subject.close(); Thread.sleep(1000); verify(lessThanOrExactly(3), postRequestedFor(urlEqualTo("/rdf4j-server/repositories/test/transactions/1?action=PING"))); }