This is an automated email from the ASF dual-hosted git repository.

michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new dbc4547  NO-JIRA Null Check in logging
     new 516ca81  This closes #2505
dbc4547 is described below

commit dbc4547dad66071f6cff9e6e9f3cc18deec8b255
Author: Michael André Pearce <michael.andre.pea...@me.com>
AuthorDate: Fri Jan 18 00:59:21 2019 +0000

    NO-JIRA Null Check in logging
---
 .../activemq/artemis/core/message/impl/CoreMessage.java      | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
index b14d4b6..7c2ea58 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
@@ -595,14 +595,16 @@ public class CoreMessage extends RefCountMessage 
implements ICoreMessage {
 
          return this.properties;
       } catch (Throwable e) {
-         ByteBuf duplicatebuffer = buffer.duplicate();
-         duplicatebuffer.readerIndex(0);
-
          // This is not an expected error, hence no specific logger created
          logger.warn("Could not decode properties for CoreMessage[messageID=" 
+ messageID + ",durable=" + durable + ",userID=" + userID + ",priority=" + 
priority +
             ", timestamp=" + timestamp + ",expiration=" + expiration + 
",address=" + address + ", propertiesLocation=" + propertiesLocation, e);
-         logger.warn("Failed message has messageID=" + messageID + " and the 
following buffer:\n" + ByteBufUtil.prettyHexDump(duplicatebuffer));
-
+         if (buffer != null) {
+            ByteBuf duplicatebuffer = buffer.duplicate();
+            duplicatebuffer.readerIndex(0);
+            logger.warn("Failed message has messageID=" + messageID + " and 
the following buffer:\n" + ByteBufUtil.prettyHexDump(duplicatebuffer));
+         } else {
+            logger.warn("Failed message has messageID=" + messageID + " and 
the buffer was null");
+         }
          throw new RuntimeException(e.getMessage(), e);
 
       }

Reply via email to