JanusGraph / JanusGraph/janusgraph

Contract for id() documented in JanusGraphElement is not respected

Open
#1,957 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

In the java doc for id() method in JanusGraphElement interface, it is stated that the id() should throw IllegalStateException if entity does not (yet) have a unique identifier:
https://github.com/JanusGraph/janusgraph/blob/548d7ad64f6663f6f4b80178601fedf73d6eac72/janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphElement.java#L48-L65

but in AbstractVertex class, id() method can return a negative value, if the transaction (within which this vertex is created) is not committed yet. See

https://github.com/JanusGraph/janusgraph/blob/548d7ad64f6663f6f4b80178601fedf73d6eac72/janusgraph-core/src/main/java/org/janusgraph/graphdb/vertices/AbstractVertex.java#L78-L81

and

https://github.com/JanusGraph/janusgraph/blob/548d7ad64f6663f6f4b80178601fedf73d6eac72/janusgraph-core/src/main/java/org/janusgraph/graphdb/internal/AbstractElement.java#L26-L36

Thus I think maybe the java doc for id() method in the base interface JanusGraphElement should be updated. Please correct me if I miss something.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the id() contract in janusgraph-core/src/main/java/org/janusgraph/core/JanusGraphElement.java with the implementations in graphdb/vertices/AbstractVertex.java and graphdb/internal/AbstractElement.java. Confirm how an uncommitted vertex is represented and whether the interface documentation or implementation conflicts with that behavior. Done means the documented contract accurately matches the confirmed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.