DATAGEODE-309 - Apply Spring bean ClassLoader to Thread context ClassLoader in LocatorApplications.

This commit is contained in:
John Blum
2020-03-19 13:25:48 -07:00
parent dc2ab304c5
commit 5d2bec1dc7

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2018-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -95,28 +95,38 @@ public class LocatorFactoryBean extends AbstractFactoryBeanSupport<Locator> impl
public void init() {
LocatorLauncher.Builder locatorBuilder = configureGemfireProperties(newLocatorLauncherBuilder());
ClassLoader currentThreadContextClassLoader = Thread.currentThread().getContextClassLoader();
getBindAddress().ifPresent(locatorBuilder::setBindAddress);
getHostnameForClients().ifPresent(locatorBuilder::setHostnameForClients);
getName().ifPresent(locatorBuilder::setMemberName);
try {
locatorBuilder.set(LOG_LEVEL_PROPERTY, getLogLevel());
locatorBuilder.setPort(getPort());
Thread.currentThread().setContextClassLoader(getBeanClassLoader());
locatorBuilder = postProcess(locatorBuilder);
LocatorLauncher.Builder locatorBuilder = configureGemfireProperties(newLocatorLauncherBuilder());
this.locatorLauncher = postProcess(locatorBuilder.build());
getBindAddress().ifPresent(locatorBuilder::setBindAddress);
getHostnameForClients().ifPresent(locatorBuilder::setHostnameForClients);
getName().ifPresent(locatorBuilder::setMemberName);
LocatorLauncher.LocatorState locatorState = this.locatorLauncher.start();
locatorBuilder.set(LOG_LEVEL_PROPERTY, getLogLevel());
locatorBuilder.setPort(getPort());
/*
if (LocatorLauncher.Status.ONLINE.equals(locatorState.getStatus())) {
// log warning
locatorBuilder = postProcess(locatorBuilder);
this.locatorLauncher = postProcess(locatorBuilder.build());
LocatorLauncher.LocatorState locatorState = this.locatorLauncher.start();
/*
if (LocatorLauncher.Status.ONLINE.equals(locatorState.getStatus())) {
// log warning
}
*/
this.locator = this.locatorLauncher.getLocator();
}
finally {
Thread.currentThread().setContextClassLoader(currentThreadContextClassLoader);
}
*/
this.locator = this.locatorLauncher.getLocator();
}
protected LocatorLauncher.Builder configureGemfireProperties(LocatorLauncher.Builder locatorBuilder) {