SGF-611 - Handle possible ClassLoader errors (NPE) related to logging detailed information about Apache Geode on cache initialization.
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -31,14 +31,14 @@
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.springframework.data.gemfire.GemfireUtils.apacheGeodeProductName;
|
||||
import static org.springframework.data.gemfire.GemfireUtils.apacheGeodeVersion;
|
||||
import static org.springframework.data.gemfire.support.GemfireBeanFactoryLocator.newBeanFactoryLocator;
|
||||
|
||||
import java.io.File;
|
||||
@@ -187,7 +189,6 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@SuppressWarnings("deprecation")
|
||||
Cache init() throws Exception {
|
||||
ClassLoader currentThreadContextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
@@ -201,13 +202,15 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
|
||||
DistributedMember member = system.getDistributedMember();
|
||||
|
||||
log.info(String.format("Connected to Distributed System [%1$s] as Member [%2$s]"
|
||||
.concat("in Group(s) [%3$s] with Role(s) [%4$s] on Host [%5$s] having PID [%6$d]."),
|
||||
system.getName(), member.getId(), member.getGroups(), member.getRoles(), member.getHost(),
|
||||
member.getProcessId()));
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info(String.format("Connected to Distributed System [%1$s] as Member [%2$s]"
|
||||
.concat(" in Group(s) [%3$s] with Role(s) [%4$s] on Host [%5$s] having PID [%6$d]."),
|
||||
system.getName(), member.getId(), member.getGroups(), member.getRoles(), member.getHost(),
|
||||
member.getProcessId()));
|
||||
|
||||
log.info(String.format("%1$s GemFire v.%2$s Cache [%3$s].", cacheResolutionMessagePrefix,
|
||||
CacheFactory.getVersion(), cache.getName()));
|
||||
log.info(String.format("%1$s %2$s version [%3$s] Cache [%4$s].",
|
||||
cacheResolutionMessagePrefix, apacheGeodeProductName(), apacheGeodeVersion(), cache.getName()));
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,13 @@ import org.w3c.dom.Element;
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class GemfireUtils extends CacheUtils {
|
||||
|
||||
public final static String GEMFIRE_NAME = GemFireVersion.getProductName();
|
||||
public final static String GEMFIRE_VERSION = CacheFactory.getVersion();
|
||||
public final static String APACHE_GEODE_NAME = "Aache Geode";
|
||||
public final static String GEMFIRE_NAME = apacheGeodeProductName();
|
||||
public final static String GEMFIRE_VERSION = apacheGeodeVersion();
|
||||
public final static String UNKNOWN = "unknown";
|
||||
|
||||
private static final String ASYNC_EVENT_QUEUE_ELEMENT_NAME = "async-event-queue";
|
||||
private static final String ASYNC_EVENT_QUEUE_TYPE_NAME = "org.apache.geode.cache.asyncqueue.AsyncEventQueue";
|
||||
@@ -47,6 +50,26 @@ public abstract class GemfireUtils extends CacheUtils {
|
||||
private static final String GATEWAY_SENDER_ELEMENT_NAME = "gateway-sender";
|
||||
private static final String GATEWAY_SENDER_TYPE_NAME = "org.apache.geode.internal.cache.wan.GatewaySenderFactoryImpl";
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static String apacheGeodeProductName() {
|
||||
try {
|
||||
return GemFireVersion.getProductName();
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return APACHE_GEODE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static String apacheGeodeVersion() {
|
||||
try {
|
||||
return CacheFactory.getVersion();
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean isClassAvailable(String fullyQualifiedClassName) {
|
||||
return ClassUtils.isPresent(fullyQualifiedClassName, GemfireUtils.class.getClassLoader());
|
||||
@@ -115,5 +138,4 @@ public abstract class GemfireUtils extends CacheUtils {
|
||||
//System.out.printf("Is GemFire Version 6.5 of Above? %1$s%n", isGemfireVersion65OrAbove());
|
||||
//System.out.printf("Is GemFire Version 7.0 of Above? %1$s%n", isGemfireVersion7OrAbove());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
log4j.rootCategory=ERROR, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework.data" level="${logback.log.level:-error}"/>
|
||||
<logger name="org.springframework" level="${logback.log.level:-error}"/>
|
||||
|
||||
<root level="${logback.log.leve:-warn}">
|
||||
<root level="${logback.log.level:-error}">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
Reference in New Issue
Block a user