// returns just the first, as it's the first only
if (iterator.hasNext())
{
MessageReference ref = iterator.next();
Message message = ref.getMessage();
messages.add(message.toMap());
}
return toJSON(messages.toArray(new Map[1])).toString();
}
finally
{