Skip to content

Commit

Permalink
Avoid NPE when writing messages with null headers to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonRoskvist committed Mar 17, 2021
1 parent 556e0c7 commit 0b79b4d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ private void saveMessageHeaders(Message msg, String baseName) throws JMSExceptio
Properties props = new Properties();
for (Enumeration<?> propertyNames = msg.getPropertyNames(); propertyNames.hasMoreElements();) {
String name = propertyNames.nextElement().toString();
try {
props.setProperty(name, msg.getStringProperty(name));
} catch (NullPointerException e) {
_logger.error("Header \"" + name + "\" has a null value on: " + msg.getJMSMessageID() + " Header is not stored");
continue;
}
props.setProperty(name, msg.getStringProperty(name));
}
props.store(fos, "JMS properties for " + msg.getJMSMessageID());
Expand Down Expand Up @@ -255,4 +261,4 @@ private void verifyChecksum(ChecksummedMessageData md, String jmsId, String appl
protected String[] getMessageLogHeaders() {
return new String[] { "ConsumedTime", "JMSID", "ID", "Length" };
}
}
}

0 comments on commit 0b79b4d

Please sign in to comment.