Unable to clear database namespaces with RDF4J

Steps to reproduce:

  • create an empty work database on a local Stardog instance

  • run the following java snippet

      final Repository repository=new StardogRepository("http://admin:admin@localhost:5820/work");
    
      repository.initialize();
    
      try (final RepositoryConnection connection=repository.getConnection()) {
      	connection.clearNamespaces();
      }
    
      repository.shutDown();
    

Expected Behaviour

  • work namespaces are cleared

Actual Behaviour

[main] ERROR com.complexible.stardog.rdf4j.StardogRepositoryConnection - Namespace clear error
java.util.ConcurrentModificationException
	at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1211)
	at java.util.TreeMap$KeyIterator.next(TreeMap.java:1265)
	at java.lang.Iterable.forEach(Iterable.java:74)
	at com.complexible.stardog.rdf4j.StardogRepositoryConnection.clearNamespaces(StardogRepositoryConnection.java:571)
	at work.StardogNamespaces.main(StardogNamespaces.java:36)
Exception in thread "main" org.eclipse.rdf4j.repository.RepositoryException: There was an error clearing the namespaces
	at com.complexible.stardog.rdf4j.StardogRepositoryConnection.clearNamespaces(StardogRepositoryConnection.java:575)
	at work.StardogNamespaces.main(StardogNamespaces.java:36)

Workarounds

  • replace connection.clearNamespaces() with

      try (final RepositoryResult<Namespace> namespaces=connection.getNamespaces()) {
      	while ( namespaces.hasNext() ) {
      		connection.removeNamespace(namespaces.next().getPrefix());
      	}
      }
    

Environment

Stardog: 5.0.2 Community
Stardog/RDF4J bindings: com.complexible.stardog.rdf4j:stardog-rdf4j:5.0.2

Hi, thanks for the very detailed bug report.

I was able to track this down and it will be fixed in the next Stardog release.

Fine. Would it be feasible to share a issue tracking number to be found in the release notes when the patch is released?

Sure, it will be “Unable to clear database namespaces with RDF4J (4165)”