Skip to content

Conversation

Fudeveloper
Copy link
Contributor

When we use the method MapperBuilderAssistant#getStatementResultMaps, the name is trimmed . But in the method Configuration#AddResultMap, there is no trim operation. These asymmetrical operations will lead to this happening.

Perhaps, we can throw an error directly in the build phase when Namespace begins with a space. Just like this in method XMLMapperBuilder#configurationElement.

private void configurationElement(XNode context) {
    try {
      String namespace = context.getStringAttribute("namespace");
      if (namespace == null || namespace.isEmpty()) {
        throw new BuilderException("Mapper's namespace cannot be empty");
      }
      // like this
      if (namespace.startsWith(" ")) {
        throw new BuilderException("Mapper's namespace cannot start with whitespace.");
      }
     
        ...
    } catch (Exception e) {
      throw new BuilderException("Error parsing Mapper XML. The XML location is '" + resource + "'. Cause: " + e, e);
    }
  }

@coveralls
Copy link

Coverage Status

Coverage remained the same at 87.248% when pulling 0349cec on Fudeveloper:issue#2302 into 0cf1efb on mybatis:master.

@harawata
Copy link
Member

I should've closed this along with #2302 .

@harawata harawata closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants