[AMQ-7424] Prevent NPE during commitRemove() on JDBC adapter

This commit is contained in:
jbonofre 2020-02-27 21:21:47 +01:00
parent 6e650841fd
commit d8ae8734a9
1 changed files with 3 additions and 1 deletions

View File

@ -800,7 +800,9 @@ public class JDBCPersistenceAdapter extends DataSourceServiceSupport implements
public void commitRemove(ConnectionContext context, MessageAck ack) throws IOException {
TransactionContext c = getTransactionContext(context);
try {
getAdapter().doRemoveMessage(c, (Long)ack.getLastMessageId().getEntryLocator(), null);
if (c != null && ack != null && ack.getLastMessageId() != null && ack.getLastMessageId().getEntryLocator() != null) {
getAdapter().doRemoveMessage(c, (Long) ack.getLastMessageId().getEntryLocator(), null);
}
} catch (SQLException e) {
JDBCPersistenceAdapter.log("JDBC Failure: ", e);
throw IOExceptionSupport.create("Failed to commit last ack: " + ack + ". Reason: " + e,e);