fix for npe

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@584929 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-10-15 21:36:37 +00:00
parent 1722001748
commit fe9bd4f594
1 changed files with 10 additions and 7 deletions

View File

@ -379,14 +379,17 @@ public class AMQMessageStore implements MessageStore {
*/ */
public Message getMessage(MessageId identity) throws IOException { public Message getMessage(MessageId identity) throws IOException {
Location location = getLocation(identity); Location location = getLocation(identity);
DataStructure rc = peristenceAdapter.readCommand(location); if (location != null) {
try { DataStructure rc = peristenceAdapter.readCommand(location);
return (Message) rc; try {
} catch (ClassCastException e) { return (Message) rc;
throw new IOException("Could not read message " + identity } catch (ClassCastException e) {
+ " at location " + location throw new IOException("Could not read message " + identity
+ ", expected a message, but got: " + rc); + " at location " + location
+ ", expected a message, but got: " + rc);
}
} }
return null;
} }
protected Location getLocation(MessageId messageId) throws IOException { protected Location getLocation(MessageId messageId) throws IOException {