我们遇到了Java类加载机制的一些非常奇怪的行为。我在实施Logback ClassCircularityError
时获得TurboFilter
。我有以下简单的实现:
public class ActivatingTurboFilter extends TurboFilter {
[...]
@Override
public FilterReply decide(Marker marker, Logger logger,
Level level, String format, Object[] params,
Throwable t) {
if (!expectedValue.equals(MDC.get(key)))
return NEUTRAL;
return isLevelAndLoggerValid(level, logger.getName()) ? ACCEPT : NEUTRAL;
}
}
应用程序在Jetty / 9.2.10上部署为WAR文件。当调用decide()
方法时,我得到了:
java.lang.ClassCircularityError: ch/qos/logback/core/spi/FilterReply
at me.bazhenov.whisperer.ActivatingTurboFilter.decide(ActivatingTurboFilter.java:33)
at ch.qos.logback.classic.spi.TurboFilterList.getTurboFilterChainDecision(TurboFilterList.java:62)
at ch.qos.logback.classic.LoggerContext.getTurboFilterChainDecision_0_3OrMore(LoggerContext.java:252)
at ch.qos.logback.classic.Logger.callTurboFilters(Logger.java:772)
at ch.qos.logback.classic.Logger.isTraceEnabled(Logger.java:644)
at ch.qos.logback.classic.Logger.isTraceEnabled(Logger.java:640)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.isTraceEnabled(SLF4JLocationAwareLog.java:60)
at org.apache.activemq.transport.failover.FailoverTransport.handleTransportFailure(FailoverTransport.java:208)
at org.apache.activemq.transport.failover.FailoverTransport$3.onException(FailoverTransport.java:186)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:160)
at org.apache.activemq.transport.InactivityMonitor.onException(InactivityMonitor.java:255)
at org.apache.activemq.transport.TransportSupport.onException(TransportSupport.java:96)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:205)
at java.lang.Thread.run(Thread.java:745)
其他一些信息:
ActivatingTurboFilter.java:33
,即返回FilterReply. NEUTRAL
的行; FilterReply
已经加载。它已使用-verbose:class
; jmap -histo
日志记录和实例计数进行了确认
lib
目录中。FilterReply
的一个定义可用)。使用-verbose:class
日志记录以及find . -name \*.jar | xargs -n 1 zipinfo | grep -i FilterReply
(在Jet文件主目录和 WAR文件的内容中)确认。我怀疑Jetty类加载有一些奇怪的东西,因为如果我在任何线程中调用此方法但Jetty请求处理线程(所谓的qtp
线程),一切正常。
我没有想法去寻找原因。