Skip to content

SimpleNamespaceContext does not implement the full contract of the NamespaceContext interface [SPR-13713] #17620

@spring-projects-issues

Description

@spring-projects-issues

Leo Arnold opened SPR-13713 and commented

I reviewed the code of org.springframework.util.xml.SimpleNamespaceContext and found that it does not implement several features required by the documentation of javax.xml.namespace.NamespaceContext as per Java 8:

  • The iterator returned by getPrefixes(namespaceURI) is modifiable, but should not be.
  • Missing null check: getPrefix(null) does not throw IllegalArgumentException
  • Calling getPrefixes(namespaceURI) after a clear() can yield a non-empty iterator, because the map namespaceUriToPrefixes has not been cleared.

I would like to submit a pull request containing the following changes:

  • Update unit tests to ensure implementation of the full contract
  • Add/improve unit tests for all methods
  • Rewrite all assertions with Hamcrest's assertThat for type safety and better error messages when tests are failing
  • Fix implementation of SimpleNamespaceContext to make unit tests pass
  • Rename private method getPrefixesInternal to getPrefixesList as a more telling name

No functionality will be added or removed.


Affects: 4.2.2

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions