Skip to content

Commit

Permalink
Fix NPE when updating settings on managed system indices (elastic#67200)
Browse files Browse the repository at this point in the history
`expectedValue` can be `null` (and in fact will always be `null` if a key is in `requestedSettings` but not `descriptorSettings`), so using `Objects.equals` prevents an NPE here.
  • Loading branch information
gwbrown committed Jan 11, 2021
1 parent 70f07ae commit 5b0273a
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

package org.elasticsearch.action.admin.indices.settings.put;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand All @@ -41,12 +48,6 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class TransportUpdateSettingsAction extends AcknowledgedTransportMasterNodeAction<UpdateSettingsRequest> {

private static final Logger logger = LogManager.getLogger(TransportUpdateSettingsAction.class);
Expand Down Expand Up @@ -142,7 +143,7 @@ private Map<String, List<String>> checkForSystemIndexViolations(Index[] concrete
final String expectedValue = descriptorSettings.get(key);
final String actualValue = requestSettings.get(key);

if (expectedValue.equals(actualValue) == false) {
if (Objects.equals(expectedValue, actualValue) == false) {
failedKeys.add(key);
}
}
Expand Down

0 comments on commit 5b0273a

Please sign in to comment.