From 9f52066bdb0c5a26c5c916b9206ac1de8eac0ec6 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 1 Jul 2016 16:23:13 -0700 Subject: [PATCH] Removed generics from LifecycleComponent This is the xplugins side of elastic/elasticsearch#19225 Original commit: elastic/x-pack-elasticsearch@845a94555225db13e03cdc131e1487b40b7f9278 --- .../core/AbstractLicenseeComponent.java | 2 +- .../license/plugin/core/LicensesService.java | 2 +- .../consumer/TestPluginServiceBase.java | 2 +- .../xpack/monitoring/agent/AgentService.java | 2 +- .../agent/collector/AbstractCollector.java | 10 +-- .../monitoring/agent/collector/Collector.java | 2 +- .../cluster/ClusterStateCollector.java | 2 +- .../cluster/ClusterStatsCollector.java | 2 +- .../indices/IndexRecoveryCollector.java | 2 +- .../indices/IndexStatsCollector.java | 2 +- .../indices/IndicesStatsCollector.java | 2 +- .../collector/node/NodeStatsCollector.java | 2 +- .../collector/shards/ShardsCollector.java | 2 +- .../monitoring/agent/exporter/Exporters.java | 2 +- .../monitoring/cleaner/CleanerService.java | 2 +- .../audit/logfile/LoggingAuditTrail.java | 2 +- .../xpack/security/authc/Realms.java | 2 +- .../security/authz/store/FileRolesStore.java | 2 +- .../crypto/InternalCryptoService.java | 2 +- .../audit/logfile/LoggingAuditTrailTests.java | 57 ++++++++++------ .../xpack/security/authc/RealmsTests.java | 3 +- .../crypto/InternalCryptoServiceTests.java | 66 ++++++++++++------- .../security/ssl/SSLConfigurationTests.java | 24 ++++--- .../xpack/common/http/HttpClient.java | 2 +- .../notification/email/EmailService.java | 2 +- .../email/InternalEmailService.java | 2 +- .../notification/hipchat/HipChatService.java | 2 +- .../hipchat/InternalHipChatService.java | 2 +- .../pagerduty/InternalPagerDutyService.java | 2 +- .../pagerduty/PagerDutyService.java | 2 +- .../slack/InternalSlackService.java | 2 +- .../notification/slack/SlackService.java | 2 +- .../xpack/common/http/HttpClientTests.java | 36 ++++++---- .../http/HttpConnectionTimeoutTests.java | 15 +++-- .../common/http/HttpReadTimeoutTests.java | 15 +++-- .../validation/WatcherSettingsValidation.java | 2 +- .../actions/webhook/WebhookActionTests.java | 3 +- .../AbstractWatcherIntegrationTestCase.java | 2 +- 38 files changed, 174 insertions(+), 113 deletions(-) diff --git a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java index db28f529bfa..73c62e780e5 100644 --- a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java +++ b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java @@ -14,7 +14,7 @@ import java.util.concurrent.CopyOnWriteArrayList; /** * A supporting base class for injectable Licensee components. */ -public abstract class AbstractLicenseeComponent> extends AbstractLifecycleComponent +public abstract class AbstractLicenseeComponent> extends AbstractLifecycleComponent implements Licensee { private final String id; diff --git a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java index 1b1d14e5add..d098094644e 100644 --- a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java +++ b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java @@ -79,7 +79,7 @@ import java.util.concurrent.atomic.AtomicReference; * Registered listeners are notified using {@link #notifyAndSchedule(LicensesMetaData)} */ @Singleton -public class LicensesService extends AbstractLifecycleComponent implements ClusterStateListener, LicensesManagerService, +public class LicensesService extends AbstractLifecycleComponent implements ClusterStateListener, LicensesManagerService, LicenseeRegistry { public static final String REGISTER_TRIAL_LICENSE_ACTION_NAME = "internal:plugin/license/cluster/register_trial_license"; diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestPluginServiceBase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestPluginServiceBase.java index cfff3c3c24c..ae32f19d00e 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestPluginServiceBase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/consumer/TestPluginServiceBase.java @@ -21,7 +21,7 @@ import org.elasticsearch.license.plugin.core.LicensesService; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -public abstract class TestPluginServiceBase extends AbstractLifecycleComponent +public abstract class TestPluginServiceBase extends AbstractLifecycleComponent implements ClusterStateListener, Licensee { private LicensesService licensesClientService; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/AgentService.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/AgentService.java index 0690964276e..cb0389684b4 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/AgentService.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/AgentService.java @@ -41,7 +41,7 @@ import java.util.concurrent.locks.ReentrantLock; * @see #stopCollection() * @see #startCollection() */ -public class AgentService extends AbstractLifecycleComponent { +public class AgentService extends AbstractLifecycleComponent { private volatile ExportingWorker exportingWorker; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/AbstractCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/AbstractCollector.java index 5ccd1a3233e..2d8ee861298 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/AbstractCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/AbstractCollector.java @@ -19,7 +19,7 @@ import org.elasticsearch.xpack.monitoring.agent.exporter.MonitoringDoc; import java.util.Collection; -public abstract class AbstractCollector extends AbstractLifecycleComponent implements Collector { +public abstract class AbstractCollector extends AbstractLifecycleComponent implements Collector { private final String name; @@ -48,9 +48,9 @@ public abstract class AbstractCollector extends AbstractLifecycleComponent } @Override - public T start() { + public void start() { logger.debug("starting collector [{}]", name()); - return super.start(); + super.start(); } @Override @@ -90,9 +90,9 @@ public abstract class AbstractCollector extends AbstractLifecycleComponent protected abstract Collection doCollect() throws Exception; @Override - public T stop() { + public void stop() { logger.debug("stopping collector [{}]", name()); - return super.stop(); + super.stop(); } @Override diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/Collector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/Collector.java index 481a79aac8c..9233ecb638a 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/Collector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/Collector.java @@ -10,7 +10,7 @@ import org.elasticsearch.xpack.monitoring.agent.exporter.MonitoringDoc; import java.util.Collection; -public interface Collector extends LifecycleComponent { +public interface Collector extends LifecycleComponent { String name(); diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStateCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStateCollector.java index f6106cbcf27..8c3db642714 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStateCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStateCollector.java @@ -30,7 +30,7 @@ import java.util.List; * This collector runs on the master node only and collects {@link ClusterStateMonitoringDoc} document * at a given frequency. */ -public class ClusterStateCollector extends AbstractCollector { +public class ClusterStateCollector extends AbstractCollector { public static final String NAME = "cluster-state-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStatsCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStatsCollector.java index 8eb39690a2e..efcdf64b0bb 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStatsCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/cluster/ClusterStatsCollector.java @@ -36,7 +36,7 @@ import java.util.List; * document; the cluster stats are also indexed in the timestamped index in a * "cluster_stats" document. */ -public class ClusterStatsCollector extends AbstractCollector { +public class ClusterStatsCollector extends AbstractCollector { public static final String NAME = "cluster-stats-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexRecoveryCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexRecoveryCollector.java index ebfd00c3ee3..fcf9fd65e66 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexRecoveryCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexRecoveryCollector.java @@ -32,7 +32,7 @@ import java.util.List; * This collector runs on the master node only and collects a {@link IndexRecoveryMonitoringDoc} document * for every index that has on-going shard recoveries. */ -public class IndexRecoveryCollector extends AbstractCollector { +public class IndexRecoveryCollector extends AbstractCollector { public static final String NAME = "index-recovery-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexStatsCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexStatsCollector.java index 5a6337299d1..f52c45d0ed6 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexStatsCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndexStatsCollector.java @@ -34,7 +34,7 @@ import java.util.List; * This collector runs on the master node only and collect a {@link IndexStatsMonitoringDoc} document * for each existing index in the cluster. */ -public class IndexStatsCollector extends AbstractCollector { +public class IndexStatsCollector extends AbstractCollector { public static final String NAME = "index-stats-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndicesStatsCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndicesStatsCollector.java index 6b6d4af45f4..2f6c538ea20 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndicesStatsCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/indices/IndicesStatsCollector.java @@ -29,7 +29,7 @@ import java.util.Collections; *

* This collector runs on the master node only and collect one {@link IndicesStatsMonitoringDoc} document. */ -public class IndicesStatsCollector extends AbstractCollector { +public class IndicesStatsCollector extends AbstractCollector { public static final String NAME = "indices-stats-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/node/NodeStatsCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/node/NodeStatsCollector.java index b0ffddcbc63..cbbeefb0836 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/node/NodeStatsCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/node/NodeStatsCollector.java @@ -32,7 +32,7 @@ import java.util.Collections; * This collector runs on every non-client node and collect * a {@link NodeStatsMonitoringDoc} document for each node of the cluster. */ -public class NodeStatsCollector extends AbstractCollector { +public class NodeStatsCollector extends AbstractCollector { public static final String NAME = "node-stats-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/shards/ShardsCollector.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/shards/ShardsCollector.java index 8aa5b71b03c..58ffd7097ac 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/shards/ShardsCollector.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/collector/shards/ShardsCollector.java @@ -30,7 +30,7 @@ import java.util.List; * This collector runs on the master node only and collects the {@link ShardMonitoringDoc} documents * for every index shard. */ -public class ShardsCollector extends AbstractCollector { +public class ShardsCollector extends AbstractCollector { public static final String NAME = "shards-collector"; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/exporter/Exporters.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/exporter/Exporters.java index 658be1282d2..ab04f41897a 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/exporter/Exporters.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/agent/exporter/Exporters.java @@ -32,7 +32,7 @@ import static java.util.Collections.emptyMap; /** * */ -public class Exporters extends AbstractLifecycleComponent implements Iterable { +public class Exporters extends AbstractLifecycleComponent implements Iterable { private final Map factories; private final ClusterService clusterService; diff --git a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java index e61426e411d..b414cf966ab 100644 --- a/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java +++ b/elasticsearch/x-pack/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/cleaner/CleanerService.java @@ -26,7 +26,7 @@ import java.util.concurrent.ScheduledFuture; /** * {@code CleanerService} takes care of deleting old monitoring indices. */ -public class CleanerService extends AbstractLifecycleComponent { +public class CleanerService extends AbstractLifecycleComponent { private final MonitoringLicensee licensee; private final ThreadPool threadPool; diff --git a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java index f730873c145..3db017b9804 100644 --- a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java +++ b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrail.java @@ -44,7 +44,7 @@ import static org.elasticsearch.xpack.security.Security.setting; /** * */ -public class LoggingAuditTrail extends AbstractLifecycleComponent implements AuditTrail { +public class LoggingAuditTrail extends AbstractLifecycleComponent implements AuditTrail { public static final String NAME = "logfile"; public static final Setting HOST_ADDRESS_SETTING = diff --git a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java index 971d0fb7c75..470c664f2e1 100644 --- a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java +++ b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java @@ -32,7 +32,7 @@ import static org.elasticsearch.xpack.security.Security.setting; /** * Serves as a realms registry (also responsible for ordering the realms appropriately) */ -public class Realms extends AbstractLifecycleComponent implements Iterable { +public class Realms extends AbstractLifecycleComponent implements Iterable { public static final Setting REALMS_GROUPS_SETTINGS = Setting.groupSetting(setting("authc.realms."), Property.NodeScope); diff --git a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java index 1816df5e15e..57f8a16eee7 100644 --- a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java +++ b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java @@ -49,7 +49,7 @@ import static org.elasticsearch.xpack.security.Security.setting; /** * */ -public class FileRolesStore extends AbstractLifecycleComponent implements RolesStore { +public class FileRolesStore extends AbstractLifecycleComponent implements RolesStore { public static final Setting ROLES_FILE_SETTING = Setting.simpleString(setting("authz.store.files.roles"), Property.NodeScope); diff --git a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/crypto/InternalCryptoService.java b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/crypto/InternalCryptoService.java index 80ca629d847..63b6fe75aca 100644 --- a/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/crypto/InternalCryptoService.java +++ b/elasticsearch/x-pack/security/src/main/java/org/elasticsearch/xpack/security/crypto/InternalCryptoService.java @@ -51,7 +51,7 @@ import static org.elasticsearch.xpack.security.Security.setting; /** * */ -public class InternalCryptoService extends AbstractLifecycleComponent implements CryptoService { +public class InternalCryptoService extends AbstractLifecycleComponent implements CryptoService { public static final String KEY_ALGO = "HmacSHA512"; public static final int KEY_SIZE = 1024; diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java index ee82d66f2bc..361e7099268 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java @@ -124,7 +124,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); auditTrail.anonymousAccessDenied("_action", message); @@ -164,7 +165,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.anonymousAccessDenied(request); switch (level) { case ERROR: @@ -187,7 +189,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext);; auditTrail.authenticationFailed(new MockToken(), "_action", message); @@ -220,7 +223,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext);; auditTrail.authenticationFailed("_action", message); @@ -258,7 +262,8 @@ public class LoggingAuditTrailTests extends ESTestCase { when(request.uri()).thenReturn("_uri"); String expectedMessage = prepareRestContent(request); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.authenticationFailed(new MockToken(), request); switch (level) { case ERROR: @@ -285,7 +290,8 @@ public class LoggingAuditTrailTests extends ESTestCase { when(request.uri()).thenReturn("_uri"); String expectedMessage = prepareRestContent(request); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.authenticationFailed(request); switch (level) { case ERROR: @@ -306,7 +312,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext);; auditTrail.authenticationFailed("_realm", new MockToken(), "_action", message); @@ -338,7 +345,8 @@ public class LoggingAuditTrailTests extends ESTestCase { when(request.uri()).thenReturn("_uri"); String expectedMessage = prepareRestContent(request); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.authenticationFailed("_realm", new MockToken(), request); switch (level) { case ERROR: @@ -359,7 +367,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); boolean runAs = randomBoolean(); @@ -403,7 +412,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); auditTrail.accessGranted(SystemUser.INSTANCE, "internal:_action", message); @@ -431,7 +441,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); boolean runAs = randomBoolean(); @@ -475,7 +486,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); boolean runAs = randomBoolean(); @@ -523,7 +535,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.tamperedRequest(request); switch (level) { case ERROR: @@ -547,7 +560,8 @@ public class LoggingAuditTrailTests extends ESTestCase { TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.tamperedRequest(action, message); switch (level) { case ERROR: @@ -588,7 +602,8 @@ public class LoggingAuditTrailTests extends ESTestCase { TransportMessage message = randomBoolean() ? new MockMessage(threadContext) : new MockIndicesRequest(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); auditTrail.tamperedRequest(user, action, message); switch (level) { case ERROR: @@ -619,7 +634,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); InetAddress inetAddress = InetAddress.getLoopbackAddress(); SecurityIpFilterRule rule = new SecurityIpFilterRule(false, "_all"); auditTrail.connectionDenied(inetAddress, "default", rule); @@ -641,7 +657,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); InetAddress inetAddress = InetAddress.getLoopbackAddress(); SecurityIpFilterRule rule = IPFilter.DEFAULT_PROFILE_ACCEPT_ALL; auditTrail.connectionGranted(inetAddress, "default", rule); @@ -664,7 +681,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = new MockMessage(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); User user = new User("_username", new String[]{"r1"}, new User("running as", new String[] {"r2"})); @@ -690,7 +708,8 @@ public class LoggingAuditTrailTests extends ESTestCase { for (Level level : Level.values()) { threadContext = new ThreadContext(Settings.EMPTY); CapturingLogger logger = new CapturingLogger(level); - LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext).start(); + LoggingAuditTrail auditTrail = new LoggingAuditTrail(settings, transport, logger, threadContext); + auditTrail.start(); TransportMessage message = new MockMessage(threadContext); String origins = LoggingAuditTrail.originAttributes(message, transport, threadContext); User user = new User("_username", new String[]{"r1"}, new User("running as", new String[] {"r2"})); diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java index d8400e0d06f..f58558aec77 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java @@ -346,7 +346,8 @@ public class RealmsTests extends ESTestCase { .put("xpack.security.authc.realms.realm_1.order", 0) .build(); Environment env = new Environment(settings); - Realms realms = new Realms(settings, env, factories, securityLicenseState, reservedRealm).start(); + Realms realms = new Realms(settings, env, factories, securityLicenseState, reservedRealm); + realms.start(); assertThat(realms.iterator().hasNext(), is(true)); diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/crypto/InternalCryptoServiceTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/crypto/InternalCryptoServiceTests.java index 9a02c4fdb10..8101e202a35 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/crypto/InternalCryptoServiceTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/crypto/InternalCryptoServiceTests.java @@ -68,14 +68,16 @@ public class InternalCryptoServiceTests extends ESTestCase { public void testSigned() throws Exception { // randomize whether to use a system key or not Settings settings = randomBoolean() ? this.settings : Settings.EMPTY; - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); String text = randomAsciiOfLength(10); String signed = service.sign(text); assertThat(service.signed(signed), is(true)); } public void testSignAndUnsign() throws Exception { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); String text = randomAsciiOfLength(10); String signed = service.sign(text); assertThat(text.equals(signed), is(false)); @@ -84,7 +86,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testSignAndUnsignNoKeyFile() throws Exception { - InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService); + service.start(); final String text = randomAsciiOfLength(10); String signed = service.sign(text); // we always have some sort of key to sign with @@ -94,7 +97,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testTamperedSignature() throws Exception { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); String text = randomAsciiOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); @@ -111,7 +115,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testTamperedSignatureOneChar() throws Exception { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); String text = randomAsciiOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); @@ -130,7 +135,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testTamperedSignatureLength() throws Exception { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); String text = randomAsciiOfLength(10); String signed = service.sign(text); int i = signed.indexOf("$$", 2); @@ -157,7 +163,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptionAndDecryptionChars() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); final char[] chars = randomAsciiOfLengthBetween(0, 1000).toCharArray(); final char[] encrypted = service.encrypt(chars); @@ -169,7 +176,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptionAndDecryptionBytes() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); final byte[] bytes = randomByteArray(); final byte[] encrypted = service.encrypt(bytes); @@ -181,7 +189,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptionAndDecryptionCharsWithoutKey() { - InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(false)); final char[] chars = randomAsciiOfLengthBetween(0, 1000).toCharArray(); final char[] encryptedChars = service.encrypt(chars); @@ -191,7 +200,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptionAndDecryptionBytesWithoutKey() { - InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(false)); final byte[] bytes = randomByteArray(); final byte[] encryptedBytes = service.encrypt(bytes); @@ -201,17 +211,20 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptionEnabledWithKey() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); } public void testEncryptionEnabledWithoutKey() { - InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(Settings.EMPTY, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(false)); } public void testChangingAByte() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); // We need at least one byte to test changing a byte, otherwise output is always the same final byte[] bytes = randomByteArray(1); @@ -231,7 +244,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptedChar() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); assertThat(service.encrypted((char[]) null), is(false)); @@ -243,7 +257,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testEncryptedByte() { - InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); assertThat(service.encrypted((byte[]) null), is(false)); @@ -266,9 +281,11 @@ public class InternalCryptoServiceTests extends ESTestCase { // randomize how we set the listener InternalCryptoService service; if (randomBoolean()) { - service = new InternalCryptoService(settings, env, watcherService, Collections.singletonList(listener)).start(); + service = new InternalCryptoService(settings, env, watcherService, Collections.singletonList(listener)); + service.start(); } else { - service = new InternalCryptoService(settings, env, watcherService).start(); + service = new InternalCryptoService(settings, env, watcherService); + service.start(); service.register(listener); } @@ -299,7 +316,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testReencryptValuesOnKeyChange() throws Exception { - final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); final char[] text = randomAsciiOfLength(10).toCharArray(); final char[] encrypted = service.encrypt(text); @@ -329,7 +347,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testResignValuesOnKeyChange() throws Exception { - final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); final String text = randomAsciiOfLength(10); final String signed = service.sign(text); assertThat(text, not(equalTo(signed))); @@ -363,7 +382,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testReencryptValuesOnKeyDeleted() throws Exception { - final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); final char[] text = randomAsciiOfLength(10).toCharArray(); final char[] encrypted = service.encrypt(text); @@ -393,7 +413,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testAllListenersCalledWhenExceptionThrown() throws Exception { - final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); assertThat(service.encryptionEnabled(), is(true)); final CountDownLatch latch = new CountDownLatch(3); @@ -428,7 +449,8 @@ public class InternalCryptoServiceTests extends ESTestCase { } public void testSigningOnKeyDeleted() throws Exception { - final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService).start(); + final InternalCryptoService service = new InternalCryptoService(settings, env, watcherService); + service.start(); final String text = randomAsciiOfLength(10); final String signed = service.sign(text); assertThat(text, not(equalTo(signed))); diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/ssl/SSLConfigurationTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/ssl/SSLConfigurationTests.java index be9912b330e..4717634c0b3 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/ssl/SSLConfigurationTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/ssl/SSLConfigurationTests.java @@ -327,7 +327,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); KeyManager[] keyManagers = keyConfig.keyManagers(env, resourceWatcherService, listener); assertThat(keyManagers.length, is(1)); assertThat(keyManagers[0], instanceOf(X509ExtendedKeyManager.class)); @@ -390,7 +391,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload pem"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); KeyManager[] keyManagers = keyConfig.keyManagers(env, resourceWatcherService, listener); assertThat(keyManagers.length, is(1)); assertThat(keyManagers[0], instanceOf(X509ExtendedKeyManager.class)); @@ -466,7 +468,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); TrustManager[] trustManagers = trustConfig.trustManagers(env, resourceWatcherService, listener); assertThat(trustManagers.length, is(1)); assertThat(trustManagers[0], instanceOf(X509ExtendedTrustManager.class)); @@ -512,7 +515,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); TrustManager[] trustManagers = trustConfig.trustManagers(env, resourceWatcherService, listener); assertThat(trustManagers.length, is(1)); assertThat(trustManagers[0], instanceOf(X509ExtendedTrustManager.class)); @@ -560,7 +564,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); KeyManager[] keyManagers = keyConfig.keyManagers(env, resourceWatcherService, listener); X509ExtendedKeyManager keyManager = (X509ExtendedKeyManager) keyManagers[0]; String[] aliases = keyManager.getServerAliases("RSA", null); @@ -609,7 +614,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload pem"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); KeyManager[] keyManagers = keyConfig.keyManagers(env, resourceWatcherService, listener); assertThat(keyManagers.length, is(1)); assertThat(keyManagers[0], instanceOf(X509ExtendedKeyManager.class)); @@ -660,7 +666,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); TrustManager[] trustManagers = trustConfig.trustManagers(env, resourceWatcherService, listener); assertThat(trustManagers.length, is(1)); assertThat(trustManagers[0], instanceOf(X509ExtendedTrustManager.class)); @@ -699,7 +706,8 @@ public class SSLConfigurationTests extends ESTestCase { ThreadPool threadPool = new TestThreadPool("reload"); try { ResourceWatcherService resourceWatcherService = - new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool).start(); + new ResourceWatcherService(Settings.builder().put("resource.reload.interval.high", "1s").build(), threadPool); + resourceWatcherService.start(); TrustManager[] trustManagers = trustConfig.trustManagers(env, resourceWatcherService, listener); assertThat(trustManagers.length, is(1)); assertThat(trustManagers[0], instanceOf(X509ExtendedTrustManager.class)); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/common/http/HttpClient.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/common/http/HttpClient.java index 7ea26a7ba57..47147abe980 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/common/http/HttpClient.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/common/http/HttpClient.java @@ -46,7 +46,7 @@ import java.util.Map; /** * Client class to wrap http connections */ -public class HttpClient extends AbstractLifecycleComponent { +public class HttpClient extends AbstractLifecycleComponent { static final String SETTINGS_SSL_PREFIX = "xpack.http.ssl."; static final String SETTINGS_PROXY_PREFIX = "xpack.http.proxy."; diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/EmailService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/EmailService.java index 3131cc5a8f7..08172e068ab 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/EmailService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/EmailService.java @@ -12,7 +12,7 @@ import javax.mail.MessagingException; /** * */ -public interface EmailService extends LifecycleComponent{ +public interface EmailService extends LifecycleComponent{ EmailSent send(Email email, Authentication auth, Profile profile) throws MessagingException; diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/InternalEmailService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/InternalEmailService.java index 32d762c1b4b..26a0f8b7279 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/InternalEmailService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/email/InternalEmailService.java @@ -19,7 +19,7 @@ import javax.mail.MessagingException; /** * */ -public class InternalEmailService extends AbstractLifecycleComponent implements EmailService { +public class InternalEmailService extends AbstractLifecycleComponent implements EmailService { private final SecretService secretService; public static final Setting EMAIL_ACCOUNT_SETTING = diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/HipChatService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/HipChatService.java index 53baa995b52..eaad3872d9b 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/HipChatService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/HipChatService.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.component.LifecycleComponent; /** * */ -public interface HipChatService extends LifecycleComponent { +public interface HipChatService extends LifecycleComponent { /** * @return The default hipchat account. diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/InternalHipChatService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/InternalHipChatService.java index c64627e418d..9d9400f7c04 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/InternalHipChatService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/hipchat/InternalHipChatService.java @@ -15,7 +15,7 @@ import org.elasticsearch.xpack.common.http.HttpClient; /** * */ -public class InternalHipChatService extends AbstractLifecycleComponent implements HipChatService { +public class InternalHipChatService extends AbstractLifecycleComponent implements HipChatService { private final HttpClient httpClient; private volatile HipChatAccounts accounts; diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/InternalPagerDutyService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/InternalPagerDutyService.java index 56f33410fe4..5c3e16d2ba8 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/InternalPagerDutyService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/InternalPagerDutyService.java @@ -15,7 +15,7 @@ import org.elasticsearch.xpack.common.http.HttpClient; /** * */ -public class InternalPagerDutyService extends AbstractLifecycleComponent implements PagerDutyService { +public class InternalPagerDutyService extends AbstractLifecycleComponent implements PagerDutyService { public static final Setting PAGERDUTY_ACCOUNT_SETTING = Setting.groupSetting("xpack.notification.pagerduty.", Setting.Property.Dynamic, Setting.Property.NodeScope); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyService.java index 8135fa149af..73154b18bae 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/pagerduty/PagerDutyService.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.component.LifecycleComponent; /** * */ -public interface PagerDutyService extends LifecycleComponent { +public interface PagerDutyService extends LifecycleComponent { PagerDutyAccount getDefaultAccount(); diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/InternalSlackService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/InternalSlackService.java index 32e72f0c5c7..fe4e1d0658f 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/InternalSlackService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/InternalSlackService.java @@ -15,7 +15,7 @@ import org.elasticsearch.xpack.common.http.HttpClient; /** * */ -public class InternalSlackService extends AbstractLifecycleComponent implements SlackService { +public class InternalSlackService extends AbstractLifecycleComponent implements SlackService { private final HttpClient httpClient; public static final Setting SLACK_ACCOUNT_SETTING = diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/SlackService.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/SlackService.java index 65983272af7..f77006f3837 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/SlackService.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/notification/slack/SlackService.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.component.LifecycleComponent; /** * */ -public interface SlackService extends LifecycleComponent { +public interface SlackService extends LifecycleComponent { /** diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java index c491e5d7fb5..702319c55c0 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpClientTests.java @@ -60,7 +60,8 @@ public class HttpClientTests extends ESTestCase { authRegistry = new HttpAuthRegistry(singletonMap(BasicAuth.TYPE, new BasicAuthFactory(secretService))); webServer = startWebServer(); webPort = webServer.getPort(); - httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment).start(); + httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment); + httpClient.start(); } @After @@ -173,15 +174,16 @@ public class HttpClientTests extends ESTestCase { .put(HttpClient.SETTINGS_SSL_SECURITY_TRUSTSTORE_PASSWORD, "truststore-testnode-only") .build(); } - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); // We can't use the client created above for the server since it is only a truststore - webServer.useHttps(new HttpClient(Settings.builder() - .put(HttpClient.SETTINGS_SSL_KEYSTORE, getDataPath("/org/elasticsearch/xpack/security/keystore/testnode.jks")) - .put(HttpClient.SETTINGS_SSL_KEYSTORE_PASSWORD, "testnode") - .build(), authRegistry, environment) - .start() - .getSslSocketFactory(), false); + HttpClient httpClient2 = new HttpClient(Settings.builder() + .put(HttpClient.SETTINGS_SSL_KEYSTORE, getDataPath("/org/elasticsearch/xpack/security/keystore/testnode.jks")) + .put(HttpClient.SETTINGS_SSL_KEYSTORE_PASSWORD, "testnode") + .build(), authRegistry, environment); + httpClient2.start(); + webServer.useHttps(httpClient2.getSslSocketFactory(), false); webServer.enqueue(new MockResponse().setResponseCode(200).setBody("body")); HttpRequest.Builder request = HttpRequest.builder("localhost", webPort) @@ -211,7 +213,8 @@ public class HttpClientTests extends ESTestCase { .build(); } - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); webServer.useHttps(new ClientAuthRequiringSSLSocketFactory(httpClient.getSslSocketFactory()), false); webServer.enqueue(new MockResponse().setResponseCode(200).setBody("body")); @@ -247,7 +250,8 @@ public class HttpClientTests extends ESTestCase { .build(); } - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); assertThat(httpClient.getSslSocketFactory(), notNullValue()); Settings.Builder badSettings = Settings.builder().put(settings); @@ -293,7 +297,8 @@ public class HttpClientTests extends ESTestCase { @Network public void testHttpsWithoutTruststore() throws Exception { - HttpClient httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment); + httpClient.start(); assertThat(httpClient.getSslSocketFactory(), nullValue()); // Known server with a valid cert from a commercial CA @@ -312,7 +317,8 @@ public class HttpClientTests extends ESTestCase { Settings settings = Settings.builder() .put(setting, randomBoolean()) .build(); - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); assertThat(httpClient.getSslSocketFactory(), notNullValue()); // Known server with a valid cert from a commercial CA @@ -333,7 +339,8 @@ public class HttpClientTests extends ESTestCase { .put(HttpClient.SETTINGS_PROXY_HOST, "localhost") .put(HttpClient.SETTINGS_PROXY_PORT, proxyServer.getPort()) .build(); - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); HttpRequest.Builder requestBuilder = HttpRequest.builder("localhost", webPort) .method(HttpMethod.GET) @@ -361,7 +368,8 @@ public class HttpClientTests extends ESTestCase { .put(HttpClient.SETTINGS_PROXY_HOST, "localhost") .put(HttpClient.SETTINGS_PROXY_PORT, proxyServer.getPort() + 1) .build(); - HttpClient httpClient = new HttpClient(settings, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(settings, authRegistry, environment); + httpClient.start(); HttpRequest.Builder requestBuilder = HttpRequest.builder("localhost", webPort) .method(HttpMethod.GET) diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java index 8f019567deb..a51336dbf21 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpConnectionTimeoutTests.java @@ -29,7 +29,8 @@ public class HttpConnectionTimeoutTests extends ESTestCase { @Network public void testDefaultTimeout() throws Exception { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); - HttpClient httpClient = new HttpClient(Settings.EMPTY, mock(HttpAuthRegistry.class), environment).start(); + HttpClient httpClient = new HttpClient(Settings.EMPTY, mock(HttpAuthRegistry.class), environment); + httpClient.start(); HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .method(HttpMethod.POST) @@ -54,9 +55,9 @@ public class HttpConnectionTimeoutTests extends ESTestCase { public void testDefaultTimeoutCustom() throws Exception { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); HttpClient httpClient = new HttpClient(Settings.builder() - .put("xpack.http.default_connection_timeout", "5s") - .build() - , mock(HttpAuthRegistry.class), environment).start(); + .put("xpack.http.default_connection_timeout", "5s").build() + , mock(HttpAuthRegistry.class), environment); + httpClient.start(); HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .method(HttpMethod.POST) @@ -81,9 +82,9 @@ public class HttpConnectionTimeoutTests extends ESTestCase { public void testTimeoutCustomPerRequest() throws Exception { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); HttpClient httpClient = new HttpClient(Settings.builder() - .put("xpack.http.default_connection_timeout", "10s") - .build() - , mock(HttpAuthRegistry.class), environment).start(); + .put("xpack.http.default_connection_timeout", "10s").build() + , mock(HttpAuthRegistry.class), environment); + httpClient.start(); HttpRequest request = HttpRequest.builder(UNROUTABLE_IP, 12345) .connectionTimeout(TimeValue.timeValueSeconds(5)) diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpReadTimeoutTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpReadTimeoutTests.java index e598edbdbdd..58caf5ad8e2 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpReadTimeoutTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/common/http/HttpReadTimeoutTests.java @@ -48,7 +48,8 @@ public class HttpReadTimeoutTests extends ESTestCase { public void testDefaultTimeout() throws Exception { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); - HttpClient httpClient = new HttpClient(Settings.EMPTY, mock(HttpAuthRegistry.class), environment).start(); + HttpClient httpClient = new HttpClient(Settings.EMPTY, mock(HttpAuthRegistry.class), environment); + httpClient.start(); // we're not going to enqueue an response... so the server will just hang @@ -74,9 +75,9 @@ public class HttpReadTimeoutTests extends ESTestCase { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); HttpClient httpClient = new HttpClient(Settings.builder() - .put("xpack.http.default_read_timeout", "3s") - .build() - , mock(HttpAuthRegistry.class), environment).start(); + .put("xpack.http.default_read_timeout", "3s").build() + , mock(HttpAuthRegistry.class), environment); + httpClient.start(); final String path = '/' + randomAsciiOfLength(5); final CountDownLatch latch = new CountDownLatch(1); @@ -107,9 +108,9 @@ public class HttpReadTimeoutTests extends ESTestCase { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); HttpClient httpClient = new HttpClient(Settings.builder() - .put("xpack.http.default_read_timeout", "10s") - .build() - , mock(HttpAuthRegistry.class), environment).start(); + .put("xpack.http.default_read_timeout", "10s").build() + , mock(HttpAuthRegistry.class), environment); + httpClient.start(); final String path = '/' + randomAsciiOfLength(5); final CountDownLatch latch = new CountDownLatch(1); diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/validation/WatcherSettingsValidation.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/validation/WatcherSettingsValidation.java index f87eb233891..f320d151963 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/validation/WatcherSettingsValidation.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/validation/WatcherSettingsValidation.java @@ -18,7 +18,7 @@ import java.util.List; /** * */ -public class WatcherSettingsValidation extends AbstractLifecycleComponent { +public class WatcherSettingsValidation extends AbstractLifecycleComponent { private List errors = new ArrayList<>(); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java index f375e5d9354..00c55c20ed6 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/webhook/WebhookActionTests.java @@ -226,7 +226,8 @@ public class WebhookActionTests extends ESTestCase { public void testThatSelectingProxyWorks() throws Exception { Environment environment = new Environment(Settings.builder().put("path.home", createTempDir()).build()); - HttpClient httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment).start(); + HttpClient httpClient = new HttpClient(Settings.EMPTY, authRegistry, environment); + httpClient.start(); MockWebServer proxyServer = new MockWebServer(); try { diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index c0e046756d4..bc635db8019 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -594,7 +594,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase assertThat("watcher should only run on the elected master node, but it is running on [" + running + "] nodes", running, equalTo(1)); } - public static class NoopEmailService extends AbstractLifecycleComponent implements EmailService { + public static class NoopEmailService extends AbstractLifecycleComponent implements EmailService { public NoopEmailService() { super(Settings.EMPTY);