Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryStore fails to read data involving persisted nested triples #4866

Closed
pulquero opened this issue Jan 4, 2024 · 1 comment · Fixed by #4873
Closed

MemoryStore fails to read data involving persisted nested triples #4866

pulquero opened this issue Jan 4, 2024 · 1 comment · Fixed by #4873
Assignees
Labels
Milestone

Comments

@pulquero
Copy link

pulquero commented Jan 4, 2024

Current Behavior

Trying to create a MemoryStore from a datafile containing a nested Triple fails.

Expected Behavior

A MemoryStore can be created from a datafile containing a nested Triple.

Steps To Reproduce

Create MemoryStore with persist=true.
Add a statement involving a nested Triple.
Shutdown MemoryStore.
Create MemoryStore from datafile.

Exception in thread "main" java.lang.ClassCastException: class org.eclipse.rdf4j.model.impl.SimpleTriple cannot be cast to class org.eclipse.rdf4j.sail.memory.model.MemResource (org.eclipse.rdf4j.model.impl.SimpleTriple and org.eclipse.rdf4j.sail.memory.model.MemResource are in unnamed module of loader 'app')
2024-01-03T13:28:27.689776800Z at org.eclipse.rdf4j.sail.memory.FileIO.readStatement(FileIO.java:256)
2024-01-03T13:28:27.689938600Z at org.eclipse.rdf4j.sail.memory.FileIO.read(FileIO.java:183)
2024-01-03T13:28:27.689956200Z at org.eclipse.rdf4j.sail.memory.MemoryStore.initializeInternal(MemoryStore.java:289)
2024-01-03T13:28:27.689972100Z at org.eclipse.rdf4j.sail.helpers.AbstractSail.init(AbstractSail.java:183)
2024-01-03T13:28:27.689990100Z at org.eclipse.rdf4j.repository.sail.SailRepository.initializeInternal(SailRepository.java:158)

Version

4.3.8

Are you interested in contributing a solution yourself?

None

Anything else?

The root cause of this is line

return RDFStarUtil.fromRDFEncodedValue(rdfStarEncodedTriple);

where SimpleValueFactory is used to convert an encoded triple IRI to a nested Triple. This will then cause a class cast exception on line

MemResource memSubj = (MemResource) readValue(dataIn);

RDFStarUtil should contain methods that take the ValueFactory to use so that the MemoryStore can pass in its ValueFactory.

@pulquero pulquero added the 🐞 bug issue is a bug label Jan 4, 2024
@pulquero pulquero changed the title MemoryStore fails to read data involving persisted triples MemoryStore fails to read data involving persisted nested triples Jan 4, 2024
@hmottestad hmottestad self-assigned this Jan 21, 2024
@hmottestad hmottestad added this to the 4.3.9 milestone Jan 21, 2024
@hmottestad
Copy link
Contributor

@pulquero Thanks for figuring out this bug! It should be fixed in 4.3.9.

Btw. I noticed that you don't have a name in your Github profile. We like to credit people for bug reports and fixes in the release notes on rdf4j.org, if you add a name to your Github profile then we will use that when we credit you in the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants