Description
The implementation of RdfList in the rdf.utils project performs a write when creating an empty RdfList.
This is dangerous because when the underlying graph is a LockableMGraphWrapper it tries to get a write lock on the graph before adding. If the creation of the list happens inside a read lock on the same graph this will create a deadlock. It requires a lot of knowledge of the implementation to be aware of these side-effects.
It may be better for users of RdflList if no such unexpected locks are set. The write access happens, because for an empty list, the triple "listResource owl:sameAs rdf:Nil" is added to the underlying graph. This is correct but not necessary. The suggestion is that the presence of an rdf:first property is used to determine whether the list is empty or not. We can provide a static method for the user to create an empty list with the owl:sameAs rdf:Nil triple if a user desires to do so and is aware of the side effects. In the add and remove methods the owl:sameAs rdf:Nil triple can still be removed/added as these operations clearly require write access.