JanusGraph / JanusGraph/janusgraph

updateIndex() should make error cases easier to understand

Open
#1,378 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted kind/enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.