apply patch (with modification to fix a null pointer violation case) fixes: https://issues.apache.org/activemq/browse/AMQ-2990