logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1582053 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
Date Wed, 26 Mar 2014 20:54:56 GMT
Author: ggregory
Date: Wed Mar 26 20:54:56 2014
New Revision: 1582053

URL: http://svn.apache.org/r1582053
Log:
Bullet-proofing.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java?rev=1582053&r1=1582052&r2=1582053&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/net/AbstractJMSReceiver.java
Wed Mar 26 20:54:56 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.logging.log4j.core.net;
 
+import java.io.Serializable;
+
 import javax.jms.JMSException;
 import javax.jms.ObjectMessage;
 import javax.naming.Context;
@@ -43,11 +45,15 @@ public abstract class AbstractJMSReceive
      */
     @Override
     public void onMessage(final javax.jms.Message message) {
-
         try {
             if (message instanceof ObjectMessage) {
                 final ObjectMessage objectMessage = (ObjectMessage) message;
-                log((LogEvent) objectMessage.getObject());
+                final Serializable object = objectMessage.getObject();
+                if (object instanceof LogEvent) {
+                    log((LogEvent) object);
+                } else {
+                    logger.warn("Received message is of type " + object.getClass().getName()
+ ", was expecting LogEvent.");
+                }
             } else {
                 logger.warn("Received message is of type " + message.getJMSType()
                     + ", was expecting ObjectMessage.");



Mime
View raw message