https://issues.apache.org/jira/browse/AMQ-5395

Check for the presence of a prefix before asking for a substring
Remove unused imports