Merge pull request #481 from jbonofre/AMQ-7424

[AMQ-7424] Prevent NPE during commitRemove() on JDBC adapter
This commit is contained in:
Jean-Baptiste Onofré 2020-02-29 07:09:56 +01:00 committed by GitHub
commit 80d06fc186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);