thinkaurelius / titan

Distributed Graph Database
http://titandb.io
Apache License 2.0
5.25k stars 1.01k forks source link

For edges Property::isPresent() reports stale state if property is removed or added #1355

Open rsteppac opened 8 years ago

rsteppac commented 8 years ago

The following usage pattern will cause an IllegalStateException when accessing the property:

// isPresent() yields "false"
if (edge.property("my_prop").isPresent()) {
    edge.value("my_prop"); 
}

edge.property("my_prop","some_value");

// isPresent() yields "true"
if (edge.property("my_prop").isPresent()) {
    edge.value("my_prop"); // retrieves string value as expected
}

// Appears to remove the value, but not the property itself.
edge.properties("my_prop").forEachRemaining(prop -> prop.remove());

// isPresent() still yields "true"
if (edge.property("my_prop").isPresent()) {
    edge.value("my_prop"); // throws java.lang.IllegalStateException
}

The problem can be worked around be reloading the edge from the graph (no commit required) every time a property is added or removed. Vertex properties do not have this issue. Their presence state always reflects the addition or removal of a property.