mirror of https://github.com/apache/activemq.git
Protect against appending recursion (In case your JMS provider appends to log4j in the process of sending a JMS message).
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1407200 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ecaae53fe8
commit
763aa74757
|
@ -137,13 +137,20 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton {
|
|||
return getSession().createProducer(null);
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Object> APPENDING = new ThreadLocal<Object>();
|
||||
|
||||
protected void append(LoggingEvent event) {
|
||||
try {
|
||||
Message message = createMessage(event);
|
||||
Destination destination = getDestination(event);
|
||||
getProducer().send(destination, message);
|
||||
} catch (Exception e) {
|
||||
getErrorHandler().error("Could not send message due to: " + e, e, JMS_PUBLISH_ERROR_CODE, event);
|
||||
if( APPENDING.get()==null ) {
|
||||
APPENDING.set(true);
|
||||
try {
|
||||
Message message = createMessage(event);
|
||||
Destination destination = getDestination(event);
|
||||
getProducer().send(destination, message);
|
||||
} catch (Exception e) {
|
||||
getErrorHandler().error("Could not send message due to: " + e, e, JMS_PUBLISH_ERROR_CODE, event);
|
||||
} finally {
|
||||
APPENDING.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue