Make sure license plugins classes are loaded before we can instantiate them

Original commit: elastic/x-pack-elasticsearch@c46fd7287e
This commit is contained in:
Simon Willnauer 2015-10-27 23:23:44 +01:00
parent c74ae7aad2
commit 70ed74cd7d
1 changed files with 10 additions and 2 deletions

View File

@ -69,7 +69,8 @@ public class ShieldPlugin extends Plugin {
private final Settings settings;
private final boolean enabled;
private final boolean clientMode;
private final ShieldLicenseState shieldLicenseState = new ShieldLicenseState();
private ShieldLicenseState shieldLicenseState;
public ShieldPlugin(Settings settings) {
this.settings = settings;
@ -99,6 +100,10 @@ public class ShieldPlugin extends Plugin {
new ShieldTransportModule(settings),
new SSLModule(settings));
} else {
// we can't load that at construction time since the license plugin might not have been loaded at that point
// which might not be the case during Plugin class instantiation. Once nodeModules are pulled
// everything should have been loaded
shieldLicenseState = new ShieldLicenseState();
return Arrays.<Module>asList(
new ShieldModule(settings),
new LicenseModule(settings, shieldLicenseState),
@ -155,7 +160,10 @@ public class ShieldPlugin extends Plugin {
if (enabled == false) {
return;
}
module.setSearcherWrapper((indexService) -> new ShieldIndexSearcherWrapper(indexService.getIndexSettings(), indexService.queryParserService(), indexService.mapperService(), indexService.bitsetFilterCache(), shieldLicenseState));
assert shieldLicenseState != null;
module.setSearcherWrapper((indexService) -> new ShieldIndexSearcherWrapper(indexService.getIndexSettings(),
indexService.queryParserService(), indexService.mapperService(),
indexService.bitsetFilterCache(), shieldLicenseState));
if (clientMode == false) {
module.registerQueryCache(ShieldPlugin.OPT_OUT_QUERY_CACHE, OptOutQueryCache::new);
}