https://issues.apache.org/jira/browse/AMQ-5087 fix and test