JanusGraph / JanusGraph/janusgraph
updateIndex() should make error cases easier to understand
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
`ManagementSystem.updateIndex()` returns `null` if the provided `SchemaAction` is not applicable for the current status of the index:
```java
if (!updateAction.isApplicableStatus(schemaVertex.getStatus()))
return null;
```
[Source](https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-core/src/main/java/org/janusgraph/graphdb/database/management/ManagementSystem.java#L671)
This is confusing and the API docs also don't mention this behaviour:
```java
/**
* Updates the provided index according to the given {@link SchemaAction}
*
* @param index
* @param updateAction
* @return a future that completes when the index action is done
*/
IndexJobFuture updateIndex(Index index, SchemaAction updateAction);
```
The method should either throw an exception in this case or at least document this behaviour in the API docs.
When a user doesn't know about this behaviour, then all they're getting is a `NullPointerException` by calling `get()` on the returned `IndexJobFuture` (see #1359).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in janusgraph-core/src/main/java/org/janusgraph/graphdb/database/management/ManagementSystem.java at updateIndex(), then inspect the IndexJobFuture API declaration and its documentation. Decide whether the invalid SchemaAction should raise an exception or be documented as returning null, update the relevant implementation or API docs, and verify that callers no longer encounter an unexplained NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100