Skip to content

Commit

Permalink
Fix potential NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Royer committed May 16, 2018
1 parent 6add12a commit cfccef8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ public boolean indexStaticOnly() {
return this.index_static_only;
}

@Override
public String toString() {
return this.name;
}
Expand Down Expand Up @@ -2109,6 +2110,7 @@ public boolean isIndexing() {
return true;
}

@Override
public String toString() {
return this.index_name;
}
Expand Down Expand Up @@ -2169,11 +2171,12 @@ public void clusterChanged(ClusterChangedEvent event)
* @param hadBootstrap If the node had bootstrap before joining.
* @return task to be executed by the index manager before joining the ring.
*/
@Override
public Callable<?> getPreJoinTask(boolean hadBootstrap)
{
return () -> {
if (!this.buildSubmit && !baseCfs.isEmpty() && !isBuilt()) {
logger.info("building index for [{}.{}]", baseCfs.keyspace.getName(), baseCfs.name);
logger.info("building index for [{}.{}]", baseCfs.keyspace.getName(), baseCfs.name);
baseCfs.forceBlockingFlush();
baseCfs.indexManager.buildIndexBlocking(this);
}
Expand All @@ -2198,7 +2201,7 @@ public Callable<?> getInitializationTask()

// Avoid inter-bocking with Keyspace.open()->rebuild()->flush()->open().
if (Keyspace.isInitialized() && !baseCfs.isEmpty() && !isBuilt()) {
logger.info("building index for [{}.{}]", baseCfs.keyspace.getName(), baseCfs.name);
logger.info("building index for [{}.{}]", baseCfs.keyspace.getName(), baseCfs.name);
this.buildSubmit = true;
baseCfs.forceBlockingFlush();
baseCfs.indexManager.buildIndexBlocking(this);
Expand Down Expand Up @@ -2333,7 +2336,8 @@ public Callable<?> getSnapshotWithoutFlushTask(String snapshotName)
@Override
public Callable<?> getInvalidateTask() {
return () -> {
this.clusterService.removeListener(this);
if (this.clusterService != null)
this.clusterService.removeListener(this);
elasticSecondayIndices.remove(index_name);
return null;
};
Expand Down

0 comments on commit cfccef8

Please sign in to comment.