Skip to content

Commit 1bf0a6b

Browse files
authored
Fix NPE in ReindexDataStreamTransportAction (elastic#123262) (elastic#123265)
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 2edbcb8 commit 1bf0a6b

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
@@ -82,11 +82,7 @@ protected void doExecute(Task task, ReindexDataStreamRequest request, ActionList
8282
ClientHelper.getPersistableSafeSecurityHeaders(transportService.getThreadPool().getThreadContext(), clusterService.state())
8383
);
8484
String persistentTaskId = getPersistentTaskId(sourceDataStreamName);
85-
86-
PersistentTasksCustomMetadata persistentTasksCustomMetadata = clusterService.state()
87-
.getMetadata()
88-
.custom(PersistentTasksCustomMetadata.TYPE);
89-
PersistentTasksCustomMetadata.PersistentTask<?> persistentTask = persistentTasksCustomMetadata.getTask(persistentTaskId);
85+
final var persistentTask = PersistentTasksCustomMetadata.getTaskWithId(clusterService.state(), persistentTaskId);
9086

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

0 commit comments

Comments
 (0)