Remove and forbid use of the type-unsafe empty Collections fields

This commit removes and now forbids all uses of the type-unsafe empty
Collections fields Collections#EMPTY_LIST, Collections#EMPTY_MAP, and
Collections#EMPTY_SET. The type-safe methods Collections#emptyList,
Collections#emptyMap, and Collections#emptySet should be used instead.

Relates elastic/elasticsearchelastic/elasticsearch#15187

Original commit: elastic/x-pack-elasticsearch@99f6fdd3a6
This commit is contained in:
Jason Tedor 2015-12-02 10:44:23 -05:00
parent 828097b281
commit 8ea7a62b86
7 changed files with 8 additions and 8 deletions

View File

@ -76,7 +76,7 @@ public class IPFilter extends AbstractLifecycleComponent<IPFilter> {
private final Transport transport;
private final ShieldLicenseState licenseState;
private final boolean alwaysAllowBoundAddresses;
private Map<String, ShieldIpFilterRule[]> rules = Collections.EMPTY_MAP;
private Map<String, ShieldIpFilterRule[]> rules = Collections.emptyMap();
private HttpServerTransport httpServerTransport = null;
@Inject
@ -156,7 +156,7 @@ public class IPFilter extends AbstractLifecycleComponent<IPFilter> {
boolean isHttpFilterEnabled = settings.getAsBoolean(IP_FILTER_ENABLED_HTTP_SETTING, isIpFilterEnabled);
if (!isIpFilterEnabled && !isHttpFilterEnabled) {
return Collections.EMPTY_MAP;
return Collections.emptyMap();
}
Map<String, ShieldIpFilterRule[]> profileRules = new HashMap<>();

View File

@ -132,7 +132,7 @@ public class TriggeredWatchStore extends AbstractComponent {
public void putAll(final List<TriggeredWatch> triggeredWatches, final ActionListener<List<Integer>> listener) throws Exception {
if (triggeredWatches.isEmpty()) {
listener.onResponse(Collections.EMPTY_LIST);
listener.onResponse(Collections.emptyList());
return;
}

View File

@ -56,7 +56,7 @@ public class Script implements ToXContent {
}
public Map<String, Object> params() {
return params != null ? params : Collections.EMPTY_MAP;
return params != null ? params : Collections.emptyMap();
}
@Override

View File

@ -51,7 +51,7 @@ public class TextTemplate implements ToXContent {
}
public Map<String, Object> getParams() {
return params != null ? params : Collections.EMPTY_MAP;
return params != null ? params : Collections.emptyMap();
}
@Override

View File

@ -230,7 +230,7 @@ public class Watch implements TriggerEngine.Job, ToXContent {
this.secretService = secretService;
this.defaultInput = new ExecutableNoneInput(logger);
this.defaultCondition = new ExecutableAlwaysCondition(logger);
this.defaultActions = new ExecutableActions(Collections.EMPTY_LIST);
this.defaultActions = new ExecutableActions(Collections.emptyList());
this.clock = clock;
}

View File

@ -450,7 +450,7 @@ public class SlackMessageTests extends ESTestCase {
SlackMessage.Template template = templateBuilder.build();
SlackMessage message = template.render("_w1", "_a1", engine, Collections.EMPTY_MAP, defaults);
SlackMessage message = template.render("_w1", "_a1", engine, Collections.emptyMap(), defaults);
assertThat(message, notNullValue());
if (template.from != null) {
assertThat(message.from, is(template.from.getTemplate()));

View File

@ -260,7 +260,7 @@ public class WatchTests extends ESTestCase {
ConditionRegistry conditionRegistry = registry(new ExecutableAlwaysCondition(logger));
InputRegistry inputRegistry = registry(new ExecutableNoneInput(logger));
TransformRegistry transformRegistry = transformRegistry();
ExecutableActions actions = new ExecutableActions(Collections.EMPTY_LIST);
ExecutableActions actions = new ExecutableActions(Collections.emptyList());
ActionRegistry actionRegistry = registry(actions, transformRegistry);
XContentBuilder builder = XContentFactory.jsonBuilder();