Skip to content

Commit 3f51012

Browse files
authored
Fix NPE in ReindexDataStreamTransportAction (#123262)
In the multi-project branch, we're making some changes to persistent tasks and those changes can cause the persistent tasks custom to still be `null`. This resulted in an NPE here, so I'm fixing the check here.
1 parent c40c5a6 commit 3f51012

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/ReindexDataStreamTransportAction.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ protected void doExecute(Task task, ReindexDataStreamRequest request, ActionList
8383
ClientHelper.getPersistableSafeSecurityHeaders(transportService.getThreadPool().getThreadContext(), clusterService.state())
8484
);
8585
String persistentTaskId = getPersistentTaskId(sourceDataStreamName);
86-
87-
PersistentTasksCustomMetadata persistentTasksCustomMetadata = clusterService.state()
88-
.getMetadata()
89-
.custom(PersistentTasksCustomMetadata.TYPE);
90-
PersistentTasksCustomMetadata.PersistentTask<?> persistentTask = persistentTasksCustomMetadata.getTask(persistentTaskId);
86+
final var persistentTask = PersistentTasksCustomMetadata.getTaskWithId(clusterService.state(), persistentTaskId);
9187

9288
if (persistentTask == null) {
9389
startTask(listener, persistentTaskId, params);

0 commit comments

Comments
 (0)