public Messages getMessages() {
    if (messages == null) {
      // This kind of lazy loading pattern is acceptable without locking.
      // Changes to the messages field are atomic; in some race conditions, the call to
      // getMessages() may occur more than once (but it caches the value anyway).
      messages = elementResources.getMessages(componentModel);
    }

    return messages;
  }