Skip to content

Fix ClassCastException in ConstraintChecker.STORAGE_READER_CONSTRAINT_BUILDER#37

Open
tsetso-spread wants to merge 3 commits intoDozerDB:neo4j-5.26.8from
tsetso-spread:fix/constraint-checker-classcast
Open

Fix ClassCastException in ConstraintChecker.STORAGE_READER_CONSTRAINT_BUILDER#37
tsetso-spread wants to merge 3 commits intoDozerDB:neo4j-5.26.8from
tsetso-spread:fix/constraint-checker-classcast

Conversation

@tsetso-spread
Copy link
Copy Markdown

Summary

  • Fix ClassCastException in STORAGE_READER_CONSTRAINT_BUILDER by casting constraintDescriptor.schema() instead of constraintDescriptor to LabelSchemaDescriptor / RelationTypeSchemaDescriptor
  • The bug caused a crash at transaction commit time for any database with property existence constraints
  • Add regression tests for both node and relationship property existence constraints

Details

In ConstraintChecker.java lines 82 and 86, the code was casting constraintDescriptor (a ConstraintDescriptorImplementation) directly to LabelSchemaDescriptor / RelationTypeSchemaDescriptor, when it should be casting constraintDescriptor.schema() which actually returns the schema descriptor.

Test plan

  • New regression test: testStorageReaderConstraintBuilder_NodePropertyExistenceConstraint — verifies node property existence constraints don't throw ClassCastException and correctly populate the checker
  • New regression test: testStorageReaderConstraintBuilder_RelPropertyExistenceConstraint — same for relationship property existence constraints
  • All existing tests pass (mvnw test -pl core -Dtest=ConstraintCheckerTest — 4/4 pass)

🤖 Generated with Claude Code

tsetso-spread and others added 2 commits March 17, 2026 19:26
…_BUILDER

Cast constraintDescriptor.schema() instead of constraintDescriptor itself
to LabelSchemaDescriptor/RelationTypeSchemaDescriptor. The previous code
threw ClassCastException at transaction commit time for any database with
property existence constraints, since ConstraintDescriptorImplementation
is not a LabelSchemaDescriptor or RelationTypeSchemaDescriptor.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… enforcement

Use SchemaDescriptors/ConstraintDescriptorFactory instead of mocks for
schema and constraint descriptors. Add tests for checkNode violation
detection, positive pass-through, label mismatch, and non-existence
constraint filtering. Switch assertions to AssertJ for codebase consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tsetso-spread
Copy link
Copy Markdown
Author

Hey @jmsuhy , found this issue, but not sure exactly to which branch I have to merge it. Could you direct me here?

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant