cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

hasRelation method returns wrong result

Hello,

I am getting a not consistent behavior of the hasRelation method when used by my custom stored procedure.

Stream<Node> filterNodesByRelationType(List<Node> nodes) {
        return nodes.stream().filter(node -> node.hasRelationship(Direction.OUTGOING, RelationshipType.withName("myRelation")));
    }

The problem is that at some point the hasRelation method returns true for a node that does not have this type of relationship.

By debugging, I found out that true is returned only the first time, the other calls of the same method return false for the same node.

By entering the innerHasRelationships method in NodeProxy class, I saw that the iterator contains a relationship that belongs to a previously checked node ( from the list ). So it seems like the method returns a value of the previous call for the first time.

If I replace the hasRelationship method by getRelationships(Direction.OUTGOING, RelationshipType.withName("myRelation")).iterator().hasNext() everything works as expected.

Could you please tell me what can be the cause of this issue.

Thanks

Neo4j version: 3.5.12

4 REPLIES 4

This sounds like a bug in Neo4j itself. Can you please create a GH issue at https://github.com/neo4j/neo4j/issues for not getting lost?

I have a similar issue here not with hasRelationship but with getRelationships. Pretty convinced is the same issue as the result is polluted by previous calls. I have an open enterprise support ticket, but my case is quite complex to reproduce. @michael.horak do you have a small database and simple case to reproduce the problem? If so please share as it will surely speed up the resolution.

I already shared the data set with Neo4j so they should be able to reproduce the problem. If you want you can follow the issue https://github.com/neo4j/neo4j/issues/12345

As a quick update, our engineering team has identified the bug and a fix is being created. Please follow the github issue for any further updates.