Skip to content

Allow annotation to be synthesized from a map with minimal attributes [SPR-13087] #17678

@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-13087 and commented

Status Quo

#17659 introduced support for synthesizing an annotation from a Map (or AnnotationAttributes). This initial support also validates the supplied map and requires that it "must contain key-value pairs for every attribute defined by the supplied annotationType."

The validation that MapAnnotationAttributeExtractor currently performs was implemented in order to support Spring's internal use case of synthesizing an annotation from merged AnnotationAttributes (as created by AnnotatedElementUtils), and for that use case it is in fact an error if any attributes defined by the annotation are not present (including aliased attributes).

However, there are use cases that would benefit from being able to supply a reduced set of attributes and still have the annotation synthesized properly. See the discussion in this Spring Integration pull request for an example.

Deliverables

  1. Refine the validation mechanism in MapAnnotationAttributeExtractor so that a reduced set of attributes may be supplied.
    • If an attribute is missing it should be set either to value of its alias (if an alias value exists) or to the value of the attribute's default value (if defined), and otherwise an exception should be thrown.

Affects: 4.2 RC2

Issue Links:

  • INT-3723 Fix IntegrationRequestMappingHandlerMapping according to the latest Spring Framework changes

Referenced from: commits d0c0d9f, ece12f9

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